Exemple #1
0
 protected override void HandleNewClientAfterLoadingFinished(NetworkCommunicator networkPeer)
 {
     GameNetwork.BeginBroadcastModuleEvent();
     GameNetwork.WriteMessage((GameNetworkMessage) new FlagDominationMoraleChangeMessage(this.MoraleRounded));
     GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
 }
Exemple #2
0
 private static void SyncBannersToAllClients(string bannerCode, NetworkCommunicator ownerPeer)
 {
     GameNetwork.BeginBroadcastModuleEvent();
     GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.CreateBanner(ownerPeer, bannerCode));
     GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeTargetPlayer, ownerPeer);
 }
Exemple #3
0
        protected virtual void OnBotKills(Agent botAgent, Agent killedAgent)
        {
            if (botAgent?.Team == null)
            {
                return;
            }
            if (botAgent.Formation?.PlayerOwner != null)
            {
                NetworkCommunicator networkCommunicator1 = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation == botAgent.Formation));
                if (networkCommunicator1 != null)
                {
                    MissionPeer         component            = networkCommunicator1.GetComponent <MissionPeer>();
                    MissionPeer         missionPeer          = killedAgent.MissionPeer;
                    NetworkCommunicator networkCommunicator2 = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null;

                    if (killedAgent.MissionPeer == null)
                    {
                        NetworkCommunicator networkCommunicator3 = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation == killedAgent.Formation));
                        if (networkCommunicator3 != null)
                        {
                            networkCommunicator2 = networkCommunicator3;
                            component.OnKillAnotherPeer(networkCommunicator2.GetComponent <MissionPeer>());
                        }
                    }
                    else
                    {
                        component.OnKillAnotherPeer(killedAgent.MissionPeer);
                    }
                    if (botAgent.Team.IsEnemyOf(killedAgent.Team))
                    {
                        ++component.KillCount;
                        component.Score += this._gameMode.GetScoreForKill(killedAgent);
                    }
                    else
                    {
                        --component.KillCount;
                        component.Score -= this._gameMode.GetScoreForKill(killedAgent);
                    }
                    this._missionScoreboardComponent.PlayerPropertiesChanged(networkCommunicator1);
                    GameNetwork.BeginBroadcastModuleEvent();
                    GameNetwork.WriteMessage((GameNetworkMessage) new KillDeathCountChange(networkCommunicator1, networkCommunicator2, component.KillCount, component.AssistCount, component.DeathCount, component.Score));
                    GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
                }
            }
            else
            {
                MissionScoreboardComponent.MissionScoreboardSide sideSafe = this._missionScoreboardComponent.GetSideSafe(botAgent.Team.Side);
                BotData botScores = sideSafe.BotScores;
                if (botAgent.Team.IsEnemyOf(killedAgent.Team))
                {
                    ++botScores.KillCount;
                }
                else
                {
                    --botScores.KillCount;
                }
                this._missionScoreboardComponent.BotPropertiesChanged(sideSafe.Side);
                GameNetwork.BeginBroadcastModuleEvent();
                GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.BotData(sideSafe.Side, botScores.KillCount, botScores.AssistCount, botScores.DeathCount, botScores.AliveCount));
                GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
            }
            this._missionScoreboardComponent.BotPropertiesChanged(botAgent.Team.Side);
        }
Exemple #4
0
 private void TeamChange(NetworkCommunicator player, Team oldTeam, Team nextTeam) => this._matchInfo.AddOrUpdatePlayer(player.VirtualPlayer.Id.ToString(), player.VirtualPlayer.UserName, player.ForcedAvatarIndex, nextTeam.TeamIndex - 1);
Exemple #5
0
 protected override void HandlePlayerDisconnect(NetworkCommunicator networkPeer) => networkPeer.RemoveComponent <MissionPeer>();
