grant enemy abilities in debug console
This commit is contained in:
parent
749c9203de
commit
dc9184075b
4 changed files with 347 additions and 178 deletions
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using TD.Gameplay.Draft;
|
||||
using TD.Gameplay.EnemyUpgrades;
|
||||
using TD.Gameplay.Waves;
|
||||
|
||||
namespace TD.Dev
|
||||
{
|
||||
|
|
@ -74,5 +76,42 @@ namespace TD.Dev
|
|||
Debug.LogWarning($"[DebugCommandRelay] '{option.DisplayName}' could not be applied " +
|
||||
$"to client {OwnerClientId}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force-apply the <see cref="EnemyUpgradeOption"/> at <paramref name="optionId"/> (its
|
||||
/// <see cref="EnemyUpgradePool"/> index) to the run's current wave slot — the same
|
||||
/// recording <c>WaveVote.ServerResolve</c> does for a vote winner, skipping the vote
|
||||
/// entirely. Not player-scoped: the effect lands on the run's current wave slot rather
|
||||
/// than the caller, so any connected client's relay can trigger it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Takes effect the next time this wave slot's enemies spawn, not retroactively on
|
||||
/// enemies already alive — see <see cref="EnemyUpgradeOption"/>'s remarks on why
|
||||
/// applying is "record on the slot," not a direct mutation.
|
||||
/// </remarks>
|
||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Owner)]
|
||||
public void DebugGrantEnemyUpgradeRpc(int optionId)
|
||||
{
|
||||
var pool = EnemyUpgradePool.Instance;
|
||||
var option = pool != null ? pool.Get(optionId) : null;
|
||||
if (option == null)
|
||||
{
|
||||
Debug.LogWarning($"[DebugCommandRelay] Grant requested for unknown enemy upgrade id {optionId}.");
|
||||
return;
|
||||
}
|
||||
|
||||
var run = RunState.Instance;
|
||||
if (run == null)
|
||||
{
|
||||
Debug.LogWarning("[DebugCommandRelay] No RunState in this scene.");
|
||||
return;
|
||||
}
|
||||
|
||||
int slot = run.CurrentUpgradeSlot;
|
||||
run.ServerAddUpgrade(slot, optionId);
|
||||
option.ServerOnApplied(run, slot);
|
||||
|
||||
Debug.Log($"[DebugCommandRelay] Granted '{option.DisplayName}' to wave slot {slot}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue