Exemple #1
0
        private void RefreshContextForFactionMembers(ICharacter character)
        {
            if (!this.IsSharedWithPartyAndFactionMembers)
            {
                return;
            }

            var factionMembers = FactionSystem.ServerGetFactionMembersReadOnly(character);

            if (factionMembers.Count <= 1)
            {
                // no party or single-player party
                return;
            }

            var currentCharacterName = character.Name;

            foreach (var factionMemberEntry in factionMembers)
            {
                var factionMemberName = factionMemberEntry.Name;
                if (factionMemberName == currentCharacterName)
                {
                    continue;
                }

                var factionMember = Api.Server.Characters
                                    .GetPlayerCharacter(factionMemberName);

                if (factionMember is not null)
                {
                    var context = this.GetActiveContext(factionMember, out _);
                    context?.Refresh();
                }
            }
        }
Exemple #2
0
        public ViewModelWindowFactionLearningPointsDonation([NotNull] Action callbackCloseWindow)
        {
            this.callbackCloseWindow = callbackCloseWindow;

            var faction             = FactionSystem.ClientCurrentFaction;
            var factionPublicState  = Faction.GetPublicState(faction);
            var factionPrivateState = Faction.GetPrivateState(faction);

            this.toLevel = (byte)(factionPublicState.Level + 1);
            this.UpdateCostLearningPoints = FactionConstants.SharedGetFactionUpgradeCost(
                toLevel: this.toLevel);

            this.FactionAccumulatedLearningPointsForUpgrade = factionPrivateState.AccumulatedLearningPointsForUpgrade;

            this.LearningPointsToDonateMax
                = (ushort)Math.Max(0,
                                   this.UpdateCostLearningPoints
                                   - factionPrivateState.AccumulatedLearningPointsForUpgrade);

            this.PlayerAvailableLearningPoints = ClientComponentTechnologiesWatcher.CurrentTechnologies.LearningPoints;
            this.LearningPointsToDonateMax     = (ushort)Math.Min(this.LearningPointsToDonateMax,
                                                                  this.PlayerAvailableLearningPoints);

            this.LearningPointsToDonateSelected = Math.Min(this.LearningPointsToDonateMax, (ushort)10);

            if (this.LearningPointsToDonateMax == 0)
            {
                // no need to donate anything as the required amount of LP is already present
                FactionSystem.ClientUpgradeFactionLevel(learningPointsDonation: 0,
                                                        this.toLevel);
                callbackCloseWindow();
            }
        }
Exemple #3
0
        public override double ServerGetCurrentValue(ILogicObject faction)
        {
            var structures = new HashSet <IStaticWorldObject>();
            var clanTag    = FactionSystem.SharedGetClanTag(faction);

            foreach (var area in LandClaimSystem.SharedEnumerateAllFactionAreas(clanTag))
            {
                var areaBounds = LandClaimSystem.SharedGetLandClaimAreaBounds(area, addGracePadding: false);
                ServerGatherValuableStructures(areaBounds, structures);
            }

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

            var result = 0.0;

            foreach (var obj in structures)
            {
                result += ((IProtoObjectStructure)obj.ProtoGameObject).FactionWealthScorePoints;
            }

            return(result);
        }
Exemple #4
0
        public string Execute(ICharacter player)
        {
            var faction = FactionSystem.ServerGetFaction(player);

            if (faction is null)
            {
                return($"Player \"{player.Name}\" has no faction");
            }

            var memberEntries = FactionSystem.ServerGetFactionMembersReadOnly(faction);
            var sb            = new StringBuilder("Player \"")
                                .Append(player.Name)
                                .AppendLine("\" - faction info:")
                                .Append("Clan tag: ")
                                .Append("[")
                                .Append(FactionSystem.SharedGetClanTag(faction))
                                .AppendLine("]")
                                .AppendLine("Members list (with roles): ");

            foreach (var entry in memberEntries)
            {
                sb.Append(" * ").AppendLine(entry.Name + " - " + entry.Role);
            }

            return(sb.ToString());
        }
