Skip to content

Game.Prefabs.MilestonePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Represents a prefab used to configure milestone data for the ECS world. Instances of this prefab serialize milestone configuration (index, rewards, dev tree points, map tiles, loan limits, XP requirement, major flag, image and colors) and, when Initialize is called, write a MilestoneData component onto the provided Entity using those serialized values. This prefab is intended to be authored in the Unity inspector and used by the game's prefab-to-ECS conversion/initialization flow.


Fields

  • public int m_Index
    Index/ID of the milestone.

  • public int m_Reward
    Monetary or other reward value associated with the milestone.

  • public int m_DevTreePoints
    Developer tree points granted by the milestone.

  • public int m_MapTiles
    Number of map tiles unlocked by the milestone.

  • public int m_LoanLimit
    Loan limit increment provided by the milestone.

  • public int m_XpRequried
    XP required to reach this milestone (note: spelled "m_XpRequried" in code).

  • public bool m_Major
    Flag indicating whether this milestone is a major milestone.

  • public string m_Image
    Path/identifier for the milestone image (can be null/empty if not set).

  • public Color m_BackgroundColor = new Color(0f, 0f, 0f, 0f)
    Background color for the milestone UI. Default is transparent black.

  • public Color m_AccentColor = new Color(0.18f, 0.235f, 0.337f, 1f)
    Accent color used in milestone UI. Default is a dark bluish tint.

  • public Color m_TextColor = Color.white
    Text color used in milestone UI. Default is white.

Properties

  • This class exposes no public properties.

Constructors

  • public MilestonePrefab()
    Default constructor (implicit). Prefab instances are typically created and populated by Unity via the inspector/serialization system.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Collects components that should be associated with the prefab. This override calls base and then adds ComponentType.ReadWrite<MilestoneData>() so entities created from this prefab include the MilestoneData component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Override present but only calls base. No additional archetype component types are added here beyond what PrefabBase provides.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called to initialize a newly created entity from the prefab. This implementation writes a MilestoneData struct to the entity using the prefab's serialized field values:

  • m_Index -> MilestoneData.m_Index
  • m_Reward -> MilestoneData.m_Reward
  • m_DevTreePoints -> MilestoneData.m_DevTreePoints
  • m_MapTiles -> MilestoneData.m_MapTiles
  • m_LoanLimit -> MilestoneData.m_LoanLimit
  • m_XpRequried -> MilestoneData.m_XpRequried
  • m_Major -> MilestoneData.m_Major Note: visual fields such as m_Image and the Color fields are not written to MilestoneData here — they are likely used by other systems (UI, texture loading) outside this Initialize method.

Usage Example

// Prefabs are typically authored in the inspector. When the game creates an Entity from this prefab,
// Initialize will be invoked automatically and MilestoneData will be written onto the entity.
// Example: reading back the component after initialization

var milestoneData = entityManager.GetComponentData<MilestoneData>(entity);
Debug.Log($"Milestone {milestoneData.m_Index}: reward={milestoneData.m_Reward}, xpReq={milestoneData.m_XpRequried}");

// If you need to customize initialization, you can override Initialize in a subclass:
public class CustomMilestonePrefab : MilestonePrefab
{
    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);
        // e.g. adjust reward based on some runtime condition
        var data = entityManager.GetComponentData<MilestoneData>(entity);
        data.m_Reward += 100; // bump reward
        entityManager.SetComponentData(entity, data);
    }
}