Minimap!
This commit is contained in:
parent
f7720a9915
commit
6c37e569ab
18 changed files with 1169 additions and 323 deletions
|
|
@ -4,6 +4,7 @@ using Unity.Netcode;
|
|||
using UnityEngine;
|
||||
using TD.Core;
|
||||
using TD.Towers;
|
||||
using TD.UI.Minimap;
|
||||
|
||||
namespace TD.Gameplay
|
||||
{
|
||||
|
|
@ -45,7 +46,7 @@ namespace TD.Gameplay
|
|||
/// traversal.</para>
|
||||
/// </remarks>
|
||||
[RequireComponent(typeof(NetworkObject))]
|
||||
public class Builder : NetworkBehaviour
|
||||
public class Builder : NetworkBehaviour, IMinimapEntity
|
||||
{
|
||||
// ----- Static registry --------------------------------------------
|
||||
|
||||
|
|
@ -188,6 +189,7 @@ namespace TD.Gameplay
|
|||
public override void OnNetworkSpawn()
|
||||
{
|
||||
s_byClientId[OwnerClientId] = this;
|
||||
MinimapEntityRegistry.Register(this);
|
||||
|
||||
if (IsServer)
|
||||
{
|
||||
|
|
@ -217,6 +219,7 @@ namespace TD.Gameplay
|
|||
{
|
||||
if (s_byClientId.TryGetValue(OwnerClientId, out var registered) && registered == this)
|
||||
s_byClientId.Remove(OwnerClientId);
|
||||
MinimapEntityRegistry.Deregister(this);
|
||||
|
||||
// Server-only cleanup: despawn any remaining build-site visuals so they
|
||||
// don't leak when a player disconnects mid-construction.
|
||||
|
|
@ -233,6 +236,32 @@ namespace TD.Gameplay
|
|||
|
||||
// (NetworkList is owned by NGO; no manual Dispose needed in NGO 2.x.)
|
||||
|
||||
// ----- IMinimapEntity ---------------------------------------------
|
||||
//
|
||||
// Read every minimap refresh tick. Position is read live (NetworkTransform
|
||||
// interpolation handles remote-client smoothing). Color comes from the same
|
||||
// OwnerClientId → PlayerSlot stub mapping used by ApplyOwnerColor; both will pick
|
||||
// up the real mapping when MatchState lands.
|
||||
|
||||
Vector3 IMinimapEntity.WorldPosition => transform.position;
|
||||
|
||||
Color IMinimapEntity.MinimapColor
|
||||
{
|
||||
get
|
||||
{
|
||||
byte slotByte = (byte)(OwnerClientId + 1);
|
||||
PlayerSlot slot = (slotByte >= 1 && slotByte <= 9)
|
||||
? (PlayerSlot)slotByte : PlayerSlot.None;
|
||||
return PlayerColors.Get(slot);
|
||||
}
|
||||
}
|
||||
|
||||
MinimapIconKind IMinimapEntity.IconKind => MinimapIconKind.Builder;
|
||||
|
||||
// Diameter of the builder dot in world units. The view enforces a pixel-size floor so
|
||||
// builders remain visible at full zoom-out regardless of this value.
|
||||
float IMinimapEntity.MinimapWorldSize => 0.6f;
|
||||
|
||||
// ----- Owner color tinting ----------------------------------------
|
||||
|
||||
// Lazily allocated; reused across renderers. Construction in a field initializer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue