Initial import

This commit is contained in:
ldbetteridge
2026-03-31 15:59:23 +01:00
commit 58da5d1d71
136 changed files with 10922 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
using Unity.Entities;
using UnityEngine;
using EE2Clone.Components;
using EE2Clone.Data;
namespace EE2Clone.Authoring
{
public class BuildingAuthoring : MonoBehaviour
{
public BuildingDataSO BuildingData;
public bool StartConstructed = false;
public class Baker : Baker<BuildingAuthoring>
{
public override void Bake(BuildingAuthoring authoring)
{
var data = authoring.BuildingData;
if (data == null) return;
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new BuildingTag());
AddComponent(entity, new Health
{
Current = authoring.StartConstructed ? data.MaxHealth : 1,
Max = data.MaxHealth
});
AddComponent(entity, new OwnerPlayer { PlayerId = 0 });
AddComponent(entity, new BuildingTypeComponent { Value = data.BuildingType });
AddComponent(entity, new LineOfSight { Range = data.LineOfSightRange });
AddComponent(entity, new EpochLevel { Value = data.RequiredEpoch });
if (!authoring.StartConstructed)
{
AddComponent(entity, new UnderConstructionTag());
AddComponent(entity, new ConstructionProgress
{
Progress = 0f,
BuildTime = data.BuildTime
});
}
if (data.TerritoryRadius > 0)
{
AddComponent(entity, new TerritorySource { Radius = data.TerritoryRadius });
}
if (data.ProvidesPopulation > 0)
{
AddComponent(entity, new ProvidesPopulation { Amount = data.ProvidesPopulation });
}
AddComponent(entity, new RallyPoint { Position = default });
// Production queue
AddBuffer<ProductionQueueElement>(entity);
AddBuffer<ResearchQueueElement>(entity);
// Dropoff
if (data.IsDropoff && data.AcceptedResourceTypes != null && data.AcceptedResourceTypes.Length > 0)
{
AddComponent(entity, new DropoffBuilding { AcceptedType = data.AcceptedResourceTypes[0] });
}
}
}
}
}