public AgentVisualsData(AgentVisualsData agentVisualsData)
 {
     this.AgentVisuals                = agentVisualsData.AgentVisuals;
     this.ActionSetData               = agentVisualsData.ActionSetData;
     this.FrameData                   = agentVisualsData.FrameData;
     this.BodyPropertiesData          = agentVisualsData.BodyPropertiesData;
     this.EquipmentData               = agentVisualsData.EquipmentData;
     this.RightWieldedItemIndexData   = agentVisualsData.RightWieldedItemIndexData;
     this.LeftWieldedItemIndexData    = agentVisualsData.LeftWieldedItemIndexData;
     this.SkeletonTypeData            = agentVisualsData.SkeletonTypeData;
     this.BannerData                  = agentVisualsData.BannerData;
     this.CachedWeaponSlot0Entity     = agentVisualsData.CachedWeaponSlot0Entity;
     this.CachedWeaponSlot1Entity     = agentVisualsData.CachedWeaponSlot1Entity;
     this.CachedWeaponSlot2Entity     = agentVisualsData.CachedWeaponSlot2Entity;
     this.CachedWeaponSlot3Entity     = agentVisualsData.CachedWeaponSlot3Entity;
     this.CachedWeaponSlot4Entity     = agentVisualsData.CachedWeaponSlot4Entity;
     this.SceneData                   = agentVisualsData.SceneData;
     this.MonsterData                 = agentVisualsData.MonsterData;
     this.PrepareImmediatelyData      = agentVisualsData.PrepareImmediatelyData;
     this.UseScaledWeaponsData        = agentVisualsData.UseScaledWeaponsData;
     this.UseTranslucencyData         = agentVisualsData.UseTranslucencyData;
     this.UseTesselationData          = agentVisualsData.UseTesselationData;
     this.UseMorphAnimsData           = agentVisualsData.UseMorphAnimsData;
     this.ClothColor1Data             = agentVisualsData.ClothColor1Data;
     this.ClothColor2Data             = agentVisualsData.ClothColor2Data;
     this.ScaleData                   = agentVisualsData.ScaleData;
     this.ActionCodeData              = agentVisualsData.ActionCodeData;
     this.EntityData                  = agentVisualsData.EntityData;
     this.CharacterObjectStringIdData = agentVisualsData.CharacterObjectStringIdData;
     this.HasClippingPlaneData        = agentVisualsData.HasClippingPlaneData;
     this.MountCreationKeyData        = agentVisualsData.MountCreationKeyData;
     this.AddColorRandomnessData      = agentVisualsData.AddColorRandomnessData;
 }
Example #2
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();
        }
Example #3
0
 public void Refresh(bool needBatchedVersionForWeaponMeshes, AgentVisualsData data)
 {
 }