-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModEntry.cs
52 lines (49 loc) · 2.06 KB
/
ModEntry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Buildings;
namespace AVerySpecialBlueChicken
{
public class ModEntry : Mod
{
public override void Entry(IModHelper helper)
{
Config = Helper.ReadConfig<Config>();
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
}
Random random = new Random();
public double PercentageChance { get; set; }
public int HeartLevel { get; set; }
internal Config Config { get; set; }
private void OnDayStarted(object sender, DayStartedEventArgs e)
{
int[] playerWantedLevel = new[] { 0, 200, 400, 600, 800, 1000 };
var heartLevel = playerWantedLevel[Config.HeartLevel];
foreach (Building building in Game1.getFarm().buildings)
{
if (building is Coop coop)
{
foreach (FarmAnimal animal in (building.indoors.Value as AnimalHouse).animals.Values)
{
if (animal.type.Value == "Blue Chicken" &&
animal.friendshipTowardFarmer.Value >= heartLevel &&
random.NextDouble() <= Config.PercentageChance)
{
foreach (KeyValuePair<Vector2, StardewValley.Object> objectAndLocation in building.indoors.Value.Objects.Pairs)
{
if (objectAndLocation.Value.ParentSheetIndex == 174 || objectAndLocation.Value.ParentSheetIndex == 176)
{
building.indoors.Value.Objects[objectAndLocation.Key] = new StardewValley.Object(objectAndLocation.Key, 797, "Pearl", false, true, false, true);
break;
}
}
}
}
}
}
}
}
}