Defines a building data record FBuilding that implements IObj and a Scene entity ObjectBuilding deriving from Obj. FBuilding holds identity, owner, position, combat and production fields. ObjectBuilding exposes engine-mapped properties for what units it can build, production cost, and view range, shows health on start, and has a virtual OnBuildDone hook.
using Forp.Game;
using Forp.Object.Unit;
using Sandbox;
using System;
using static Sandbox.VideoWriter;
namespace Forp.Object.Building;
public record FBuilding : IObj
{
public string ObjectId { get; set; }
public string Name { get; set; }
public Transform Transform { get; set; }
public Guid OwnerGuid { get; set; }
public int TurnsAlive { get; set; }
public int ViewRange { get; set; }
public int Health { get; set; }
public int Attack { get; set; }
public Hex Hex { get; set; }
public FUpgrade Upgrade { get; set; }
public int ProductionToBuild { get; set; } // TODO : remove me
}
public class ObjectBuilding : Obj
{
[Property] public List<GameObject> BuildableUnits { get; set; }
[Property] public int ProductionToBuild { get; set; }
[Property] public int ViewRange { get; set; }
protected virtual void OnBuildDone()
{
}
protected override void OnStart()
{
base.OnStart();
ShowHealth = true;
}
}