Exemple #6
0
 void IUdpNetworkHandler.HandleLateNewClientAfterSynchronized(
     NetworkCommunicator networkPeer)
 {
 }
        protected override void SpawnAgents()
        {
            BasicCultureObject cultureLimit1 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam1.GetStrValue());
            BasicCultureObject cultureLimit2 = MBObjectManager.Instance.GetObject <BasicCultureObject>(MultiplayerOptions.OptionType.CultureTeam2.GetStrValue());

            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                NetworkCommunicator networkPeer = peer.GetNetworkPeer();
                if (networkPeer.IsSynchronized && peer.ControlledAgent == null && (!peer.HasSpawnedAgentVisuals && peer.Team != null) && (peer.Team != this.Mission.SpectatorTeam && peer.SpawnTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission))))
                {
                    BasicCultureObject basicCultureObject = peer.Team.Side == BattleSideEnum.Attacker ? cultureLimit1 : cultureLimit2;
                    MultiplayerClassDivisions.MPHeroClass heroClassForPeer = MultiplayerClassDivisions.GetMPHeroClassForPeer(peer);
                    if (heroClassForPeer == null || heroClassForPeer.TroopCost > this.GameMode.GetCurrentGoldForPeer(peer))
                    {
                        if (peer.SelectedTroopIndex != 0)
                        {
                            peer.SelectedTroopIndex = 0;
                            GameNetwork.BeginBroadcastModuleEvent();
                            GameNetwork.WriteMessage((GameNetworkMessage) new UpdateSelectedTroopIndex(networkPeer, 0));
                            GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, networkPeer);
                        }
                    }
                    else
                    {
                        BasicCharacterObject heroCharacter = heroClassForPeer.HeroCharacter;
                        Equipment            equipment     = heroCharacter.Equipment.Clone();
                        IEnumerable <(EquipmentIndex, EquipmentElement)> alternativeEquipments = MPPerkObject.GetOnSpawnPerkHandler(peer)?.GetAlternativeEquipments(true);
                        if (alternativeEquipments != null)
                        {
                            foreach ((EquipmentIndex, EquipmentElement)tuple in alternativeEquipments)
                            {
                                equipment[tuple.Item1] = tuple.Item2;
                            }
                        }
                        AgentBuildData agentBuildData = new AgentBuildData(heroCharacter);
                        agentBuildData.MissionPeer(peer);
                        agentBuildData.Equipment(equipment);
                        agentBuildData.Team(peer.Team);
                        agentBuildData.IsFemale(peer.Peer.IsFemale);
                        agentBuildData.BodyProperties(this.GetBodyProperties(peer, peer.Team == this.Mission.AttackerTeam ? cultureLimit1 : cultureLimit2));
                        agentBuildData.VisualsIndex(0);
                        agentBuildData.ClothingColor1(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color : basicCultureObject.ClothAlternativeColor);
                        agentBuildData.ClothingColor2(peer.Team == this.Mission.AttackerTeam ? basicCultureObject.Color2 : basicCultureObject.ClothAlternativeColor2);
                        agentBuildData.TroopOrigin((IAgentOriginBase) new BasicBattleAgentOrigin(heroCharacter));
                        if (this.GameMode.ShouldSpawnVisualsForServer(networkPeer))
                        {
                            this.AgentVisualSpawnComponent.SpawnAgentVisualsForPeer(peer, agentBuildData, peer.SelectedTroopIndex);
                        }
                        this.GameMode.HandleAgentVisualSpawning(networkPeer, agentBuildData);
                    }
                }
            }
            if (this.Mission.AttackerTeam != null)
            {
                int num = 0;
                foreach (Agent activeAgent in this.Mission.AttackerTeam.ActiveAgents)
                {
                    if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                    {
                        ++num;
                    }
                }
                if (num < MultiplayerOptions.OptionType.NumberOfBotsTeam1.GetIntValue())
                {
                    this.SpawnBot(this.Mission.AttackerTeam, cultureLimit1);
                }
            }
            if (this.Mission.DefenderTeam == null)
            {
                return;
            }
            int num1 = 0;

            foreach (Agent activeAgent in this.Mission.DefenderTeam.ActiveAgents)
            {
                if (activeAgent.Character != null && activeAgent.MissionPeer == null)
                {
                    ++num1;
                }
            }
            if (num1 >= MultiplayerOptions.OptionType.NumberOfBotsTeam2.GetIntValue())
            {
                return;
            }
            this.SpawnBot(this.Mission.DefenderTeam, cultureLimit2);
        }
 public void PlayerIsInactive(NetworkCommunicator peer) => this.HandleNewNotification(MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.PlayerIsInactive, syncToPeer: peer);
 void IGameNetworkHandler.OnPlayerDisconnectedFromServer(
     NetworkCommunicator networkPeer)
 {
     GameManagerBase.Current.OnPlayerDisconnect(networkPeer.VirtualPlayer);
 }
 protected override void HandlePlayerDisconnect(NetworkCommunicator networkPeer)
 {
     int num = GameNetwork.IsServer ? 1 : 0;
 }
 public void GoldCarriedFromPreviousRound(int carriedGoldAmount, NetworkCommunicator syncToPeer) => this.HandleNewNotification(MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum.GoldCarriedFromPreviousRound, carriedGoldAmount, syncToPeer: syncToPeer);
 protected override void HandleLateNewClientAfterLoadingFinished(NetworkCommunicator networkPeer) => this.AddPeerEquipment(networkPeer.GetComponent <MissionPeer>());
