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.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
NetworkEntityBehaviour - Nested types
PointFilterDelegate - Documented in Heat
Constructors
| Member | What it is |
|---|---|
HeatArea() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
12 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<Collider, HeatPoint> affectingPoints | Heat points inside the trigger, keyed by their collider. |
private AmbientTemperatureChecker ambientChecker | Reads the ambient temperature at this entity. |
private GameObject colliderObject | The trigger object; its active state is IsActive. |
private HashSet<HeatPoint> externallyRegisteredHeatPoints | Heat points added by code through RegisterHeatPointExternal rather than by trigger. |
private IHeatSource heatSource | The IHeatSource this area spreads, if any. Server only. |
private Object heatSourceObject | Serialized reference to the heat source object. |
private static Logger logger | NLog logger for this class. |
private int priority | Area priority (0 base, 1 cooking). A point is only heated by its highest-priority area. |
private float targetTemperature | Backing field for TargetTemperature. |
private IUnityUpdateMethod update | Registration on the update module while points are present. |
private Action<HeatPoint, float> UpdateHeatPoint | Chosen at init: ConductToHeatPoint with a heat source, otherwise BaseHeatPointUpdate. |
private static UpdateModule updateModule | Shared fixed-update module for all heat areas. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action<HeatPoint> AddedHeatPoint | Raised when a heat point starts being affected. |
event HeatArea.PointFilterDelegate PointFilter | Lets listeners reject a heat point that enters the trigger. |
event Action<HeatPoint> RemovedHeatPoint | Raised when a heat point stops being affected. |
Methods
| Member | What 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
| Member | What 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: