示例#1
0
        public void UpdateStatus()
        {
            if (CurrentHitPoints > MaxHitPoints)
            {
                CurrentHitPoints = MaxHitPoints;
            }
            if (CurrentHitPoints < 0)
            {
                CurrentHitPoints = 0;
            }
            if (CurrentShieldPoints > MaxShieldPoints)
            {
                CurrentShieldPoints = MaxShieldPoints;
            }
            if (CurrentShieldPoints < 0)
            {
                CurrentShieldPoints = 0;
            }

            if (this is Player player)
            {
                player.SendCommand(AttributeHitpointUpdateCommand.write(CurrentHitPoints, MaxHitPoints, CurrentNanoHull, MaxNanoHull));
                player.SendCommand(AttributeShieldUpdateCommand.write(player.CurrentShieldPoints, player.MaxShieldPoints));
                player.SendCommand(SetSpeedCommand.write(player.Speed, player.Speed));
                player.Group?.UpdateTarget(player, new List <command_i3O> {
                    new GroupPlayerInformationsModule(player.CurrentHitPoints, player.MaxHitPoints, player.CurrentShieldPoints, player.MaxShieldPoints, player.CurrentNanoHull, player.MaxNanoHull)
                });
            }
            else if (this is Pet pet)
            {
                var owner = pet.Owner;
                owner.SendCommand(PetHitpointsUpdateCommand.write(pet.CurrentHitPoints, pet.MaxHitPoints, false));
                owner.SendCommand(PetShieldUpdateCommand.write(pet.CurrentShieldPoints, pet.MaxShieldPoints));
            }

            foreach (var otherCharacter in Spacemap?.Characters.Values)
            {
                if (otherCharacter is Player otherPlayer && otherPlayer.Selected == this)
                {
                    if (this is Character character)
                    {
                        otherPlayer.SendCommand(ShipSelectionCommand.write(Id, character.Ship.Id, CurrentShieldPoints, MaxShieldPoints, CurrentHitPoints, MaxHitPoints, CurrentNanoHull, MaxNanoHull, (this is Player && (this as Player).SkillTree.shieldEngineering == 5)));
                    }
                    else if (this is Activatable activatable)
                    {
                        otherPlayer.SendCommand(AssetInfoCommand.write(
                                                    activatable.Id,
                                                    activatable.GetAssetType(),
                                                    activatable is Satellite ? (activatable as Satellite).DesignId : 0,
                                                    0,
                                                    activatable.CurrentHitPoints,
                                                    activatable.MaxHitPoints,
                                                    activatable.MaxShieldPoints > 0 ? true : false,
                                                    activatable.CurrentShieldPoints,
                                                    activatable.MaxShieldPoints
                                                    ));
                    }
                }
            }
        }
        public void UpdateStatus()
        {
            if (CurrentHitPoints > MaxHitPoints)
            {
                CurrentHitPoints = MaxHitPoints;
            }
            if (CurrentHitPoints < 0)
            {
                CurrentHitPoints = 0;
            }
            if (CurrentShieldPoints > MaxShieldPoints)
            {
                CurrentShieldPoints = MaxShieldPoints;
            }
            if (CurrentShieldPoints < 0)
            {
                CurrentShieldPoints = 0;
            }


            if (this is Player player)
            {
                player.SendCommand(HitpointInfoCommand.write(player.CurrentHitPoints, player.MaxHitPoints, player.CurrentNanoHull, player.MaxNanoHull));
                player.SendCommand(AttributeShieldUpdateCommand.write(player.CurrentShieldPoints, player.MaxShieldPoints));
                player.SendCommand(AttributeShipSpeedUpdateCommand.write(player.Speed));
            }

            if (this is Pet pet)
            {
                var gameSession = pet.Owner.GameSession;
                if (gameSession == null)
                {
                    return;
                }

                gameSession.Player.SendCommand(PetHitpointsUpdateCommand.write(pet.CurrentHitPoints, pet.MaxHitPoints, false));
                gameSession.Player.SendCommand(PetShieldUpdateCommand.write(pet.CurrentShieldPoints, pet.MaxShieldPoints));
            }

            foreach (var character in Spacemap.Characters.Values)
            {
                if (character is Player otherPlayer && (otherPlayer.Selected != null && otherPlayer.Selected == this))
                {
                    otherPlayer.SendCommand(ShipSelectionCommand.write(Id, Ship.Id, CurrentShieldPoints, MaxShieldPoints, CurrentHitPoints, MaxHitPoints, CurrentNanoHull, MaxNanoHull, false));
                }
            }
        }