Exemple #13
0
        public void SpawnAgentVisualsForPeer(
            MissionPeer missionPeer,
            AgentBuildData buildData,
            int selectedEquipmentSetIndex = -1,
            bool isBot          = false,
            int totalTroopCount = 0)
        {
            NetworkCommunicator myPeer = GameNetwork.MyPeer;

            if (myPeer != null)
            {
                myPeer.GetComponent <MissionPeer>();
            }
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.ClearAllVisuals();
            }
            missionPeer.ClearVisuals(buildData.AgentVisualsIndex);
            Equipment        overridenSpawnEquipment = buildData.AgentOverridenSpawnEquipment;
            ItemObject       mountItem           = overridenSpawnEquipment[10].Item;
            MatrixFrame      pointFrameForPlayer = this._spawnFrameSelectionHelper.GetSpawnPointFrameForPlayer(missionPeer.Peer, missionPeer.Team.Side, buildData.AgentVisualsIndex, totalTroopCount, mountItem != null);
            ActionIndexCache actionIndexCache1   = mountItem == null ? SpawningBehaviourBase.PoseActionInfantry : SpawningBehaviourBase.PoseActionCavalry;

            MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(buildData.AgentCharacter);
            IReadOnlyList <MPPerkObject>          selectedPerks     = missionPeer.SelectedPerks;
            float        parameter    = (float)(0.100000001490116 + (double)MBRandom.RandomFloat * 0.800000011920929);
            IAgentVisual mountVisuals = (IAgentVisual)null;

            if (mountItem != null)
            {
                Monster          monster = mountItem.HorseComponent.Monster;
                AgentVisualsData data    = new AgentVisualsData().Equipment(overridenSpawnEquipment).Scale(mountItem.ScaleFactor).Frame(MatrixFrame.Identity).ActionSet(MBGlobals.GetActionSet(monster.ActionSetCode)).Scene(Mission.Current.Scene).Monster(monster).PrepareImmediately(false).MountCreationKey(MountCreationKey.GetRandomMountKey(mountItem, MBRandom.RandomInt()));
                mountVisuals = Mission.Current.AgentVisualCreator.Create(data, "Agent " + buildData.AgentCharacter.StringId + " mount", true);
                MatrixFrame frame = pointFrameForPlayer;
                frame.rotation.ApplyScaleLocal(data.ScaleData);
                ActionIndexCache actionName = ActionIndexCache.act_none;
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.HeroMountIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopMountIdleAnimOverride != null)
                    {
                        actionName = ActionIndexCache.Create(mpPerkObject.TroopMountIdleAnimOverride);
                        break;
                    }
                }
                if (actionName == ActionIndexCache.act_none)
                {
                    if (mountItem.StringId == "mp_aserai_camel")
                    {
                        Debug.Print("Client is spawning a camel for without mountCustomAction from the perk.", debugFilter: 17179869184UL);
                        actionName = isBot ? ActionIndexCache.Create("act_camel_idle_1") : ActionIndexCache.Create("act_hero_mount_idle_camel");
                    }
                    else
                    {
                        if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.HeroMountIdleAnim);
                        }
                        if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopMountIdleAnim))
                        {
                            actionName = ActionIndexCache.Create(classForCharacter.TroopMountIdleAnim);
                        }
                    }
                }
                if (actionName != ActionIndexCache.act_none)
                {
                    mountVisuals.SetAction(actionName);
                    mountVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
                    mountVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, frame, true);
                }
                mountVisuals.GetVisuals().GetEntity().SetFrame(ref frame);
            }
            ActionIndexCache actionIndexCache2 = actionIndexCache1;

            if (mountVisuals != null)
            {
                actionIndexCache2 = mountVisuals.GetVisuals().GetSkeleton().GetActionAtChannel(0);
            }
            else
            {
                foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks)
                {
                    if (!isBot && mpPerkObject.HeroIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.HeroIdleAnimOverride);
                        break;
                    }
                    if (isBot && mpPerkObject.TroopIdleAnimOverride != null)
                    {
                        actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.TroopIdleAnimOverride);
                        break;
                    }
                }
                if (actionIndexCache2 == actionIndexCache1)
                {
                    if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.HeroIdleAnim);
                    }
                    if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopIdleAnim))
                    {
                        actionIndexCache2 = ActionIndexCache.Create(classForCharacter.TroopIdleAnim);
                    }
                }
            }
            IAgentVisual agentVisuals = Mission.Current.AgentVisualCreator.Create(new AgentVisualsData().Equipment(overridenSpawnEquipment).BodyProperties(buildData.AgentBodyProperties).Frame(pointFrameForPlayer).ActionSet(MBGlobals.PlayerMaleActionSet).Scene(Mission.Current.Scene).Monster(Game.Current.HumanMonster).PrepareImmediately(false).UseMorphAnims(true).SkeletonType(buildData.AgentIsFemale ? SkeletonType.Female : SkeletonType.Male).ClothColor1(buildData.AgentClothingColor1).ClothColor2(buildData.AgentClothingColor2).AddColorRandomness((uint)buildData.AgentVisualsIndex > 0U).ActionCode(actionIndexCache2), "Mission::SpawnAgentVisuals", true);

            agentVisuals.SetAction(actionIndexCache2);
            agentVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter);
            agentVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, pointFrameForPlayer, true);
            agentVisuals.GetVisuals().SetFrame(ref pointFrameForPlayer);
            agentVisuals.SetCharacterObjectID(buildData.AgentCharacter.StringId);
            EquipmentIndex mainHandWeaponIndex;
            EquipmentIndex offHandWeaponIndex;
            bool           isMainHandNotUsableWithOneHand;

            overridenSpawnEquipment.GetInitialWeaponIndicesToEquip(out mainHandWeaponIndex, out offHandWeaponIndex, out isMainHandNotUsableWithOneHand);
            if (isMainHandNotUsableWithOneHand)
            {
                offHandWeaponIndex = EquipmentIndex.None;
            }
            agentVisuals.GetVisuals().SetWieldedWeaponIndices((int)mainHandWeaponIndex, (int)offHandWeaponIndex);
            PeerVisualsHolder visualsHolder = new PeerVisualsHolder(missionPeer, buildData.AgentVisualsIndex, agentVisuals, mountVisuals);

            missionPeer.OnVisualsSpawned(visualsHolder, visualsHolder.VisualsIndex);
            if (buildData.AgentVisualsIndex == 0)
            {
                missionPeer.HasSpawnedAgentVisuals   = true;
                missionPeer.EquipmentUpdatingExpired = false;
            }
            if (!missionPeer.IsMine || buildData.AgentVisualsIndex != 0)
            {
                return;
            }
            Action agentVisualSpawned = this.OnMyAgentVisualSpawned;

            if (agentVisualSpawned == null)
            {
                return;
            }
            agentVisualSpawned();
        }
Exemple #14
0
 void IUdpNetworkHandler.HandlePlayerDisconnect(NetworkCommunicator networkPeer)
 {
 }
Exemple #15
0
 protected override void HandleEarlyNewClientAfterLoadingFinished(NetworkCommunicator networkPeer) => networkPeer.AddComponent <DuelMissionRepresentative>();
Exemple #16
0
 protected override void HandleNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
     networkPeer.AddComponent <TeamDeathmatchMissionRepresentative>();
     this.ChangeCurrentGoldForPeer(networkPeer.GetComponent <MissionPeer>(), 120);
     this.GameModeBaseClient.OnGoldAmountChangedForRepresentative((MissionRepresentativeBase)networkPeer.GetComponent <TeamDeathmatchMissionRepresentative>(), 120);
 }
 public override void HandleLateNewClientAfterLoadingFinished(NetworkCommunicator networkPeer)
 {
 }
Exemple #18
0
 void IUdpNetworkHandler.HandleLateNewClientAfterLoadingFinished(
     NetworkCommunicator networkPeer)
 {
 }