Exemple #5
0
        public string Execute(
            [CustomSuggestions(nameof(GetClanTagSuggestions))]
            string clanTag)
        {
            var faction = FactionSystem.ServerGetFactionByClanTag(clanTag);

            var bannedCount = 0;

            foreach (var playerName in FactionSystem.ServerGetFactionMemberNames(faction))
            {
                var character = Server.Characters.GetPlayerCharacter(playerName);
                if (character == this.ExecutionContextCurrentCharacter)
                {
                    continue;
                }

                if (ServerPlayerAccessSystem.SetBlackListEntry(playerName, isEnabled: true))
                {
                    bannedCount++;
                }
            }

            if (bannedCount == 0)
            {
                return($"No need to add anyone from the faction [{clanTag}] to the blacklist (already added)");
            }

            return($"{bannedCount} player(s) of the faction [{clanTag}] were added to the blacklist");
        }
Exemple #6
0
        private static void ServerTransferAreasGroupToFactionOwnership(
            ILogicObject faction,
            ICharacter byCharacter,
            ILogicObject areasGroup)
        {
            var areas = LandClaimAreasGroup.GetPrivateState(areasGroup).ServerLandClaimsAreas;

            foreach (var area in areas)
            {
                ServerUnregisterArea(area);
            }

            var publicState = LandClaimAreasGroup.GetPublicState(areasGroup);

            publicState.ServerSetFaction(faction);

            var centerTilePosition
                = new Vector2Ushort(
                      (ushort)areas.Average(a => LandClaimArea.GetPublicState(a).LandClaimCenterTilePosition.X),
                      (ushort)areas.Average(a => LandClaimArea.GetPublicState(a).LandClaimCenterTilePosition.Y));

            Logger.Important(
                $"Transferred land claim areas group to the faction ownership: {areasGroup} at {centerTilePosition}");
            FactionSystem.ServerOnLandClaimExpanded(faction, centerTilePosition, byCharacter);

            foreach (var area in areas)
            {
                ServerRegisterArea(area);
            }
        }
        public string Execute([CurrentCharacterIfNull] ICharacter player, FactionMemberRole role)
        {
            var faction = FactionSystem.ServerGetFaction(player);

            if (faction is null)
            {
                return($"Player {player.Name} has no faction");
            }

            if (!Api.IsEditor)
            {
                var currentRole = FactionSystem.ServerGetRole(player);
                if (currentRole == FactionMemberRole.Leader)
                {
                    return("Cannot change the role of the faction leader");
                }

                if (role == FactionMemberRole.Leader)
                {
                    return("Cannot assign a leader role to anyone");
                }
            }

            FactionSystem.ServerSetMemberRoleNoChecks(player.Name, faction, role);
            return("Role changed to " + role);
        }
Exemple #8
0
        private void ServerOnPlayerOnlineStateChangedHandler(ICharacter playerCharacter, bool isOnline)
        {
            ServerRefreshTotalPlayersCount();

            var onlineStatusChangeReceivers = ServerGetOnlineStatusChangeReceivers(playerCharacter);

            this.CallClient(onlineStatusChangeReceivers,
                            _ => _.ClientRemote_OnlineStatusChanged(
                                new Entry(playerCharacter.Name,
                                          FactionSystem.SharedGetClanTag(playerCharacter)),
                                isOnline));

            if (SharedIsListHidden)
            {
                this.CallClient(Server.Characters
                                .EnumerateAllPlayerCharacters(onlyOnline: true)
                                .ExceptOne(playerCharacter)
                                .Except(onlineStatusChangeReceivers),
                                _ => _.ClientRemote_OnlinePlayersCountWhenListHidden(
                                    Server.Characters.OnlinePlayersCount));
            }

            if (!isOnline)
            {
                // player disconnected
                return;
            }

            this.ServerSendOnlineListAndOtherInfo(playerCharacter);
        }
