| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System.Collections.Generic;
- namespace MazeGen
- {
- public enum FightState
- {
- /// <summary>Declared, but not started yet - the join window is counting down.</summary>
- Mustering,
- /// <summary>Outcome is decided; if it's being watched, playback is still running.</summary>
- Resolving,
- Resolved,
- /// <summary>Never happened (every participant left/died, or the monsters were already dead).</summary>
- Cancelled
- }
- /// <summary>Whether a fight's outcome is just logged, or played out on the arena grid.</summary>
- public enum CombatViewMode
- {
- Simulate,
- Watch
- }
- /// <summary>
- /// A fight that has been declared in a room but hasn't started yet. The join window is the
- /// whole point of this type existing: an agent that picks a fight doesn't fight immediately,
- /// it commits and then waits, and during that wait other agents can walk in and pile on
- /// (improving the odds) or try to sneak past.
- /// </summary>
- public class PendingFight
- {
- public readonly int Id;
- public readonly Room Room;
- public readonly MonsterEncounter Encounter;
- /// <summary>Agents committed to this fight, in join order. The first is whoever started it.</summary>
- public readonly List<MazeAgent> Agents = new List<MazeAgent>();
- /// <summary>Seconds of join window left. Ticks on SimulationClock time, so pausing freezes it.</summary>
- public float JoinTimeRemaining;
- public FightState State = FightState.Mustering;
- /// <summary>Why this fight started, for the log/HUD.</summary>
- public string Trigger;
- /// <summary>Null until resolution.</summary>
- public BattleResult Result;
- /// <summary>How this fight was (or will be) resolved.</summary>
- public CombatViewMode ResolvedAs;
- /// <summary>
- /// The observer's choice of Watch/Log for when the join window naturally expires. Setting
- /// this (via CombatDirector.PreferWatch/PreferSimulate) is only a preference, not a trigger -
- /// the join window always has to run out on its own first; see CombatDirector.Update.
- /// Null means "use the director's default timeout resolution".
- /// </summary>
- public CombatViewMode? PreferredResolution;
- public PendingFight(int id, Room room, MonsterEncounter encounter)
- {
- Id = id;
- Room = room;
- Encounter = encounter;
- }
- public bool Contains(MazeAgent agent) => agent != null && Agents.Contains(agent);
- public string Describe() => $"Fight #{Id} in room {Room.Id}: {Agents.Count} agent(s) vs {Encounter.AliveMonsterCount} monster(s)";
- }
- }
|