Game.Buildings.RescueTarget
Assembly: Game
Namespace: Game.Buildings
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, ISerializable
Summary: {{ A lightweight ECS component used to mark an entity as a "rescue target" by holding a reference to a requesting entity. Typically used by building/vehicle systems to track which entity requested rescue (for example, a citizen entity that needs evacuation). Implements ISerializable so the contained Entity reference can be saved/loaded by the game's serialization system. As an IQueryTypeParameter it can be used in query definitions for ECS systems. }}
Fields
-
public Entity m_Request
{{ The Entity that represents the requester for rescue (for example, a citizen or a unit that asked for rescue). This is an Entity reference stored directly in the component. When serializing/saving, this field is read/written by the provided Serialize/Deserialize methods. Note: Entity references may need remapping on load; rely on the game's serialization remapping logic that consumes ISerializable. }} -
private
fields: none
Properties
- None
{{ This struct exposes no C# properties. Access the contained Entity via the public field m_Request. }}
Constructors
public RescueTarget(Entity request)
{{ Initializes a RescueTarget that points to the provided request Entity. Use this constructor when creating and adding the component to an entity (for example, when a building/vehicle begins a rescue operation). Example: new RescueTarget(requestEntity) }}
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
{{ Writes the contained Entity (m_Request) to the provided writer. This allows the save/load system to persist the reference. The writer implementation is provided by the game's serialization infrastructure. }} -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
{{ Reads back the Entity reference into m_Request from the provided reader. The reader implementation is provided by the game's serialization infrastructure and will typically handle remapping of entity IDs to the current runtime. }}
Usage Example
// Add a RescueTarget component to an entity (e.g., a building or vehicle entity)
Entity requester = /* an entity that requested rescue (e.g., a citizen entity) */;
Entity targetEntity = /* the entity to which we attach the RescueTarget component */;
var rescue = new RescueTarget(requester);
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(targetEntity, rescue);
// Later, a system can query for components and read rescue.m_Request to act on the requester.
{{ Notes: - Because this stores an Entity reference, ensure your systems handle the case where the referenced entity may have been destroyed. - Serialization uses the ISerializable methods implemented here; the game's save/load pipeline is responsible for proper entity remapping on load. - This struct is intentionally minimal and value-type friendly for efficient ECS usage. }}