Core Game Loop Additions
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the baked <see cref="ResourceFieldSpawner"/> singleton (mirrors StorageSpawnerAuthoring).
|
||||
/// Place once in the gameplay subscene and assign the resource-node ghost prefab; ExpeditionFieldSystem
|
||||
/// scatters the field each Expedition. Carries no transform.
|
||||
/// </summary>
|
||||
public class ResourceFieldSpawnerAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Resource-node ghost prefab. Must carry ResourceNodeAuthoring + a GhostAuthoringComponent (ownerless, interpolated).")]
|
||||
public GameObject NodePrefab;
|
||||
|
||||
[Tooltip("Number of nodes per expedition.")]
|
||||
[Min(1)] public int Count = 8;
|
||||
|
||||
[Tooltip("Scatter radius (world units) around the expedition origin.")]
|
||||
[Min(1f)] public float Radius = 12f;
|
||||
|
||||
private class ResourceFieldSpawnerBaker : Baker<ResourceFieldSpawnerAuthoring>
|
||||
{
|
||||
public override void Bake(ResourceFieldSpawnerAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
||||
AddComponent(entity, new ResourceFieldSpawner
|
||||
{
|
||||
Prefab = authoring.NodePrefab != null
|
||||
? GetEntity(authoring.NodePrefab, TransformUsageFlags.Dynamic)
|
||||
: Entity.Null,
|
||||
Count = authoring.Count,
|
||||
Radius = authoring.Radius,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9e840f8b95266140b0ac5bd4e81391b
|
||||
@@ -0,0 +1,45 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for a resource-node ghost prefab (ownerless interpolated — duplicate from UpgradePickup.prefab
|
||||
/// so the GhostAuthoringComponent comes free). Bakes <see cref="ResourceNode"/> + <see cref="HitRadius"/>
|
||||
/// (reused for the harvest hit test) + <see cref="RegionTag"/>{Expedition} so GhostRelevancy scopes the node
|
||||
/// to expedition players. The field spawner overrides ResourceId (round-robin) and Position per instance.
|
||||
/// </summary>
|
||||
public class ResourceNodeAuthoring : MonoBehaviour
|
||||
{
|
||||
public enum ResourceKind : byte { Aether = 1, Ore = 2, Biomass = 3 }
|
||||
|
||||
[Tooltip("Default resource type (the spawner round-robins this per node).")]
|
||||
public ResourceKind Kind = ResourceKind.Aether;
|
||||
|
||||
[Tooltip("Total resource units in the node before it depletes.")]
|
||||
[Min(1)] public int Amount = 30;
|
||||
|
||||
[Tooltip("Units harvested per projectile hit.")]
|
||||
[Min(1f)] public float HarvestPerHit = 5f;
|
||||
|
||||
[Tooltip("Hit radius (world units) for the harvest sweep.")]
|
||||
[Min(0f)] public float HitRadius = 1.2f;
|
||||
|
||||
private class ResourceNodeBaker : Baker<ResourceNodeAuthoring>
|
||||
{
|
||||
public override void Bake(ResourceNodeAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new ResourceNode
|
||||
{
|
||||
ResourceId = (byte)authoring.Kind,
|
||||
Remaining = authoring.Amount,
|
||||
HarvestPerHit = authoring.HarvestPerHit,
|
||||
});
|
||||
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
||||
AddComponent(entity, new RegionTag { Region = RegionId.Expedition });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 174563c586d9a0f4bb84cca191f4a1f0
|
||||
Reference in New Issue
Block a user