Пример #1
0
        public bool CheckActivatables(Player Player)
        {
            bool isInSecureZone        = false;
            bool inEquipZone           = false;
            bool onBlockedMinePosition = false;

            foreach (var entity in Activatables.Values)
            {
                bool  inRange = Player.Position.DistanceTo(entity.Position) <= (entity is HomeStation ? HomeStation.SECURE_ZONE_RANGE : 700);
                short status  = inRange ? MapAssetActionAvailableCommand.ON : MapAssetActionAvailableCommand.OFF;

                if (inRange)
                {
                    if (!(entity is BattleStation) && !(entity is Satellite))
                    {
                        onBlockedMinePosition = true;
                    }

                    if (entity is HomeStation homeStation)
                    {
                        if (homeStation.FactionId == Player.FactionId)
                        {
                            if (!Player.LastAttackTime(5))
                            {
                                isInSecureZone = true;
                                inEquipZone    = true;
                            }
                        }
                    }
                    else if (entity is RepairStation)
                    {
                        if (Player.CurrentHitPoints == Player.MaxHitPoints || Player.FactionId != entity.FactionId)
                        {
                            inRange = false;
                        }
                    }
                }

                bool activateButton = Player.UpdateActivatable(entity, inRange);

                if (activateButton)
                {
                    if (entity is Portal portal && !portal.Working)
                    {
                        status = MapAssetActionAvailableCommand.OFF;
                    }

                    //TODO check old = if (entity is BattleStation battleStation && battleStation.Clan.Id != 0 && !battleStation.InBuildingState && battleStation.Clan.Id != Player.Clan.Id)

                    if (entity is BattleStation battleStation && battleStation.Clan.Id != 0 && battleStation.Clan.Id != Player.Clan.Id)
                    {
                        status = MapAssetActionAvailableCommand.OFF;
                    }

                    if (entity is BattleStation && status == MapAssetActionAvailableCommand.OFF)
                    {
                        //TODO: Find close ui command end send it
                    }

                    var portalTooltip = new List <ClientUITooltipModule>();
                    portalTooltip.Add(new ClientUITooltipModule(new ClientUITooltipTextFormatModule(ClientUITooltipTextFormatModule.LOCALIZED), ClientUITooltipModule.STANDARD, "q2_condition_JUMP", new List <ClientUITextReplacementModule>()));

                    var assetAction =
                        MapAssetActionAvailableCommand.write(entity.Id,
                                                             status,
                                                             inRange,
                                                             new ClientUITooltipsCommand(entity is Portal ? portalTooltip : new List <ClientUITooltipModule>()),
                                                             new class_h45()
                                                             );

                    Player.SendCommand(assetAction);
                }
            }

            if (Player.Storage.OnBlockedMinePosition != onBlockedMinePosition)
            {
                Player.Storage.OnBlockedMinePosition = onBlockedMinePosition;
            }

            if (Player.Storage.IsInEquipZone != inEquipZone)
            {
                Player.Storage.IsInEquipZone = inEquipZone;

                Player.SendCommand(EquipReadyCommand.write(Player.Storage.IsInEquipZone));

                var packet = Player.Storage.IsInEquipZone ? "0|A|STM|msg_equip_ready" : "0|A|STM|msg_equip_not_ready";
                Player.SendPacket(packet);
            }

            if (Player.Storage.IsInDemilitarizedZone != isInSecureZone)
            {
                Player.Storage.IsInDemilitarizedZone = isInSecureZone;
                return(true);
            }
            return(false);
        }
        private bool CheckActivatables(Player Player)
        {
            bool isInSecureZone = false;
            bool inEquipZone    = false;


            foreach (var station in Stations.Values)
            {
                if (station is HomeStation)
                {
                    var homeStation = (HomeStation)station;

                    if (Player.Position.DistanceTo(homeStation.Position) <= HomeStation.SECURE_ZONE_RANGE)
                    {
                        if (homeStation.FactionId == Player.FactionId)
                        {
                            if (!Player.LastAttackTime(3))
                            {
                                isInSecureZone = true;
                                inEquipZone    = true;
                            }
                        }
                    }
                }
            }

            foreach (var entity in Activatables.Values)
            {
                bool  inRange        = Player.Position.DistanceTo(entity.Position) <= 500;
                short status         = inRange ? MapAssetActionAvailableCommand.ON : MapAssetActionAvailableCommand.OFF;
                bool  activateButton = Player.UpdateActivatable(entity, inRange);

                if (activateButton)
                {
                    if (entity is Portal)
                    {
                        Player.SendPacket(Player.GetBeaconPacket());
                    }
                    else
                    {
                        var assetAction = MapAssetActionAvailableCommand.write(entity.Id, status);
                        Player.SendCommand(assetAction);
                    }
                }
            }

            if (Player.Settings.InGameSettings.inEquipZone != inEquipZone)
            {
                Player.Settings.InGameSettings.inEquipZone = inEquipZone;
                Player.SendCommand(EquipReadyCommand.write(inEquipZone));

                if (Player.Settings.InGameSettings.inEquipZone)
                {
                    Player.SendPacket("0|A|STM|msg_equip_ready");
                }
                else
                {
                    Player.SendPacket("0|A|STM|msg_equip_not_ready");
                }
            }

            QueryManager.SavePlayer.Settings(Player);

            if (Player.Storage.IsInDemilitarizedZone != isInSecureZone)
            {
                Player.Storage.IsInDemilitarizedZone = isInSecureZone;
                return(true);
            }
            return(false);
        }