Game.PlaceableNetPieceData
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
A lightweight ECS component that holds cost-related data for a placeable network piece (for example a road/track segment, bridge ramp, or other placeable net prefab). This struct is intended to be attached to entities that represent placeable net pieces so systems can read construction, elevation and upkeep costs during placement, simulation and economy calculations. All fields are public and default to zero. The units for costs follow the game's economy conventions (currency units for construction/elevation, and a float for recurring upkeep); consult the game's economy/system documentation for exact time unit of upkeep.
Fields
-
public uint m_ConstructionCost
Upfront construction cost to place this net piece (unsigned integer, in game currency units). Typically applied once when the piece is built. -
public uint m_ElevationCost
Additional cost applied when this piece changes elevation (e.g., building ramps/bridges). Unsigned integer in game currency units. -
public float m_UpkeepCost
Recurring maintenance/upkeep cost for the piece (floating point). The exact time unit (per second, per simulation step, per in-game year, etc.) is determined by the game's economy/simulation systems.
Properties
- None. This is a plain data struct with public fields intended for fast ECS access.
Constructors
public PlaceableNetPieceData()
Default (implicit) parameterless constructor for the struct. All fields initialize to zero. Use object/collection initializers to create instances with specific values, e.g. new PlaceableNetPieceData { m_ConstructionCost = 100u, m_UpkeepCost = 1.5f }.
Methods
- None. This type contains only data fields and no instance methods.
Usage Example
// Example: create an entity for a placeable net piece and attach the cost data
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(GameObjectConversionSystem), typeof(Game.Prefabs.PlaceableNetPieceData));
// Create an entity and assign costs
Entity pieceEntity = entityManager.CreateEntity();
entityManager.AddComponentData(pieceEntity, new Game.Prefabs.PlaceableNetPieceData
{
m_ConstructionCost = 500u,
m_ElevationCost = 150u,
m_UpkeepCost = 2.5f
});
// Example: reading/updating in a SystemBase
public partial class NetPieceCostSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.ForEach((ref Game.Prefabs.PlaceableNetPieceData cost) =>
{
// Example usage: apply a modifier to upkeep
cost.m_UpkeepCost *= 1.05f;
}).ScheduleParallel();
}
}