Exemple #9
0
        private static void ServerCharacterDeathMechanicOnCharacterKilled(
            ICharacter attackerCharacter,
            ICharacter targetCharacter)
        {
            if (attackerCharacter.IsNpc ||
                !targetCharacter.IsNpc)
            {
                return;
            }

            var faction = FactionSystem.ServerGetFaction(attackerCharacter);

            if (faction is null)
            {
                return;
            }

            // a mob is killed by player
            var rawXP = SkillHunting.ExperienceForKill;

            rawXP *= ((IProtoCharacterMob)targetCharacter.ProtoGameObject).MobKillExperienceMultiplier;
            if (rawXP <= 0)
            {
                return;
            }

            rawXP *= 0.01; // 0.01 is our default XP->LP conversion coefficient (see TechConstants)

            Faction.GetPrivateState(faction).ServerMetricHuntingScore += rawXP;

            /*Logger.Dev("Mob killing metric updated: "
             + rawXP.ToString("0.###")
             + " total metric: "
             + Faction.GetPrivateState(faction).ServerMetricHuntingScore.ToString("0.###"));*/
        }
Exemple #10
0
        private void ServerCharacterGainedLearningPointsHandler(
            ICharacter character,
            int gainedLearningPoints,
            bool isModifiedByStat)
        {
            if (!isModifiedByStat)
            {
                // gained through the quest, by a consumable item, etc
                return;
            }

            var faction = FactionSystem.ServerGetFaction(character);

            if (faction is null)
            {
                return;
            }

            var factionPrivateState = Faction.GetPrivateState(faction);

            factionPrivateState.ServerMetricLearningPoints
                = (uint)Math.Min(factionPrivateState.ServerMetricLearningPoints + gainedLearningPoints,
                                 uint.MaxValue);

            /*Logger.Dev("Learning points metric updated: "
             + gainedLearningPoints.ToString("0.###")
             + " total metric: "
             + factionPrivateState.ServerMetricLearningPoints.ToString("0.###"));*/
        }
