Game.Events.LightningStrike
Assembly:
Assembly-CSharp (typical for user code / mods)
Namespace: Game.Events
Type: struct
Base: System.ValueType
Summary:
LightningStrike is a simple plain-old-data (POD) struct used to represent a lightning impact event: where the strike occurred (position) and which entity was hit (if any). It contains only public fields and no methods or ECS interfaces in this declaration, so it can be used as lightweight event data passed between systems or stored in native containers. Note: as declared it does not implement Unity.Entities.IComponentData or IBufferElementData — wrap or adapt it if you need to attach it directly to entities or buffers.
Fields
-
public Unity.Entities.Entity m_HitEntity
Represents the entity that was hit by the lightning strike. If no entity was hit, this is typically Entity.Null. Use this to identify the target entity for damage, effects, or other reactions. -
public Unity.Mathematics.float3 m_Position
World-space position of the lightning strike. Uses Unity.Mathematics.float3 for efficiency and compatibility with Burst and jobified code.
Properties
- (none)
This struct exposes only public fields. If you need property semantics or encapsulation, wrap it in another type or convert to a component type.
Constructors
public LightningStrike()
(implicit default)
As a value-type, LightningStrike has an implicit parameterless constructor that zero-initializes fields. You may typically create instances with object-initializer syntax: var s = new LightningStrike { m_HitEntity = someEntity, m_Position = pos };
Methods
- (none)
No methods are defined on this struct. Processing and behavior should be implemented in systems or helper classes.
Usage Example
// Example: creating and passing a LightningStrike event into an event handler or system method.
// Note: LightningStrike as declared is a plain struct. To attach to an Entity or a DynamicBuffer,
// implement IComponentData or IBufferElementData (or wrap it) as needed.
using Unity.Entities;
using Unity.Mathematics;
using Game.Events;
public static class LightningEventHelper
{
public static void RaiseLightning(Entity hitEntity, float3 position)
{
var evt = new LightningStrike
{
m_HitEntity = hitEntity,
m_Position = position
};
// Example usages:
// 1) Pass to a manager/event bus method that processes strikes:
LightningSystem.ProcessStrike(evt);
// 2) Store in a native collection (NativeList/NativeArray) for batched processing:
// NativeList<LightningStrike> strikes = ...; strikes.Add(evt);
// 3) If you want to attach it to an Entity as a component, create a wrapper that implements IComponentData:
// EntityManager.AddComponentData(eventEntity, new LightningStrikeComponent { Value = evt });
}
}
{{ This struct is intentionally minimal to keep event payloads compact and allocation-free. For ECS workflow integration, prefer implementing or wrapping it as an IComponentData/IBufferElementData when you need to store it on entities or use Jobs/Burst efficiently. }}