Game.AnimalData
Assembly:
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Component data representing movement-related parameters for animal prefabs in the game's ECS. This struct is intended to be attached to entities representing animals and contains speeds, acceleration and bounds for swim depth and flight height. It implements IComponentData so it can be stored on Unity.Entities.Entity instances and IQueryTypeParameter so it can be used in query type parameters.
Fields
-
public float m_MoveSpeed
Maximum ground (walk/run) movement speed for the animal (units per second). Used by movement systems to determine horizontal locomotion speed. -
public float m_SwimSpeed
Movement speed used while the animal is swimming (units per second). Systems should switch to this value when the animal is in water. -
public float m_FlySpeed
Movement speed used while the animal is flying (units per second). Systems should use this for aerial movement. -
public float m_Acceleration
Acceleration value applied to change the animal's current velocity towards the target speed (units per second^2). Used by movement systems to smooth speed changes. -
public Bounds1 m_SwimDepth
Allowed swim depth range (min/max) for the animal. Bounds1 (from Colossal.Mathematics) typically encodes a single-dimensional range; movement or physics systems use this to determine whether the animal should swim or is out of its valid depth range. -
public Bounds1 m_FlyHeight
Allowed flight height range (min/max) for the animal. Systems use this to decide if the animal may or should be flying based on altitude.
Properties
- None.
All data is exposed as public fields on the struct. Because this is a plain IComponentData struct, there are no encapsulated properties.
Constructors
- None declared explicitly.
This is a value type (struct); it has the default parameterless constructor which will initialize numeric fields to 0 and Bounds1 to its default. Initialize fields explicitly when creating instances to meaningful values.
Methods
- None declared.
This component only holds data. Behavior should be implemented by ECS systems that read and write this component.
Usage Example
// Example: creating an AnimalData instance and assigning it to an entity.
// Replace Bounds1(min, max) with the correct constructor/signature if different.
var animalData = new Game.Prefabs.AnimalData
{
m_MoveSpeed = 4.5f,
m_SwimSpeed = 2.0f,
m_FlySpeed = 6.0f,
m_Acceleration = 3.0f,
m_SwimDepth = new Bounds1(0f, 2.5f),
m_FlyHeight = new Bounds1(1f, 12f)
};
// Using EntityManager to add/set the component on an entity (DOTS):
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(animalEntity, animalData);
Notes: - Because this is an ECS component, movement/animation/AI systems should read these fields to implement animal behavior. - Bounds1 is part of Colossal.Mathematics; check its API for constructors and semantics (min/max vs center/extent) before using literal values.