Adding Match State controller

This commit is contained in:
Matt F 2026-05-12 10:31:23 -07:00
parent c100db52e5
commit abcefcd7f1
13 changed files with 445 additions and 99 deletions

View file

@ -268,23 +268,13 @@ namespace TD.Gameplay
// ----- 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.
// Position is read live (NetworkTransform interpolation handles remote-client smoothing).
// Color comes from PlayerMatchState slot assignment.
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);
}
}
=> PlayerColors.Get(PlayerMatchState.SlotForClient(OwnerClientId));
MinimapIconKind IMinimapEntity.IconKind => MinimapIconKind.Builder;
@ -305,12 +295,7 @@ namespace TD.Gameplay
private void ApplyOwnerColor()
{
// Owner color comes from the slot mapping. Same stub mapping as elsewhere —
// replaced when MatchState lands.
byte slotByte = (byte)(OwnerClientId + 1);
PlayerSlot slot = (slotByte >= 1 && slotByte <= 9) ? (PlayerSlot)slotByte : PlayerSlot.None;
Color c = PlayerColors.Get(slot);
Color c = PlayerColors.Get(PlayerMatchState.SlotForClient(OwnerClientId));
c.a = 1f;
colorPropertyBlock ??= new MaterialPropertyBlock();
@ -560,12 +545,7 @@ namespace TD.Gameplay
return;
}
// Owner slot: same stub mapping as elsewhere.
byte slotByte = (byte)(OwnerClientId + 1);
PlayerSlot owner = (slotByte >= 1 && slotByte <= 9)
? (PlayerSlot)slotByte
: PlayerSlot.None;
PlayerSlot owner = PlayerMatchState.SlotForClient(OwnerClientId);
visual.InitializeServer(def, owner, job.Anchor, job.TowerTypeId, job.GoldSpent);
var netObj = go.GetComponent<NetworkObject>();
@ -1078,12 +1058,7 @@ namespace TD.Gameplay
// ----- Helpers ----------------------------------------------------
private static PlayerSlot OwnerToSlot(ulong clientId)
{
// STUB — replaced when MatchState lands. Same mapping as elsewhere.
byte slotByte = (byte)(clientId + 1);
if (slotByte < 1 || slotByte > 9) return PlayerSlot.None;
return (PlayerSlot)slotByte;
}
=> PlayerMatchState.SlotForClient(clientId);
private static Vector2Int ResolveFootprint(int towerTypeId)
{