Recycler
A class in Root.Township, Alta.Blacksmithing.
Melts metal items back into material. Pumping the bellows with fuel heats its smelting area; items that reach melting point are destroyed and add 60% of their ingot value to an output slot. The server runs the melting.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour,ISavable<RecyclerSaveData>,ISavableSave<RecyclerSaveData>,ISavableSaveBase - Derived types
RecyclerSaveData - Nested types
MeltingModelReference - Documented in Smelting and forging
Constructors
| Member | What it is |
|---|---|
Recycler() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
23 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<NetworkEntity, Recycler.MeltingModelReference> affecting | Items being heated in the smelting area, with the heat points they have inside it. |
private AmbientTemperatureChecker ambientTemperatureChecker | Reads the ambient temperature at the recycler. Server. |
private PumpingMechanism bellows | The pumping mechanism that heats the recycler. |
private AnimationCurve bellowValueToConsumption | Curve from the bellows' steady value to fuel burned per second. |
private AnimationCurve bellowValueToTemperature | Curve from the bellows' steady value to how far toward targetTemperature the area heats. |
private float consumed | Fuel burned so far toward the next item taken from the fuel dock. |
private IUnityUpdateMethod consumptionUpdate | Handle for the registered ConsumeFuel method. |
private List<Recycler.MeltingModelReference> destroyed | Scratch list of tracked items found destroyed during an update. |
private PickupDock fueldDock | Dock holding the fuel. |
private bool isLit | True while fuel is burning. |
private static Logger logger | NLog logger for this class. |
private IUnityUpdateMethod meltingModelsUpdate | Handle for the registered UpdateMeltingModels method. |
private DynamicQueue<RecyclerOutputSlot> orderedSlots | Output slots ordered by last use. Saved in this order. |
private List<Recycler.MeltingModelReference> readyToMelt | Scratch list of tracked items ready to melt during an update. |
private float recycleEfficiency | Share of an item's ingot value it gives back. Defaults to 0.6. |
private RecyclerOutputSlot[] slots | The output slots that hold recycled material. |
private HeatArea smeltingArea | Heat area items are placed in to melt. |
private MethodSync syncFull | Method sync on SyncA for all slots and the temperature. |
private MethodSyncStruct<int> syncOutputEffect | Method sync on EffectRequest for one slot. |
private MethodSync syncTemperatureValue | Method sync on SyncB for the temperature. |
private float targetTemperature | Temperature the smelting area reaches at full bellows. |
private TemperatureVisuals temperatureVisuals | Visuals that show the current temperature on clients. |
private static UpdateModule updateModule | Shared late-update module for all recyclers. |
Properties
| Member | What it is |
|---|---|
bool HasFuel { get; } | True while the fuel dock holds anything. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the syncs, hooks the bellows' pump filter and sets up each output slot. |
override void InitializeAsServer(SpawnData spawnData) | Hooks the smelting area and bellows events and fills the slot order on the server. |
override void OnConnected(Player player) | Sends all slot contents and the temperature to a joining player. |
11 private and internal methods
| Member | What it is |
|---|---|
private void AddedHeatPoint(HeatPoint newHeatPoint) | Server: starts tracking an item when one of its heat points enters the smelting area, if it can melt. |
private void BellowsFilter(ref bool isValid) | Blocks pumping the bellows while the fuel dock is empty. |
private void ConsumeFuel() | Server update that burns fuel at a rate set by the bellows' steady value; stops when out of fuel or the bellows are idle. |
private RecyclerOutputSlot GetSlot(PhysicalMaterial material) | Picks the output slot for a material: one already holding it, else an empty one, else reuses the least recently used slot. |
private void OnDestroy() | Stops the melting and fuel updates. |
private void RemovedHeatPoint(HeatPoint oldHeatPoint) | Server: stops tracking an item once none of its heat points are in the smelting area. |
private void SyncFull(IPlayer player, Stream stream) | Method sync for every output slot plus the temperature. |
private void SyncOutputEffect(IPlayer player, Stream stream, int index) | Method sync for one output slot's contents, by index. |
private void SyncTemperatureValue(IPlayer player, Stream stream) | Method sync for the bellows' value and steady value. Clients update the temperature visuals. |
private void UpdatedBellows(PumpingMechanism bellows, float steadyValue) | Server: sets the smelting area's target temperature from the bellows, lights the fuel burn and syncs the temperature. |
private void UpdateMeltingModels() | Server update that melts tracked items at melting point (when the area is hot enough) into output slots. |