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] });
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 37310523fb4035f4b96ce9b3d32af1f3

View File

@@ -0,0 +1,44 @@
using Unity.Entities;
using UnityEngine;
using EE2Clone.Components;
using EE2Clone.Core;
namespace EE2Clone.Authoring
{
public class PlayerStateAuthoring : MonoBehaviour
{
public int StartingFood = 200;
public int StartingWood = 200;
public int StartingStone = 100;
public int StartingGold = 100;
public class Baker : Baker<PlayerStateAuthoring>
{
public override void Bake(PlayerStateAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new PlayerStateComponent
{
PlayerId = 0,
CurrentEpoch = Epoch.StoneAge,
PopulationCurrent = 0,
PopulationMax = GameConstants.StartingPopulationCap,
CivilizationId = 0,
IsAlive = true
});
AddComponent(entity, new PlayerResourcesComponent
{
Food = authoring.StartingFood,
Wood = authoring.StartingWood,
Stone = authoring.StartingStone,
Gold = authoring.StartingGold,
Tin = 0
});
AddBuffer<PlayerTechBufferElement>(entity);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78cb57b57a35e8e44951d464cc24dfab

View File

@@ -0,0 +1,28 @@
using Unity.Entities;
using UnityEngine;
using EE2Clone.Components;
namespace EE2Clone.Authoring
{
public class ProjectileAuthoring : MonoBehaviour
{
public float Speed = 20f;
public class Baker : Baker<ProjectileAuthoring>
{
public override void Bake(ProjectileAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new ProjectileTag());
AddComponent(entity, new ProjectileData
{
Target = Entity.Null,
Damage = 0,
Speed = authoring.Speed,
OwnerPlayerId = 0
});
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e6647a589e575c94788124df33f6dffd

View File

@@ -0,0 +1,28 @@
using Unity.Entities;
using UnityEngine;
using EE2Clone.Components;
using EE2Clone.Core;
namespace EE2Clone.Authoring
{
public class ResourceNodeAuthoring : MonoBehaviour
{
public ResourceType ResourceType = ResourceType.Food;
public int StartingAmount = 500;
public class Baker : Baker<ResourceNodeAuthoring>
{
public override void Bake(ResourceNodeAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new ResourceNodeTag());
AddComponent(entity, new ResourceNode
{
Type = authoring.ResourceType,
RemainingAmount = authoring.StartingAmount
});
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0c7d47019d3edcc44b3e904abfe37c5c

View File

@@ -0,0 +1,72 @@
using Unity.Entities;
using UnityEngine;
using EE2Clone.Components;
using EE2Clone.Core;
using EE2Clone.Data;
namespace EE2Clone.Authoring
{
public class UnitAuthoring : MonoBehaviour
{
public UnitDataSO UnitData;
public class Baker : Baker<UnitAuthoring>
{
public override void Bake(UnitAuthoring authoring)
{
var data = authoring.UnitData;
if (data == null) return;
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new UnitTag());
AddComponent(entity, new Health { Current = data.MaxHealth, Max = data.MaxHealth });
AddComponent(entity, new OwnerPlayer { PlayerId = 0 });
AddComponent(entity, new MovementSpeed { Value = data.MoveSpeed });
AddComponent(entity, new MoveTarget { Position = default, IsActive = false });
AddComponent(entity, new AttackData
{
Damage = data.AttackDamage,
Range = data.AttackRange,
AttackCooldown = data.AttackCooldown,
CooldownRemaining = 0
});
AddComponent(entity, new ArmorData { Value = data.Armor });
AddComponent(entity, new UnitClassComponent { Value = data.UnitClass });
AddComponent(entity, new UnitStateComponent { Value = UnitState.Idle });
AddComponent(entity, new LineOfSight { Range = data.LineOfSightRange });
AddComponent(entity, new EpochLevel { Value = data.RequiredEpoch });
AddComponent(entity, new CombatTarget { Target = Entity.Null });
// Counter bonuses
var counterBuffer = AddBuffer<CounterBonusElement>(entity);
if (data.CounterBonuses != null)
{
foreach (var bonus in data.CounterBonuses)
{
counterBuffer.Add(new CounterBonusElement
{
TargetClass = bonus.TargetClass,
Multiplier = bonus.Multiplier
});
}
}
// Citizen-specific components
if (data.UnitClass == UnitClass.Citizen)
{
AddComponent(entity, new CitizenTag());
AddComponent(entity, new CitizenStateComponent { Value = CitizenState.Idle });
AddComponent(entity, new CarriedResource
{
Type = ResourceType.Food,
Amount = 0,
MaxCarryCapacity = data.MaxCarryCapacity
});
AddComponent(entity, new GatherTarget { Target = Entity.Null });
AddComponent(entity, new BuildTarget { Target = Entity.Null });
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1bbeae99680553f46b1d3fd5c27d6342