Exemple #11
0
        public override bool SharedCanInteract(ICharacter character, IStaticWorldObject worldObject, bool writeToLog)
        {
            if (!base.SharedCanInteract(character, worldObject, writeToLog))
            {
                return(false);
            }

            if (IsClient)
            {
                // cannot perform further checks on client side
                return(true);
            }

            if (PlayerCharacterSpectator.SharedIsSpectator(character) ||
                CreativeModeSystem.SharedIsInCreativeMode(character))
            {
                return(true);
            }

            var publicState = GetPublicState(worldObject);
            var areasGroup  = LandClaimSystem.SharedGetLandClaimAreasGroup(worldObject);

            if (areasGroup is not null &&
                LandClaimAreasGroup.GetPublicState(areasGroup).FactionClanTag is var claimFactionClanTag &&
                !string.IsNullOrEmpty(claimFactionClanTag))
            {
                // the land claim is owned by faction - verify permission
                if (claimFactionClanTag == FactionSystem.SharedGetClanTag(character) &&
                    FactionSystem.SharedHasAccessRight(character, FactionMemberAccessRights.LandClaimManagement))
                {
                    return(true);
                }
            }
Exemple #12
0
        private void ServerCharacterJoinedOrLeftPartyOrFactionHandler(
            ICharacter playerCharacter,
            ILogicObject party,
            bool isJoined)
        {
            if (!playerCharacter.ServerIsOnline)
            {
                // it's not in online players list so no notifications necessary
                return;
            }

            var onlineStatusChangeReceivers = ServerGetOnlineStatusChangeReceivers(playerCharacter);

            this.CallClient(onlineStatusChangeReceivers,
                            _ => _.ClientRemote_OnlinePlayerClanTagChanged(
                                new Entry(playerCharacter.Name,
                                          FactionSystem.SharedGetClanTag(playerCharacter))));

            if (!SharedIsListHidden)
            {
                return;
            }

            // need to notify current party and faction members that this player is online
            this.CallClient(onlineStatusChangeReceivers,
                            _ => _.ClientRemote_OnlineStatusChanged(
                                new Entry(playerCharacter.Name,
                                          FactionSystem.SharedGetClanTag(playerCharacter)),
                                true));
        }
Exemple #13
0
        private static ILogicObject ServerGetOwningFaction(IWorldObject worldObject)
        {
            ILogicObject faction = null;

            if (worldObject is IStaticWorldObject staticWorldObject)
            {
                var areasGroup = LandClaimSystem.SharedGetLandClaimAreasGroup(staticWorldObject);
                if (areasGroup is null)
                {
                    throw new Exception(
                              "Cannot modify faction access mode for an object without a faction land claim area");
                }

                faction = LandClaimAreasGroup.GetPublicState(areasGroup).ServerFaction;
            }
            else if (worldObject.ProtoGameObject is IProtoVehicle)
            {
                var clanTag = worldObject.GetPublicState <VehiclePublicState>().ClanTag;
                if (string.IsNullOrEmpty(clanTag))
                {
                    throw new Exception("The vehicle doesn't belong to a faction: " + worldObject);
                }

                faction = FactionSystem.ServerGetFactionByClanTag(clanTag);
            }

            if (faction is null)
            {
                throw new Exception(
                          "Cannot modify faction access mode for an object without a faction land claim area");
            }

            return(faction);
        }
Exemple #14
0
        private void ExecuteCommandInviteToFaction()
        {
            var viewModel = (ViewModelPlayerEntry)this.DataContext;
            var name      = viewModel.Name;

            FactionSystem.ClientOfficerInviteMember(name);
        }
Exemple #15
0
        public string Execute()
        {
            var sorted = Api.Server.Characters
                         .EnumerateAllPlayerCharacters(onlyOnline: false,
                                                       exceptSpectators: false)
                         .Select(c =>
            {
                var statistics = PlayerCharacter.GetPrivateState(c).Statistics;
                return(Character: c,
                       Score: statistics.MineralsMined + statistics.TreesCut);
            })
                         .Where(c => c.Score > 1)
                         .OrderByDescending(c => c.Score)
                         .Take(100)
                         .ToList();
            var sb = new StringBuilder();

            sb.AppendLine("Resource gathering leaderboard, top-100:")
            .Append("(format: total score | minerals mined | trees cut | total LP)");

            if (sorted.Count == 0)
            {
                sb.AppendLine()
                .Append("<the leaderboard is empty>");
                return(sb.ToString());
            }

            for (var index = 0; index < sorted.Count; index++)
            {
                var entry = sorted[index];
                sb.AppendLine()
                .Append("#")
                .Append(index + 1)
                .Append(" ");

                var clanTag = FactionSystem.SharedGetClanTag(entry.Character);
                if (!string.IsNullOrEmpty(clanTag))
                {
                    sb.Append("[")
                    .Append(clanTag)
                    .Append("] ");
                }

                var characterPrivateState = PlayerCharacter.GetPrivateState(entry.Character);
                var statistics            = characterPrivateState.Statistics;

                sb.Append(entry.Character.Name)
                .Append(" - ")
                .Append(entry.Score)
                .Append(" total, minerals: ")
                .Append(statistics.MineralsMined)
                .Append(", trees: ")
                .Append(statistics.TreesCut)
                .Append(", LP: ")
                .Append(characterPrivateState.Technologies.LearningPointsAccumulatedTotal);
            }

            return(sb.ToString());
        }
Exemple #16
0
        public static void ClientDeactivateShield(ILogicObject areasGroup)
        {
            var status = SharedGetShieldPublicStatus(areasGroup);

            if (status == ShieldProtectionStatus.Inactive)
            {
                Logger.Important("The shield is already inactive");
                return;
            }

            var stackPanel = new StackPanel();

            stackPanel.Children.Add(
                DialogWindow.CreateTextElement(
                    string.Format(CoreStrings.ShieldProtection_DeactivationNotes_Format,
                                  ClientTimeFormatHelper.FormatTimeDuration(
                                      SharedCooldownDuration,
                                      appendSeconds: false)),
                    TextAlignment.Left));

            var accessRight            = FactionMemberAccessRights.BaseShieldManagement;
            var areasGroupPublicState  = LandClaimAreasGroup.GetPublicState(areasGroup);
            var hasNoFactionPermission = !string.IsNullOrEmpty(areasGroupPublicState.FactionClanTag) &&
                                         !FactionSystem.ClientHasAccessRight(accessRight);

            if (hasNoFactionPermission)
            {
                var message = FactionSystem.ClientHasFaction
                                  ? string.Format(
                    CoreStrings.Faction_Permission_Required_Format,
                    accessRight.GetDescription())
                                  : CoreStrings.Faction_ErrorDontHaveFaction;

                var textElement = DialogWindow.CreateTextElement("[br]" + message,
                                                                 TextAlignment.Left);

                textElement.Foreground = Client.UI.GetApplicationResource <Brush>("BrushColorRed6");
                textElement.FontWeight = FontWeights.Bold;
                stackPanel.Children.Add(textElement);
            }

            var dialog = DialogWindow.ShowDialog(
                CoreStrings.ShieldProtection_Dialog_ConfirmDeactivation,
                stackPanel,
                okText: CoreStrings.ShieldProtection_Button_DeactivateShield,
                okAction: () => Instance.CallServer(_ => _.ServerRemote_DeactivateShield(areasGroup)),
                cancelAction: () => { },
                focusOnCancelButton: true);

            if (hasNoFactionPermission)
            {
                dialog.ButtonOk.IsEnabled = false;
            }
        }
Exemple #17
0
        private void ServerRemote_TransferLandClaimToFactionOwnership(ILogicObject area)
        {
            var character  = ServerRemoteContext.Character;
            var areasGroup = SharedGetLandClaimAreasGroup(area);

            if (LandClaimAreasGroup.GetPublicState(areasGroup).ServerFaction is not null)
            {
                // already has a faction (and it's not possible to change the faction)
                Logger.Warning("The land claim areas group is already transferred to a faction.");
                return;
            }

            FactionSystem.ServerValidateHasAccessRights(character,
                                                        FactionMemberAccessRights.LandClaimManagement,
                                                        out var faction);

            var factionOwnedAreas = SharedEnumerateAllFactionAreas(FactionSystem.SharedGetClanTag(faction));
            var claimLimitRemains = FactionConstants.SharedGetFactionLandClaimsLimit(
                Faction.GetPublicState(faction).Level)
                                    - factionOwnedAreas.Count();

            claimLimitRemains -= LandClaimAreasGroup.GetPrivateState(areasGroup).ServerLandClaimsAreas.Count;
            if (claimLimitRemains < 0)
            {
                Logger.Warning(
                    "Cannot transfer land claims to the faction as it will exceed the land claims number limit");
                return;
            }

            Logger.Important("Will transfer land claims to the faction: after upgrade the remaining limit will be "
                             + claimLimitRemains);

            // verify user has access to the land claim
            var owner = ServerRemoteContext.Character;

            if (!Server.World.IsInPrivateScope(area, owner))
            {
                throw new Exception(
                          "Cannot interact with the land claim object as the area is not in private scope: "
                          + area);
            }

            if (!LandClaimArea.GetPrivateState(area).ServerGetLandOwners()
                .Contains(owner.Name))
            {
                throw new Exception("Player is not an owner of the land claim area");
            }

            ServerTransferAreasGroupToFactionOwnership(faction, character, areasGroup);

            var worldObject = InteractionCheckerSystem.SharedGetCurrentInteraction(character);

            InteractableWorldObjectHelper.ServerTryAbortInteraction(character, worldObject);
        }
Exemple #18
0
        public void ServerSetFaction(ILogicObject faction)
        {
            if (this.ServerFaction is not null &&
                !ReferenceEquals(this.ServerFaction, faction))
            {
                throw new Exception("This land claim areas group is already owned by a faction");
            }

            this.ServerFaction  = faction;
            this.FactionClanTag = FactionSystem.SharedGetClanTag(faction);
        }
        private Color GetColor()
        {
            if (this.currentCharacter.IsCurrentClientCharacter)
            {
                return(RayColorCurrentPlayerCharacter);
            }

            return(PartySystem.ClientIsPartyMember(this.currentCharacter.Name) ||
                   FactionSystem.ClientIsFactionMemberOrAlly(this.currentCharacter)
                       ? RayColorFriendlyPlayerCharacter
                       : RayColorOtherPlayerCharacter);
        }
Exemple #20
0
        private void ServerRemote_TransferToFactionOwnership(IDynamicWorldObject vehicle)
        {
            var character = ServerRemoteContext.Character;

            if (vehicle.ProtoGameObject is not IProtoVehicle)
            {
                throw new Exception("Not a vehicle");
            }

            if (!vehicle.ProtoWorldObject.SharedCanInteract(character,
                                                            vehicle,
                                                            writeToLog: true))
            {
                return;
            }

            var publicState = vehicle.GetPublicState <VehiclePublicState>();

            if (!string.IsNullOrEmpty(publicState.ClanTag))
            {
                Logger.Warning("Already in faction ownership: " + vehicle, character);
                return;
            }

            var faction = FactionSystem.ServerGetFaction(character);

            if (faction is null)
            {
                throw new Exception("Player has no faction");
            }

            /*if (FactionSystem.SharedGetFactionKind(faction)
             *  == FactionKind.Public)
             * {
             *  throw new Exception("Cannot transfer a vehicle to ownership of a public faction");
             * }*/

            var clanTag = FactionSystem.SharedGetClanTag(faction);

            publicState.ClanTag = clanTag;

            var privateState = vehicle.GetPrivateState <VehiclePrivateState>();

            //privateState.Owners.Clear(); // keep the original owners list in case the faction is dissolved
            privateState.FactionAccessMode = WorldObjectFactionAccessModes.Leader
                                             | WorldObjectFactionAccessModes.Officer1
                                             | WorldObjectFactionAccessModes.Officer2
                                             | WorldObjectFactionAccessModes.Officer3;
            Logger.Important($"Vehicle transferred to faction ownership: {vehicle} - [{clanTag}]", character);

            WorldObjectOwnersSystem.ServerOnOwnersChanged(vehicle);
        }
Exemple #21
0
        private async void RequestData()
        {
            var entry = await FactionSystem.ClientGetFactionEntry(this.clanTag);

            if (this.IsDisposed)
            {
                // received too late
                return;
            }

            this.factionEntry = entry;
            this.Refresh();
        }
Exemple #22
0
        public override IEnumerable <ICharacter> ServerEnumerateMessageRecepients(ICharacter forPlayer)
        {
            var members = FactionSystem.ServerGetFactionMemberNames(this.Faction);

            foreach (var member in members)
            {
                var character = CharactersServerService.GetPlayerCharacter(member);
                if (character is not null)
                {
                    yield return(character);
                }
            }
        }
Exemple #23
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));
        }
