Skip to content

Game.Prefabs.DeliveryTruckSelectItem

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: public struct

Base: System.ValueType, System.IComparable

Summary:
Represents a selectable delivery-truck option used by the UI or selection systems. Contains the truck's capacity, cost, the resource type it transports, and up to four prefab Entity variants that can be instantiated in the game. Primarily intended to be used in collections and sorted by capacity.


Fields

  • public int m_Capacity
    Capacity of the delivery truck (used for sorting and display). Higher values indicate the truck can carry more goods.

  • public int m_Cost
    Cost associated with this truck option (in-game currency). Used for displaying purchase/upgrade cost or for economic calculations.

  • public Resource m_Resources
    Resource type the truck delivers or collects. Resource is defined in Game.Economy and indicates what commodity this truck handles (e.g., goods, waste, freight).

  • public Entity m_Prefab1

  • public Entity m_Prefab2
  • public Entity m_Prefab3
  • public Entity m_Prefab4
    Up to four Entity prefabs that represent visual/functional variants of this truck option. These are Unity.Entities.Entity references and may be used to instantiate the correct visual/model variant depending on game state (e.g., upgrades, color variants, different tiers).

Properties

  • This type does not declare any C# properties. It exposes public fields and implements IComparable via a method.

Constructors

  • public DeliveryTruckSelectItem()
    Structs in C# have an implicit parameterless constructor that initializes numeric fields to 0, enum/struct fields to their default values, and reference/value-type fields to their default (for Entity this will be the default Entity). There is no explicit constructor declared in the source.

Methods

  • public int CompareTo(DeliveryTruckSelectItem other)
    Compares this item to another DeliveryTruckSelectItem by m_Capacity. Returns a negative value if this capacity is less than the other's, zero if equal, and positive if greater. This allows sorting collections (e.g., List) by capacity in ascending order.

Usage Example

using System;
using System.Collections.Generic;
using Unity.Entities;
using Game.Prefabs;
using Game.Economy;

// Create some items
var a = new DeliveryTruckSelectItem
{
    m_Capacity = 100,
    m_Cost = 500,
    m_Resources = Resource.Goods,
    m_Prefab1 = Entity.Null
};

var b = new DeliveryTruckSelectItem
{
    m_Capacity = 200,
    m_Cost = 900,
    m_Resources = Resource.Goods,
    m_Prefab1 = Entity.Null
};

var list = new List<DeliveryTruckSelectItem> { b, a };

// Sort by capacity (uses CompareTo)
list.Sort();

// After sorting, list[0] is 'a' (capacity 100), list[1] is 'b' (capacity 200)