Skip to main content

HeatArea

A class in Root.Township, Alta.Heat.

Server: a trigger area that heats or cools heat points inside it, toward a set temperature or from a heat source such as a fire. Removed on clients. Only the highest priority area touching a point affects it.

Constructors​

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

Fields​

12 private and internal fields
MemberWhat it is
private Dictionary<Collider, HeatPoint> affectingPointsHeat points inside the trigger, keyed by their collider.
private AmbientTemperatureChecker ambientCheckerReads the ambient temperature at this entity.
private GameObject colliderObjectThe trigger object; its active state is IsActive.
private HashSet<HeatPoint> externallyRegisteredHeatPointsHeat points added by code through RegisterHeatPointExternal rather than by trigger.
private IHeatSource heatSourceThe IHeatSource this area spreads, if any. Server only.
private Object heatSourceObjectSerialized reference to the heat source object.
private static Logger loggerNLog logger for this class.
private int priorityArea priority (0 base, 1 cooking). A point is only heated by its highest-priority area.
private float targetTemperatureBacking field for TargetTemperature.
private IUnityUpdateMethod updateRegistration on the update module while points are present.
private Action<HeatPoint, float> UpdateHeatPointChosen at init: ConductToHeatPoint with a heat source, otherwise BaseHeatPointUpdate.
private static UpdateModule updateModuleShared fixed-update module for all heat areas.

Properties​

MemberWhat it is
int AffectHeatPointCount { get; }How many heat points are being affected.
Func<HeatPoint, float> GetTemperatureMultiplier { get; set; }Function giving each point a 0 to 1 weight for how strongly the area affects it. Always 1 by default.
bool IsActive { get; }Whether the area's trigger object is active.
float TargetTemperature { get; set; }The temperature points are pulled toward when there's no heat source. 23 by default.

Events​

MemberWhat it is
event Action<HeatPoint> AddedHeatPointRaised when a heat point starts being affected.
event HeatArea.PointFilterDelegate PointFilterLets listeners reject a heat point that enters the trigger.
event Action<HeatPoint> RemovedHeatPointRaised when a heat point stops being affected.

Methods​

MemberWhat it is
void DeregisterHeatPointExternal(HeatPoint heatPoint)Stops affecting a heat point added with RegisterHeatPointExternal.
override void Initialize()Server: picks heat source or target temperature mode. On clients the component removes itself.
override void InitializeAsServer(SpawnData spawnData)Server: starts updating if points are already inside.
void RegisterHeatPointExternal(HeatPoint heatPoint)Affects a heat point without it being in the trigger.
void SetActive(bool isActive)Turns the area's trigger on or off. Turning it off forgets the points inside.
14 private and internal methods
MemberWhat it is
private void Awake()Server: caches the heat source from heatSourceObject.
private void BaseHeatPointUpdate(HeatPoint heatPoint, float multiplier)Used when there's no heat source: moves a point's temperature toward a blend of ambient and TargetTemperature.
private void CheckForDisabled()Stops the update when no heat points are left.
private void CheckForEnabled()Starts the update once at least one heat point is registered.
private void ConductToHeatPoint(HeatPoint point, float weight)Used with a heat source: conducts the source's heat into a point, weighted by the multiplier.
private void DeregisterHeatPoint(HeatPoint heatPoint, Collider heatPointCollider)Removes a heat point (and its collider if given), drops this area's priority from it and fires RemovedHeatPoint.
private void DeregisterHeatPoint(HeatPoint heatPoint)Removes a heat point (and its collider if given), drops this area's priority from it and fires RemovedHeatPoint.
private void OnDestroy()Server: removes the update.
private void OnTriggerEnter(Collider other)Registers a HeatPoint found on the entering collider or its rigidbody, if PointFilter allows it.
private void OnTriggerExit(Collider other)Deregisters the heat point of a collider that leaves the trigger.
private void RegisterHeatPoint(HeatPoint heatPoint, Collider heatPointCollider)Adds a heat point (with its collider if given), gives it this area's priority and fires AddedHeatPoint.
private void RegisterHeatPoint(HeatPoint heatPoint)Adds a heat point (with its collider if given), gives it this area's priority and fires AddedHeatPoint.
private void UpdateAffected()Fixed update: heats every point in range, and drops one point per tick that is destroyed, disabled or failed.
private bool UpdateHeatPointTemperature(HeatPoint heatPoint)Updates one point if this area is its highest-priority area. Returns false and logs if it throws.

Used in​

Members of other types that take, return or hold a HeatArea: