caelum0x 6172e21cfe feat: wire the MVP combat loop to the real PvP relay transport
Replaces the bots-only MVP scene with a real server-authoritative combat
loop driven over the relay transport shipped last round. MatchHostSimulator
validates deploys, spends elixir, spawns units, runs AutoUnitAI targeting
and attack resolution against real nearest-enemy selection, resolves
unit/tower damage, and drives the win-condition clock, broadcasting a
state_snapshot at 10Hz. MatchSnapshotRenderer applies those snapshots on
the guest without running a second simulation. MatchSimulationController
ties it to NetworkBootstrap's host/guest role and is the one entry point
(RequestLocalDeploy) the HUD needs for card placement.
2026-10-24 00:34:05 +03:00

38 lines
1.5 KiB
C#

using Siegebreak.Cards;
namespace Siegebreak.Units
{
/// <summary>
/// Identity tag attached to every troop/building GameObject the moment
/// it's spawned (host: Core/MatchHostSimulator on a validated deploy;
/// guest: Core/MatchSimulationController when a new unitId first shows
/// up in a state_snapshot). Carries exactly what both sides need to
/// agree an instance is "the same unit": a server-assigned id, which
/// card it came from (for stats + targeting rules), and whose side it's
/// on. Not a MonoBehaviour-with-logic on purpose — AutoUnitAI stays the
/// only thing driving movement/attack state so the guest can disable
/// just that component and keep this one as pure data.
/// </summary>
public class SpawnedUnit : UnityEngine.MonoBehaviour
{
public string UnitId { get; private set; }
public CardData Card { get; private set; }
public bool IsHostOwned { get; private set; }
public AutoUnitAI Ai { get; private set; }
public UnitHealth Health { get; private set; }
public void Initialize(string unitId, CardData card, bool isHostOwned)
{
UnitId = unitId;
Card = card;
IsHostOwned = isHostOwned;
Ai = GetComponent<AutoUnitAI>();
Health = GetComponent<UnitHealth>();
if (Health == null) Health = gameObject.AddComponent<UnitHealth>();
Health.Initialize(card != null ? card.hp : 1);
}
}
}