forked from Pathoschild/StardewMods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachineWrapper.cs
More file actions
57 lines (48 loc) · 2.1 KB
/
MachineWrapper.cs
File metadata and controls
57 lines (48 loc) · 2.1 KB
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
using System;
using Microsoft.Xna.Framework;
using StardewValley;
namespace Pathoschild.Stardew.Automate.Framework
{
/// <summary>Wraps a machine instance to simplify patching.</summary>
internal class MachineWrapper : IMachine
{
/*********
** Accessors
*********/
/// <summary>The wrapped machine instance.</summary>
public IMachine Machine { get; }
/// <summary>The location which contains the machine.</summary>
public GameLocation Location => this.Machine.Location;
/// <summary>The tile area covered by the machine.</summary>
public Rectangle TileArea => this.Machine.TileArea;
/// <summary>A unique ID for the machine type.</summary>
/// <remarks>This value should be identical for two machines if they have the exact same behavior and input logic. For example, if one machine in a group can't process input due to missing items, Automate will skip any other empty machines of that type in the same group since it assumes they need the same inputs.</remarks>
public string MachineTypeID => this.Machine.MachineTypeID;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="machine">The wrapped machine instance.</param>
public MachineWrapper(IMachine machine)
{
this.Machine = machine ?? throw new ArgumentNullException(nameof(machine));
}
/// <summary>Get the machine's processing state.</summary>
public MachineState GetState()
{
return this.Machine.GetState();
}
/// <summary>Get the output item.</summary>
public ITrackedStack GetOutput()
{
return this.Machine.GetOutput();
}
/// <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 bool SetInput(IStorage input)
{
return this.Machine.SetInput(input);
}
}
}