Exemple #24
0
 private void ExecuteCommandEditFactionDescription(bool isPrivateDescription)
 {
     BbTextEditorHelper.ClientOpenTextEditor(
         originalText: isPrivateDescription
                           ? this.factionPrivateState.DescriptionPrivate
                           : this.factionPrivateState.DescriptionPublic,
         maxLength: isPrivateDescription
                        ? FactionSystem.MaxDescriptionLengthPrivate
                        : FactionSystem.MaxDescriptionLengthPublic,
         windowHeight: isPrivateDescription
                           ? 450
                           : 200,
         onSave: text => FactionSystem.ClientOfficerSetFactionDescription(text, isPrivateDescription));
 }
Exemple #25
0
        public static ChatEntry CreatePlayerMessage(ICharacter fromCharacter, string message)
        {
            var hasSupporterPack = Api.IsServer
                                       ? Api.Server.Characters.IsSupporterPackOwner(fromCharacter)
                                       : fromCharacter.IsCurrentClientCharacter &&
                                   Api.Client.MasterServer.IsSupporterPackOwner;

            return(new ChatEntry(fromCharacter.Name,
                                 message,
                                 isService: false,
                                 DateTime.Now,
                                 hasSupporterPack,
                                 clanTag: FactionSystem.SharedGetClanTag(fromCharacter)));
        }
