Core Game Loop Additions
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c81ee1ba775463a4d940bb397a01f4e6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b2e77367c16a9a41943145e582954d1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the GLOBAL cycle-director ghost prefab: an ownerless INTERPOLATED ghost (the
|
||||
/// GhostAuthoringComponent is inherited when this prefab is duplicated from UpgradePickup.prefab) that
|
||||
/// carries the replicated macro-loop state (<see cref="CycleState"/>) and the shared resource ledger
|
||||
/// (a <see cref="StorageEntry"/> buffer marked by <see cref="ResourceLedger"/>). It is GLOBAL — it must
|
||||
/// carry NO <see cref="RegionTag"/> so GhostRelevancy keeps it relevant to every connection regardless of
|
||||
/// region. The server CycleDirectorSpawnSystem overrides the baked CycleState at spawn (real PhaseEndTick)
|
||||
/// and adds the server-only CycleRuntime.
|
||||
/// </summary>
|
||||
public class CycleDirectorAuthoring : MonoBehaviour
|
||||
{
|
||||
private class CycleDirectorBaker : Baker<CycleDirectorAuthoring>
|
||||
{
|
||||
public override void Bake(CycleDirectorAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new CycleState
|
||||
{
|
||||
Phase = CyclePhase.Expedition,
|
||||
CycleNumber = 1,
|
||||
PhaseEndTick = 0u,
|
||||
});
|
||||
AddComponent<ResourceLedger>(entity);
|
||||
AddBuffer<StorageEntry>(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 843fd0d567f48ad46840dcce0ce84bbc
|
||||
@@ -0,0 +1,31 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the baked <see cref="CycleDirectorSpawner"/> singleton (mirrors StorageSpawnerAuthoring).
|
||||
/// Place once in the gameplay subscene; the server-only CycleDirectorSpawnSystem reads it, instantiates the
|
||||
/// global cycle-director ghost, then destroys the singleton so it fires exactly once. Carries no transform.
|
||||
/// </summary>
|
||||
public class CycleDirectorSpawnerAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Cycle-director ghost prefab. Must carry CycleDirectorAuthoring + a GhostAuthoringComponent (ownerless, interpolated).")]
|
||||
public GameObject DirectorPrefab;
|
||||
|
||||
private class CycleDirectorSpawnerBaker : Baker<CycleDirectorSpawnerAuthoring>
|
||||
{
|
||||
public override void Bake(CycleDirectorSpawnerAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
||||
AddComponent(entity, new CycleDirectorSpawner
|
||||
{
|
||||
Prefab = authoring.DirectorPrefab != null
|
||||
? GetEntity(authoring.DirectorPrefab, TransformUsageFlags.Dynamic)
|
||||
: Entity.Null,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f4d2cb1e17d6a1429525674969dd3f0
|
||||
@@ -0,0 +1,45 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for a walk-in <see cref="ExpeditionGate"/>. Place on a visible gate object in the gameplay
|
||||
/// subscene; baked into both worlds at the gate's position (the server reads its LocalTransform for the
|
||||
/// overlap test, the client renders the mesh). Set From/To regions + the arrival point in the destination
|
||||
/// region (offset from that region's gate so the player doesn't immediately re-trigger).
|
||||
/// </summary>
|
||||
public class ExpeditionGateAuthoring : MonoBehaviour
|
||||
{
|
||||
public enum Region : byte { Base = 0, Expedition = 1 }
|
||||
|
||||
[Tooltip("Region a player must be in for this gate to act on them.")]
|
||||
public Region From = Region.Base;
|
||||
|
||||
[Tooltip("Region the player is transited to.")]
|
||||
public Region To = Region.Expedition;
|
||||
|
||||
[Min(0.5f)] public float Radius = 2.5f;
|
||||
|
||||
[Tooltip("Where the player arrives in the destination region (offset from that region's gate).")]
|
||||
public Vector3 ArrivalPos = new Vector3(1000f, 1f, 0f);
|
||||
|
||||
private class ExpeditionGateBaker : Baker<ExpeditionGateAuthoring>
|
||||
{
|
||||
public override void Bake(ExpeditionGateAuthoring authoring)
|
||||
{
|
||||
// Dynamic so the baked entity carries a LocalTransform the server can read for the overlap test.
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new ExpeditionGate
|
||||
{
|
||||
FromRegion = (byte)authoring.From,
|
||||
ToRegion = (byte)authoring.To,
|
||||
Radius = authoring.Radius,
|
||||
ArrivalPos = new float3(authoring.ArrivalPos.x, authoring.ArrivalPos.y, authoring.ArrivalPos.z),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22f744b59ad23834abe28fc09b661005
|
||||
Reference in New Issue
Block a user