private void HandleTelefragged([NotNull] Actor actor, IEnumerable <Actor> telefragged, Pos2D oldPos, Pos2D newPos, int damage) { string hurtMessage; // Teleporting on top of another actor should always cause damage to that actor and swap it to your old location foreach (var target in telefragged) { hurtMessage = CombatManager.HurtObject(this, actor, target, damage, "scrambles", DamageType.Normal); if (actor.IsPlayer || target.IsPlayer || CanPlayerSee(newPos)) { AddMessage(hurtMessage, ClientMessageType.Generic); } Level.MoveObject(target, oldPos); } // If any collisions occurred, also hurt the actor who triggered it hurtMessage = CombatManager.HurtObject(this, actor, actor, damage, "scrambles", DamageType.Normal); if (actor.IsPlayer || Player.CanSee(newPos)) { AddMessage(hurtMessage, ClientMessageType.Generic); } }
private void HandleFailedTeleport([NotNull] Actor actor, Pos2D pos, int damage) { if (actor.IsPlayer || CanPlayerSee(pos)) { AddMessage($"{actor.Name} tries to teleport but is blocked, causing {damage} scramble damage.", ClientMessageType.Failure); } CombatManager.HurtObject(this, actor, actor, damage, "scrambles", DamageType.Normal); }
public GameContext([NotNull] LevelData level, [NotNull] GameService gameService, [NotNull] CombatManager combatManager, [NotNull] LootProvider lootProvider, [NotNull] IRandomization randomizer) { GameService = gameService ?? throw new ArgumentNullException(nameof(gameService)); CombatManager = combatManager ?? throw new ArgumentNullException(nameof(combatManager)); LootProvider = lootProvider ?? throw new ArgumentNullException(nameof(lootProvider)); Randomizer = randomizer ?? throw new ArgumentNullException(nameof(randomizer)); _messages = new List <GameMessage>(); AI = new ArtificialIntelligenceService(this); SetLevel(level); }