Exemple #26
0
        public string Execute(ICharacter player, string clanTag)
        {
            var faction = FactionSystem.ServerGetFactionByClanTag(clanTag);

            if (faction is null)
            {
                return("Faction not found: " + clanTag);
            }

            var result = FactionSystem.ServerForceAcceptApplication(player,
                                                                    faction);

            return("Faction application accept result: " + result.GetDescription());
        }
Exemple #27
0
        public ViewModelWindowCrateContainer(
            IStaticWorldObject worldObjectCrate,
            ObjectCratePrivateState privateState,
            Action callbackCloseWindow)
        {
            this.WorldObjectCrate = worldObjectCrate;

            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                privateState.ItemsContainer,
                callbackCloseWindow)
            {
                IsContainerTitleVisible = false
            };

            this.IsInsideFactionClaim = LandClaimSystem.SharedIsWorldObjectOwnedByFaction(worldObjectCrate);

            if (!this.HasOwnersList)
            {
                return;
            }

            if (this.IsInsideFactionClaim)
            {
                if (FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.LandClaimManagement))
                {
                    this.ViewModelFactionAccessEditor = new ViewModelWorldObjectFactionAccessEditorControl(
                        worldObjectCrate);
                }
            }
            else
            {
                var isOwner = WorldObjectOwnersSystem.SharedIsOwner(
                    ClientCurrentCharacterHelper.Character,
                    worldObjectCrate);

                this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                    privateState.Owners,
                    canEditOwners: isOwner ||
                    CreativeModeSystem.ClientIsInCreativeMode(),
                    callbackServerSetOwnersList:
                    ownersList => WorldObjectOwnersSystem.ClientSetOwners(this.WorldObjectCrate,
                                                                          ownersList),
                    title: CoreStrings.ObjectOwnersList_Title2);

                this.ViewModelDirectAccessEditor = new ViewModelWorldObjectDirectAccessEditor(
                    worldObjectCrate,
                    canSetAccessMode: isOwner);
            }
        }
