Пример #1
0
        public bool RemoveInRangeCharacter(Character character)
        {
            try
            {
                if (character.Spacemap != Spacemap || !InRangeCharacters.ContainsKey(character.Id))
                {
                    return(false);
                }

                var success = InRangeCharacters.TryRemove(character.Id, out character);
                if (success)
                {
                    InRangeCharacterRemoved?.Invoke(this, new CharacterArgs(character));

                    if (Selected == character)
                    {
                        Deselection();
                    }

                    if (this is Player player)
                    {
                        player.SendCommand(ShipRemoveCommand.write(character.Id));
                    }
                }
                return(success);
            }
            catch (Exception e)
            {
                Out.WriteLine("RemoveInRangeCharacter void exception " + e, "Character.cs");
                Logger.Log("error_log", $"- [Character.cs] RemoveInRangeCharacter void exception: {e}");
                return(false);
            }
        }
Пример #2
0
        public bool RemoveInRangeCharacter(Character character)
        {
            if (character.Spacemap != Spacemap || !IsInRangeCharacter(character))
            {
                return(false);
            }

            var success = InRangeCharacters.TryRemove(character.Id, out character);

            if (success)
            {
                InRangeCharacterRemoved?.Invoke(this, new CharacterArgs(character));

                if (this is Player player)
                {
                    if (Selected == character)
                    {
                        Selected = null;
                        player.DisableAttack(player.SettingsManager.SelectedLaser);
                    }
                    var shipRemoveCommand = ShipRemoveCommand.write(character.Id);
                    player.SendCommand(shipRemoveCommand);
                }
            }
            return(success);
        }