Game.Events.EventUtils
Assembly: Assembly-CSharp
Namespace: Game.Events
Type: static class
Base: System.Object
Summary:
Utility helpers for event-related calculations and comparisons used by the game's event system. Provides constants for event timing/tolerances and small helper methods to compute the severity of a weather phenomenon at a position and to compare danger flags to determine which is "worse".
Fields
-
public const uint MIN_IN_DANGER_TIME
Minimum amount of time (in whatever internal time units the game uses) considered for an entity to be "in danger". This constant is 64u and is used to gate or compare danger durations in event logic. -
public const float FLOOD_DEPTH_TOLERANCE
Tolerance (in world units/meters) for flood depth comparisons. This constant is 0.5f and is intended as a small threshold to avoid treating very shallow water as damaging.
Properties
- None (static utility class)
Constructors
- None (static utility class)
Methods
public static float GetSeverity(float3 position, WeatherPhenomenon weatherPhenomenon, WeatherPhenomenonData weatherPhenomenonData)
Calculates a severity value for a given world position relative to a weather phenomenon (e.g., storm, fire hotspot). Implementation details:- Computes normalized distance from the phenomenon hotspot: distance(position.xz, hotspot.xz) / hotspotRadius.
- Computes raw severity: intensity * weatherPhenomenonData.m_DamageSeverity * (1 - normalizedDistance).
- If the computed severity is less than 0.001 (including negative values), the method returns 0. Otherwise it returns the computed severity.
- Return value is a float where 0 means no effective severity and larger values indicate greater severity at the supplied position.
-
Notes: If the position is outside the hotspot radius (normalizedDistance >= 1) the (1 - normalizedDistance) term will reduce severity and it may be clamped to 0 by the threshold. The method uses only the XZ plane for distance, ignoring Y (height).
-
public static bool IsWorse(DangerFlags flags, DangerFlags other)
Compares two DangerFlags bitmasks and returns true ifflags
represents a "worse" (more severe) instruction thanother
. Implementation details: - Computes difference bits with XOR: difference = flags ^ other.
- If the Evacuate bit differs between the two, the method returns true when the Evacuate bit is set in
flags
(Evacuate is considered worse than not-evacuate). - Otherwise, if the StayIndoors bit differs, the method returns true when the StayIndoors bit is set in
flags
. - If neither Evacuate nor StayIndoors differ, the method returns false.
- Notes: This method relies on the presence of Evacuate and StayIndoors members in the DangerFlags enum (expected to be a [Flags] enum). The method gives priority to Evacuate over StayIndoors when determining which is worse.
Usage Example
using Game.Events;
using Game.Prefabs;
using Unity.Mathematics;
// Example: compute severity at a position for a given weather phenomenon
float3 myPos = new float3(120f, 0f, 85f);
// These objects are normally provided by the game's systems; shown here as placeholders:
WeatherPhenomenon phenomenon = /* obtain phenomenon instance */;
WeatherPhenomenonData phenomenonData = /* obtain phenomenon data */;
float severity = EventUtils.GetSeverity(myPos, phenomenon, phenomenonData);
if (severity > 0f)
{
// handle damage or effects scaled by severity
}
// Example: compare danger flags
DangerFlags a = DangerFlags.StayIndoors | DangerFlags.SomeOtherFlag;
DangerFlags b = DangerFlags.None;
bool aIsWorse = EventUtils.IsWorse(a, b);
if (aIsWorse)
{
// prioritize a's instructions over b's
}
Notes and tips: - GetSeverity uses only the XZ plane for distance checks; vertical offset (Y) is ignored. - The severity threshold (0.001f) prevents tiny floating values from being treated as damage; treat returned float as already-clamped for practical checks. - IsWorse only checks Evacuate and StayIndoors bits. If your DangerFlags enum has other levels or priorities, extend this helper accordingly.