Exemple #28
0
            private static void ServerAreasGroupChangedHandler(
                ILogicObject area,
                [CanBeNull] ILogicObject areasGroupFrom,
                [CanBeNull] ILogicObject areasGroupTo)
            {
                var byMember = ServerPlayerCharacterCurrentActionStateContext.CurrentCharacter
                               ?? (ServerRemoteContext.IsRemoteCall
                                       ? ServerRemoteContext.Character
                                       : null);

                if (areasGroupTo is not null)
                {
                    var clanTag = LandClaimAreasGroup.GetPublicState(areasGroupTo).FactionClanTag;
                    if (string.IsNullOrEmpty(clanTag))
                    {
                        return;
                    }

                    var faction            = FactionSystem.ServerGetFactionByClanTag(clanTag);
                    var centerTilePosition = LandClaimArea.GetPublicState(area).LandClaimCenterTilePosition;
                    Logger.Important(
                        string.Format("Faction-owned land claim areas group expanded with a new claim area: {0} at {1}",
                                      areasGroupTo,
                                      centerTilePosition));

                    FactionSystem.ServerOnLandClaimExpanded(faction,
                                                            centerTilePosition,
                                                            byMember: byMember);
                }
                else if (areasGroupFrom is not null)
                {
                    var clanTag = LandClaimAreasGroup.GetPublicState(areasGroupFrom).FactionClanTag;
                    if (string.IsNullOrEmpty(clanTag))
                    {
                        return;
                    }

                    var faction            = FactionSystem.ServerGetFactionByClanTag(clanTag);
                    var centerTilePosition = LandClaimArea.GetPublicState(area).LandClaimCenterTilePosition;
                    Logger.Important(
                        string.Format("Faction-owned land claim areas group removed: {0} at {1}",
                                      areasGroupFrom,
                                      centerTilePosition));

                    FactionSystem.ServerOnLandClaimRemoved(faction,
                                                           centerTilePosition,
                                                           byMember: byMember);
                }
            }
Exemple #29
0
        private static bool SharedHasFactionAccessRights(
            ICharacter who,
            FactionMemberAccessRights accessRights,
            string clanTag)
        {
            Api.Assert(!string.IsNullOrEmpty(clanTag), "Clan tag is null or empty");

            if (clanTag != FactionSystem.SharedGetClanTag(who))
            {
                // player has no faction or a member of a different faction
                return(false);
            }

            return(FactionSystem.SharedHasAccessRight(who, accessRights));
        }
Exemple #30
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);
            }
        }