Skip to main content

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.

Constructors​

MemberWhat it is
Recycler()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

23 private and internal fields
MemberWhat it is
private Dictionary<NetworkEntity, Recycler.MeltingModelReference> affectingItems being heated in the smelting area, with the heat points they have inside it.
private AmbientTemperatureChecker ambientTemperatureCheckerReads the ambient temperature at the recycler. Server.
private PumpingMechanism bellowsThe pumping mechanism that heats the recycler.
private AnimationCurve bellowValueToConsumptionCurve from the bellows' steady value to fuel burned per second.
private AnimationCurve bellowValueToTemperatureCurve from the bellows' steady value to how far toward targetTemperature the area heats.
private float consumedFuel burned so far toward the next item taken from the fuel dock.
private IUnityUpdateMethod consumptionUpdateHandle for the registered ConsumeFuel method.
private List<Recycler.MeltingModelReference> destroyedScratch list of tracked items found destroyed during an update.
private PickupDock fueldDockDock holding the fuel.
private bool isLitTrue while fuel is burning.
private static Logger loggerNLog logger for this class.
private IUnityUpdateMethod meltingModelsUpdateHandle for the registered UpdateMeltingModels method.
private DynamicQueue<RecyclerOutputSlot> orderedSlotsOutput slots ordered by last use. Saved in this order.
private List<Recycler.MeltingModelReference> readyToMeltScratch list of tracked items ready to melt during an update.
private float recycleEfficiencyShare of an item's ingot value it gives back. Defaults to 0.6.
private RecyclerOutputSlot[] slotsThe output slots that hold recycled material.
private HeatArea smeltingAreaHeat area items are placed in to melt.
private MethodSync syncFullMethod sync on SyncA for all slots and the temperature.
private MethodSyncStruct<int> syncOutputEffectMethod sync on EffectRequest for one slot.
private MethodSync syncTemperatureValueMethod sync on SyncB for the temperature.
private float targetTemperatureTemperature the smelting area reaches at full bellows.
private TemperatureVisuals temperatureVisualsVisuals that show the current temperature on clients.
private static UpdateModule updateModuleShared late-update module for all recyclers.

Properties​

MemberWhat it is
bool HasFuel { get; }True while the fuel dock holds anything.

Methods​

MemberWhat 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
MemberWhat 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.