forked from Pathoschild/StardewMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KegMachine.cs
111 lines (102 loc) · 4.16 KB
/
KegMachine.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using Microsoft.Xna.Framework;
using StardewValley;
using SObject = StardewValley.Object;
namespace Pathoschild.Stardew.Automate.Framework.Machines.Objects
{
/// <summary>A keg that accepts input and provides output.</summary>
/// <remarks>See the game's machine logic in <see cref="SObject.performObjectDropInAction"/> and <see cref="SObject.checkForAction"/>.</remarks>
internal class KegMachine : GenericObjectMachine<SObject>
{
/*********
** Fields
*********/
/// <summary>The recipes to process.</summary>
private readonly IRecipe[] Recipes =
{
// honey => mead
new Recipe(
input: 340,
inputCount: 1,
output: input => new SObject(Vector2.Zero, 459, "Mead", false, true, false, false) { name = "Mead" },
minutes: 600
),
// coffee bean => coffee
new Recipe(
input: 433,
inputCount: 5,
output: input => new SObject(Vector2.Zero, 395, "Coffee", false, true, false, false) { name = "Coffee" },
minutes: 120
),
// tea leaves => green tea
new Recipe(
input: 815,
inputCount: 1,
output: input => new Object(Vector2.Zero, 614, "Green Tea", false, true, false, false) { name = "Green Tea" },
minutes: 180
),
// wheat => beer
new Recipe(
input: 262,
inputCount: 1,
output: input => new SObject(Vector2.Zero, 346, "Beer", false, true, false, false) { name = "Beer" },
minutes: 1750
),
// hops => pale ale
new Recipe(
input: 304,
inputCount: 1,
output: input => new SObject(Vector2.Zero, 303, "Pale Ale", false, true, false, false) { name = "Pale Ale" },
minutes: 2250
),
// fruit => wine
new Recipe(
input: SObject.FruitsCategory,
inputCount: 1,
output: input =>
{
SObject wine = new SObject(Vector2.Zero, 348, input.Name + " Wine", false, true, false, false)
{
name = input.Name + " Wine",
Price = ((SObject)input).Price * 3
};
wine.preserve.Value = SObject.PreserveType.Wine;
wine.preservedParentSheetIndex.Value = input.ParentSheetIndex;
return wine;
},
minutes: 10000
),
new Recipe(
input: SObject.VegetableCategory,
inputCount: 1,
output: input =>
{
SObject juice = new SObject(Vector2.Zero, 350, input.Name + " Juice", false, true, false, false)
{
name = input.Name + " Juice",
Price = (int)(((SObject)input).Price * 2.25)
};
juice.preserve.Value = SObject.PreserveType.Juice;
juice.preservedParentSheetIndex.Value = input.ParentSheetIndex;
return juice;
},
minutes: 6000
)
};
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="machine">The underlying machine.</param>
/// <param name="location">The location containing the machine.</param>
/// <param name="tile">The tile covered by the machine.</param>
public KegMachine(SObject machine, GameLocation location, Vector2 tile)
: base(machine, location, tile) { }
/// <summary>Provide input to the machine.</summary>
/// <param name="input">The available items.</param>
/// <returns>Returns whether the machine started processing an item.</returns>
public override bool SetInput(IStorage input)
{
return this.GenericPullRecipe(input, this.Recipes);
}
}
}