forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLatheComponent.cs
More file actions
130 lines (109 loc) · 4.14 KB
/
Copy pathLatheComponent.cs
File metadata and controls
130 lines (109 loc) · 4.14 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using Content.Shared.Construction.Prototypes;
using Content.Shared.Lathe.Prototypes;
using Content.Shared.Research.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Lathe
{
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class LatheComponent : Component
{
/// <summary>
/// All of the recipe packs that the lathe has by default
/// </summary>
[DataField]
public List<ProtoId<LatheRecipePackPrototype>> StaticPacks = new();
/// <summary>
/// All of the recipe packs that the lathe is capable of researching
/// </summary>
[DataField]
public List<ProtoId<LatheRecipePackPrototype>> DynamicPacks = new();
// Note that this shouldn't be modified dynamically.
// I.e., this + the static recipies should represent all recipies that the lathe can ever make
// Otherwise the material arbitrage test and/or LatheSystem.GetAllBaseRecipes needs to be updated
/// <summary>
/// The lathe's construction queue.
/// </summary>
/// <remarks>
/// This is a LinkedList to allow for constant time insertion/deletion (vs a List), and more efficient
/// moves (vs a Queue).
/// </remarks>
[DataField]
public LinkedList<LatheRecipeBatch> Queue = new();
/// <summary>
/// The sound that plays when the lathe is producing an item, if any
/// </summary>
[DataField]
public SoundSpecifier? ProducingSound;
[DataField]
public string? ReagentOutputSlotId;
/// <summary>
/// The default amount that's displayed in the UI for selecting the print amount.
/// </summary>
[DataField, AutoNetworkedField]
public int DefaultProductionAmount = 1;
#region Visualizer info
[DataField]
public string? IdleState;
[DataField]
public string? RunningState;
[DataField]
public string? UnlitIdleState;
[DataField]
public string? UnlitRunningState;
#endregion
/// <summary>
/// The recipe the lathe is currently producing
/// </summary>
[ViewVariables]
public ProtoId<LatheRecipePrototype>? CurrentRecipe;
#region MachineUpgrading
/// <summary>
/// A modifier that changes how long it takes to print a recipe
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float TimeMultiplier = 1;
/// <summary>
/// A modifier that changes how much of a material is needed to print a recipe
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float MaterialUseMultiplier = 1;
#endregion
}
public sealed class LatheGetRecipesEvent : EntityEventArgs
{
public readonly EntityUid Lathe;
public readonly LatheComponent Comp;
public bool GetUnavailable;
public HashSet<ProtoId<LatheRecipePrototype>> Recipes = new();
public LatheGetRecipesEvent(Entity<LatheComponent> lathe, bool forced)
{
(Lathe, Comp) = lathe;
GetUnavailable = forced;
}
}
[Serializable]
public sealed partial class LatheRecipeBatch
{
public ProtoId<LatheRecipePrototype> Recipe;
public int ItemsPrinted;
public int ItemsRequested;
public LatheRecipeBatch(ProtoId<LatheRecipePrototype> recipe, int itemsPrinted, int itemsRequested)
{
Recipe = recipe;
ItemsPrinted = itemsPrinted;
ItemsRequested = itemsRequested;
}
}
/// <summary>
/// Event raised on a lathe when it starts producing a recipe.
/// </summary>
[ByRefEvent]
public readonly record struct LatheStartPrintingEvent(LatheRecipePrototype Recipe);
/// <summary>
/// Event raised on a lathe when it finishes producing a recipe.
/// </summary>
[ByRefEvent]
public readonly record struct LatheFinishPrintingEvent(LatheRecipePrototype Recipe);
}