Beispiel #1
0
 public static void InitializeReferences()
 {
     if (MBGlobals._initialized)
     {
         return;
     }
     MBGlobals._actionSets                           = new Dictionary <string, MBActionSet>();
     MBGlobals.HumanWarriorActionSet                 = MBGlobals.GetActionSet("as_human_warrior");
     MBGlobals.HumanVillager1ActionSet               = MBGlobals.GetActionSet("as_human_villager");
     MBGlobals.HumanVillager2ActionSet               = MBGlobals.GetActionSet("as_human_villager_2");
     MBGlobals.HumanVillager3ActionSet               = MBGlobals.GetActionSet("as_human_villager_3");
     MBGlobals.HumanVillager4ActionSet               = MBGlobals.GetActionSet("as_human_villager_4");
     MBGlobals.HumanFemaleVillager1ActionSet         = MBGlobals.GetActionSet("as_human_female_villager");
     MBGlobals.HumanFemaleVillager2ActionSet         = MBGlobals.GetActionSet("as_human_female_villager_2");
     MBGlobals.HumanVillainActionSet                 = MBGlobals.GetActionSet("as_human_villain");
     MBGlobals.HumanPrisonerActionSet                = MBGlobals.GetActionSet("as_human_prisoner");
     MBGlobals.HumanLordActionSet                    = MBGlobals.GetActionSet("as_human_lord");
     MBGlobals.HumanLadyActionSet                    = MBGlobals.GetActionSet("as_human_lady");
     MBGlobals.HumanVillagerDrinkerWithMugActionSet  = MBGlobals.GetActionSet("as_human_villager_drinker_with_mug");
     MBGlobals.HumanVillagerDrinkerWithBowlActionSet = MBGlobals.GetActionSet("as_human_villager_drinker_with_bowl");
     MBGlobals.HumanBarmaidActionSet                 = MBGlobals.GetActionSet("as_human_barmaid");
     MBGlobals.HumanTavernKeeperActionSet            = MBGlobals.GetActionSet("as_human_tavern_keeper");
     MBGlobals.HumanMusicianActionSet                = MBGlobals.GetActionSet("as_human_musician");
     MBGlobals.HumanGameHostActionSet                = MBGlobals.GetActionSet("as_human_game_host");
     MBGlobals.HumanGuardActionSet                   = MBGlobals.GetActionSet("as_human_guard");
     MBGlobals.HumanMaleFaceGenActionSet             = MBGlobals.GetActionSet("as_human_male_facegen");
     MBGlobals.HumanFemaleFaceGenActionSet           = MBGlobals.GetActionSet("as_human_female_facegen");
     MBGlobals.HumanMapActionSet                     = MBGlobals.GetActionSet("as_human_map");
     MBGlobals.HumanMapWithBannerActionSet           = MBGlobals.GetActionSet("as_human_map_with_banner");
     MBGlobals.PlayerMaleActionSet                   = MBGlobals.GetActionSet("as_player_male");
     MBGlobals._initialized                          = true;
 }
 protected internal override void OnEditorVariableChanged(string variableName)
 {
     base.OnEditorVariableChanged(variableName);
     if (variableName == MBGlobals.GetMemberName <string>((Expression <Func <string> >)(() => this.materialName)))
     {
         this.UpdatePathMesh();
     }
     if (!((NativeObject)this.pathMesh != (NativeObject)null))
     {
         return;
     }
     this.pathMesh.SetVectorArgument2(this.textureSweepX, this.textureSweepY, 0.0f, 0.0f);
 }
Beispiel #3
0
        public override void OnLoadFinished()
        {
            base.OnLoadFinished();
            MBGlobals.InitializeReferences();
            GameState state;

            if (GameNetwork.IsDedicatedServer)
            {
                int dedicatedServerType = (int)Module.CurrentModule.StartupInfo.DedicatedServerType;
                state = (GameState)Game.Current.GameStateManager.CreateState <UnspecifiedDedicatedServerState>();
            }
            else
            {
                state = (GameState)Game.Current.GameStateManager.CreateState <LobbyState>();
            }
            Game.Current.GameStateManager.CleanAndPushState(state);
        }
Beispiel #4
0
        protected override void DoLoadingForGameManager(
            GameManagerLoadingSteps gameManagerLoadingStep,
            out GameManagerLoadingSteps nextStep)
        {
            nextStep = GameManagerLoadingSteps.None;
            switch (gameManagerLoadingStep)
            {
            case GameManagerLoadingSteps.PreInitializeZerothStep:
                nextStep = GameManagerLoadingSteps.FirstInitializeFirstStep;
                break;

            case GameManagerLoadingSteps.FirstInitializeFirstStep:
                MBGameManager.LoadModuleData(false);
                MBDebug.Print("Game creating...");
                MBGlobals.InitializeReferences();
                Game.CreateGame((TaleWorlds.Core.GameType) new MultiplayerGame(), (GameManagerBase)this).DoLoading();
                nextStep = GameManagerLoadingSteps.WaitSecondStep;
                break;

            case GameManagerLoadingSteps.WaitSecondStep:
                MBGameManager.StartNewGame();
                nextStep = GameManagerLoadingSteps.SecondInitializeThirdState;
                break;

            case GameManagerLoadingSteps.SecondInitializeThirdState:
                nextStep = Game.Current.DoLoading() ? GameManagerLoadingSteps.PostInitializeFourthState : GameManagerLoadingSteps.SecondInitializeThirdState;
                break;

            case GameManagerLoadingSteps.PostInitializeFourthState:
                bool flag = true;
                foreach (MBSubModuleBase subModule in Module.CurrentModule.SubModules)
                {
                    flag = flag && subModule.DoLoading(Game.Current);
                }
                nextStep = flag ? GameManagerLoadingSteps.FinishLoadingFifthStep : GameManagerLoadingSteps.PostInitializeFourthState;
                break;

            case GameManagerLoadingSteps.FinishLoadingFifthStep:
                nextStep = GameManagerLoadingSteps.None;
                break;
            }
        }
Beispiel #5
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();
        }