예제 #1
0
        private static void ServerNotifyFactionAllies(
            ILogicObject faction,
            ILogicObject area,
            ILogicObject areasGroup)
        {
            var allyFactions = Faction.GetPrivateState(faction)
                               .FactionDiplomacyStatuses
                               .Where(p => p.Value == FactionDiplomacyStatus.Ally)
                               .Select(p => FactionSystem.ServerGetFactionByClanTag(p.Key))
                               .ToArray();

            if (allyFactions.Length == 0)
            {
                return;
            }

            var charactersToNotify = allyFactions.SelectMany(FactionSystem.ServerGetFactionMembersReadOnly)
                                     .ToArray();

            var playerCharactersToNotify = new List <ICharacter>();

            foreach (var memberEntry in charactersToNotify)
            {
                var character = Server.Characters.GetPlayerCharacter(memberEntry.Name);
                if (character is not null &&
                    !LandClaimSystem.ServerIsOwnedArea(area, character, requireFactionPermission: false))
                {
                    playerCharactersToNotify.Add(character);
                }
            }

            if (playerCharactersToNotify.Count == 0)
            {
                return;
            }

            var clanTag = FactionSystem.SharedGetClanTag(faction);
            var mark    = new ServerAllyBaseUnderRaidMark(areasGroup, factionMemberName: null, clanTag);

            ServerNotifiedCharactersForAreasGroups[mark] = playerCharactersToNotify;

            var mapPosition = LandClaimSystem.SharedGetLandClaimGroupCenterPosition(areasGroup);

            Instance.CallClient(playerCharactersToNotify,
                                _ => _.ClientRemote_AllyBaseUnderRaid(
                                    areasGroup.Id,
                                    mark.FactionMemberName,
                                    mark.ClanTag,
                                    mapPosition));
        }
예제 #2
0
        private static void ServerRaidBlockStartedOrExtendedHandler(
            ILogicObject area,
            ICharacter raiderCharacter,
            bool isNewRaidBlock,
            bool isStructureDestroyed)
        {
            if (!isNewRaidBlock)
            {
                return;
            }

            var areasGroup = LandClaimSystem.SharedGetLandClaimAreasGroup(area);

            if (ServerNotifiedCharactersForAreasGroups.ContainsKey(
                    ServerAllyBaseUnderRaidMark.CreateKeyOnly(areasGroup)))
            {
                // notification for this areas group is already sent
                return;
            }

            ILogicObject faction;
            var          clanTag = LandClaimSystem.SharedGetAreaOwnerFactionClanTag(area);

            if (!string.IsNullOrEmpty(clanTag))
            {
                // owned by a faction, notify allies
                faction = FactionSystem.ServerGetFactionByClanTag(clanTag);
                ServerNotifyFactionAllies(faction, area, areasGroup);
                return;
            }

            // not owned by faction,
            // check whether its founder is a member of any faction and notify its members
            var founderName = LandClaimArea.GetPrivateState(area)
                              .LandClaimFounder;
            var founderCharacter = Server.Characters.GetPlayerCharacter(founderName);

            if (founderCharacter is null)
            {
                return;
            }

            faction = FactionSystem.ServerGetFaction(founderCharacter);
            if (faction is not null)
            {
                ServerNotifyFactionMembers(faction, founderCharacter, area, areasGroup);
            }
        }
예제 #3
0
        private static void ServerNotifyFactionMembers(
            ILogicObject faction,
            ICharacter founderCharacter,
            ILogicObject area,
            ILogicObject areasGroup)
        {
            var charactersToNotify = FactionSystem.ServerGetFactionMembersReadOnly(faction);

            var playerCharactersToNotify = new List <ICharacter>();

            foreach (var memberEntry in charactersToNotify)
            {
                var character = Server.Characters.GetPlayerCharacter(memberEntry.Name);
                if (character is not null &&
                    !LandClaimSystem.ServerIsOwnedArea(area, character, requireFactionPermission: false))
                {
                    playerCharactersToNotify.Add(character);
                }
            }

            if (playerCharactersToNotify.Count == 0)
            {
                return;
            }

            var founderCharacterName = founderCharacter.Name;
            var mark = new ServerAllyBaseUnderRaidMark(areasGroup, founderCharacterName, clanTag: null);

            ServerNotifiedCharactersForAreasGroups[mark] = playerCharactersToNotify;

            var mapPosition = LandClaimSystem.SharedGetLandClaimGroupCenterPosition(areasGroup);

            Instance.CallClient(playerCharactersToNotify,
                                _ => _.ClientRemote_AllyBaseUnderRaid(
                                    areasGroup.Id,
                                    mark.FactionMemberName,
                                    mark.ClanTag,
                                    mapPosition));
        }