Game.Effects.EffectControlData
Assembly: Assembly-CSharp.dll
Namespace: Game.Effects
Type: struct
Base: System.ValueType
Summary: EffectControlData is a helper/utility struct used by effect-related systems to cache ComponentLookup/BufferLookup objects and other context needed to evaluate whether an effect (visual/light/etc.) should be active for a given entity. It centralizes read-only access to many ECS component types and provides logic to test effect conditions (operational, on fire, lights, boarding, etc.) based on entity state, simulation frame and pseudo-random seeds. This is used to avoid repeatedly creating lookups and to keep effect enable/disable logic consistent across effect systems.
Fields
-
public ComponentLookup<Owner> m_Owners
This lookup lets the code query an entity's Owner component to traverse attachment/ownership relationships. -
public ComponentLookup<Transform> m_Transforms
Used to get position/transform data for an entity (used also to derive deterministic pseudo-randomness when needed). -
public ComponentLookup<Hidden> m_Hidden
Indicates whether an entity is hidden (e.g., editor containers, removed, or temporaries). -
public ComponentLookup<EffectData> m_EffectDatas
Lookup for effect metadata, including condition flags used when evaluating effect activation. -
public ComponentLookup<LightEffectData> m_LightEffectDatas
Lookup for light-specific effect prefabs to distinguish light effects from general effects. -
public ComponentLookup<Building> m_Buildings
Lookup for Building component data used when checking building-related conditions (operational, efficiency, etc.). -
public ComponentLookup<Signature> m_SignatureBuildings
Used to detect special signature buildings which may change effect behavior (e.g., renters). -
public ComponentLookup<Vehicle> m_Vehicles
Generic vehicle component lookup used as part of parked/vehicle-specific checks. -
public ComponentLookup<Car> m_Cars
Car-specific flags (emergency, signs, working, etc.) used by certain effect conditions. -
public ComponentLookup<Aircraft> m_Aircraft
Aircraft-specific flags (e.g., emergency) used to evaluate effect conditions. -
public ComponentLookup<Watercraft> m_Watercraft
Watercraft flags (for example lights off) used by lighting-related effect checks. -
public ComponentLookup<ParkedCar> m_ParkedCars
Detects parked cars used for the Parked effect condition. -
public ComponentLookup<ParkedTrain> m_ParkedTrains
Detects parked trains used for the Parked effect condition. -
public ComponentLookup<PrefabRef> m_Prefabs
Lookup to get prefab references for entities. -
public ComponentLookup<OnFire> m_OnFires
Detects entities/buildings that are on fire. -
public ComponentLookup<Game.Vehicles.FireEngine> m_FireEngines
Fire engine state lookup to check extinguishing state, etc. -
public ComponentLookup<Temp> m_Temps
Temporary/editor-only components used to handle editor containers and temporary placement entities. -
public ComponentLookup<Game.Vehicles.PublicTransport> m_PublicTransports
Public transport state checks (boarding, etc.). -
public ComponentLookup<Game.Vehicles.Taxi> m_Taxis
Taxi state checks (boarding, etc.). -
public ComponentLookup<Game.Vehicles.CargoTransport> m_CargoTransports
Cargo transport state checks (boarding, etc.). -
public ComponentLookup<Game.Vehicles.PersonalCar> m_PersonalCars
Personal car state checks (boarding, states). -
public ComponentLookup<Game.Buildings.ServiceUpgrade> m_ServiceUpgrades
Detects service upgrade entities to resolve real owners. -
public ComponentLookup<Extension> m_Extensions
Detects extension components and flags (e.g., extension disabled). -
public ComponentLookup<Game.Events.WeatherPhenomenon> m_WeatherPhenomenonData
Weather phenomenon data used for the Occurring effect condition and similar. -
public ComponentLookup<PseudoRandomSeed> m_PseudoRandomSeeds
Provides deterministic pseudo-random seeds per entity to evaluate probabilistic/flag conditions like Night or Cold. -
public ComponentLookup<Destroyed> m_Destroyeds
Destroyed component data used for collapsing/clearing checks. -
public ComponentLookup<EarlyDisasterWarningDuration> m_EarlyDisasterWarningDurations
Used to determine whether a disaster is currently in early-warning state for the Disaster condition. -
public ComponentLookup<Game.Buildings.WaterPumpingStation> m_WaterPumpingStations
Used when checking processing/production state for water pumping stations. -
public ComponentLookup<Game.Buildings.SewageOutlet> m_SewageOutlets
Used when checking processing state for sewage outlets. -
public ComponentLookup<Game.Buildings.WaterTower> m_WaterTowers
Used for checking water tower storage/processing state. -
public ComponentLookup<StreetLight> m_StreetLights
Used to test whether a street light is turned off for LightsOff condition. -
public ComponentLookup<Stopped> m_Stoppeds
Indicates stopped state (Stopped effect condition). -
public ComponentLookup<Composition> m_Composition
Used for net composition checks (e.g., Spillway). -
public ComponentLookup<NetCompositionData> m_NetCompositionData
Used with Composition to test net-related flags like Spillway. -
public ComponentLookup<Game.Buildings.ExtractorFacility> m_ExtractorData
Extractor facility data, used when resolving real owner/attached entities. -
public ComponentLookup<Attachment> m_AttachmentData
Attachment information used to resolve actual attached entity targets. -
public BufferLookup<TransformFrame> m_TransformFrames
Buffer lookup for transform frames which contain per-frame flags (TakingOff, Landing, Flying, MainLights, ExtraLights, WarningLights, WorkLights). -
public BufferLookup<Renter> m_Renter
Buffer lookup used to detect renters for signature buildings. -
public ComponentLookup<TrafficLights> m_TrafficLights
Traffic light components used when checking MoveableBridgeWorking condition, etc. -
public EffectFlagSystem.EffectFlagData m_EffectFlagData
Cached effect flag system data used when evaluating probabilistic flags (Night/Cold) via pseudo-random seeds. -
public uint m_SimulationFrame
Current simulation frame used for time-based checks (e.g., disaster early warning). -
public Entity m_Selected
Entity currently selected in the editor/tool context used by editor container logic.
Properties
- None (this struct exposes only public fields and methods; no C# properties).
Constructors
public EffectControlData(SystemBase system)
Initializes all ComponentLookup and BufferLookup fields as read-only using the provided SystemBase. It also initializes effect flag data to default, simulation frame to 0 and selected Entity to default. Use this in a SystemBase.OnCreate or similar to cache lookups once.
Methods
-
public void Update(SystemBase system, EffectFlagSystem.EffectFlagData effectFlagData, uint simulationFrame, Entity selected)
Refreshes all ComponentLookup/BufferLookup handles by calling Update(system) on each, and stores the current EffectFlagData, simulation frame and selected entity. Call at the start of a system update to ensure lookups are valid for the current Frame/Query. -
private bool CheckTrigger(Entity owner, Entity buildingOwner, Entity topOwner, EffectConditionFlags flag, bool forbidden)
Low-level evaluator that checks a single EffectConditionFlags bit (e.g., Operational, Parked, OnFire, Emergency, TakingOff, Landing, Flying, Stopped, Processing, Boarding, Disaster, Night, Cold, LightsOff, MainLights, ExtraLights, WarningLights, WorkLights, Spillway, Collapsing, MoveableBridgeWorking) for the given entities. Returns whether the condition is currently true for that flag. The 'forbidden' parameter inverts some per-frame buffer checks semantics (used when verifying that all frames have a flag vs any). -
private bool CheckTriggers(Entity owner, Entity buildingOwner, Entity topOwner, EffectCondition condition)
Iterates all flags present in an EffectCondition (required and forbidden) and uses CheckTrigger to determine whether the condition fails. Returns true when the effect should be prevented due to a mismatch (internal usage returns whether a trigger check forced disabling). -
private bool CheckConditions(Entity owner, Entity buildingOwner, Entity topOwner, Entity effect)
High-level check consulting the effect's EffectData flags. If the effect has EffectData, it evaluates triggers; returns true when effect conditions pass (i.e., effect can be enabled). If effect does not have EffectData, it returns true. -
private Random GetRandom(Entity owner)
Returns a deterministic Random for probabilistic evaluations: prefers entity's PseudoRandomSeed component, otherwise uses a hash of the entity position, otherwise falls back to the entity index. Used for Night/Cold and other random-enabled effect flags via the EffectFlagSystem. -
public bool ShouldBeEnabled(Entity owner, Entity prefab, bool checkEnabled, bool isEditorContainer)
Main public helper to decide whether a given prefab effect (prefab entity or light effect prefab) should be active for the provided owner entity. It handles editor-container/external-editor logic (hiding temporaries, selection, light vs non-light effects), hides disabled/hidden entities in editor mode, and optionally checks effect-specific enabled conditions by resolving the real owner and invoking CheckConditions. Returns true if the effect should be active. -
private Entity GetRealOwner(Entity owner, out Entity buildingOwner)
Resolves the "real" owner and the buildingOwner for special cases: temporary entities (Temp), service upgrades, extractor/attached entities. This normalization allows effect condition checks to operate on the correct entity (e.g., the parent building or original entity).
Usage Example
// Example usage from within a SystemBase-derived system:
public partial class MyEffectSystem : SystemBase
{
private EffectControlData m_EffectControl;
protected override void OnCreate()
{
base.OnCreate();
m_EffectControl = new EffectControlData(this);
}
protected override void OnUpdate()
{
// refresh lookups and runtime state once per update
EffectFlagSystem.EffectFlagData flags = /* obtain from effect flag system */;
uint simFrame = (uint)Time.ElapsedFrames; // example source of simulation frame
Entity selected = /* obtain currently selected entity */;
m_EffectControl.Update(this, flags, simFrame, selected);
// Later, decide whether an effect prefab should be enabled for an owner entity:
Entity owner = /* some entity */;
Entity effectPrefab = /* effect prefab entity */;
bool checkEnabled = true;
bool isEditorContainer = false;
if (m_EffectControl.ShouldBeEnabled(owner, effectPrefab, checkEnabled, isEditorContainer))
{
// enable or spawn the effect for owner
}
}
}
Notes: - Construct EffectControlData once (e.g., OnCreate) and call Update each frame before using it. - ShouldBeEnabled combines editor/temporary rules, prefab type (light vs effect), and effect-specific condition flags to produce the final decision. - This struct is read-only oriented — all ComponentLookup/BufferLookup instances are obtained as read-only to be safe for parallel reads in Jobs/Systems.