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,61 @@
using Unity.Entities;
using Unity.NetCode;
using EE2Clone.Core;
namespace EE2Clone.Components
{
[GhostComponent(PrefabType = GhostPrefabType.All)]
public struct PlayerStateComponent : IComponentData
{
[GhostField] public int PlayerId;
[GhostField] public Epoch CurrentEpoch;
[GhostField] public int PopulationCurrent;
[GhostField] public int PopulationMax;
[GhostField] public int CivilizationId;
[GhostField] public bool IsAlive;
}
[GhostComponent(PrefabType = GhostPrefabType.All)]
public struct PlayerResourcesComponent : IComponentData
{
[GhostField] public int Food;
[GhostField] public int Wood;
[GhostField] public int Stone;
[GhostField] public int Gold;
[GhostField] public int Tin;
public int GetResource(ResourceType type)
{
return type switch
{
ResourceType.Food => Food,
ResourceType.Wood => Wood,
ResourceType.Stone => Stone,
ResourceType.Gold => Gold,
ResourceType.Tin => Tin,
_ => 0
};
}
public void AddResource(ResourceType type, int amount)
{
switch (type)
{
case ResourceType.Food: Food += amount; break;
case ResourceType.Wood: Wood += amount; break;
case ResourceType.Stone: Stone += amount; break;
case ResourceType.Gold: Gold += amount; break;
case ResourceType.Tin: Tin += amount; break;
}
}
public bool TrySpend(ResourceType type, int amount)
{
if (GetResource(type) < amount)
return false;
AddResource(type, -amount);
return true;
}
}
}