public void SetAnimationAtChannelSynched(
            string animationName,
            int channelNo,
            float animationSpeed = 1f)
        {
            int animationIndexWithName1 = MBAnimation.GetAnimationIndexWithName(animationName);

            if (GameNetwork.IsServerOrRecorder)
            {
                int  animationIndexWithName2 = MBAnimation.GetAnimationIndexWithName(this.GameEntity.Skeleton.GetAnimationAtChannel(channelNo));
                bool flag = true;
                int  num  = animationIndexWithName1;
                if (animationIndexWithName2 == num && this.GameEntity.Skeleton.GetAnimationSpeedAtChannel(channelNo).ApproximatelyEqualsTo(animationSpeed) && (double)this.GameEntity.Skeleton.GetAnimationParameterAtChannel(channelNo) < 0.0199999995529652)
                {
                    flag = false;
                }
                if (flag)
                {
                    GameNetwork.BeginBroadcastModuleEvent();
                    GameNetwork.WriteMessage((GameNetworkMessage) new SetMissionObjectAnimationAtChannel((MissionObject)this, channelNo, animationIndexWithName1, animationSpeed));
                    GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.AddToMissionRecord);
                    this._initialSynchFlags |= SynchedMissionObject.SynchFlags.SynchAnimation;
                }
            }
            this.GameEntity.Skeleton.SetAnimationAtChannel(animationIndexWithName1, channelNo, animationSpeed);
        }
示例#2
0
 protected internal override void OnTick(float dt)
 {
     base.OnTick(dt);
     if (GameNetwork.IsClientOrReplay)
     {
         return;
     }
     if (this.HasAIMovingTo)
     {
         foreach (KeyValuePair <Agent, UsableMissionObject.MoveInfo> movingAgent in this.MovingAgents)
         {
             this.UpdateAgent(movingAgent.Key, movingAgent.Value);
         }
     }
     if (!this.HasUser)
     {
         return;
     }
     if (this.DoesActionTypeStopUsingGameObject(MBAnimation.GetActionType(this.UserAgent.GetCurrentAction(0))))
     {
         this.UserAgent.StopUsingGameObject(false);
     }
     else
     {
         if (!this.AutoSheathWeapons)
         {
             return;
         }
         if (this.UserAgent.GetWieldedItemIndex(Agent.HandIndex.MainHand) != EquipmentIndex.None)
         {
             this.UserAgent.TryToSheathWeaponInHand(Agent.HandIndex.MainHand, Agent.WeaponWieldActionType.Instant);
         }
         if (this.UserAgent.GetWieldedItemIndex(Agent.HandIndex.OffHand) == EquipmentIndex.None)
         {
             return;
         }
         this.UserAgent.TryToSheathWeaponInHand(Agent.HandIndex.OffHand, Agent.WeaponWieldActionType.Instant);
     }
 }
 public virtual void WriteToNetwork()
 {
     GameNetworkMessage.WriteBoolToPacket(this.GameEntity.GetVisibilityExcludeParents());
     GameNetworkMessage.WriteBoolToPacket(this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SynchTransform));
     if (this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SynchTransform))
     {
         GameNetworkMessage.WriteMatrixFrameToPacket(this.GameEntity.GetFrame());
         GameNetworkMessage.WriteBoolToPacket(this._synchState == SynchedMissionObject.SynchState.SynchronizeFrameOverTime);
         if (this._synchState == SynchedMissionObject.SynchState.SynchronizeFrameOverTime)
         {
             GameNetworkMessage.WriteMatrixFrameToPacket(this._lastSynchedFrame);
             GameNetworkMessage.WriteFloatToPacket(this._duration - this._timer, CompressionMission.FlagCapturePointDurationCompressionInfo);
         }
     }
     if ((NativeObject)this.GameEntity.Skeleton != (NativeObject)null)
     {
         string animationAtChannel = this.GameEntity.Skeleton.GetAnimationAtChannel(0);
         int    num = !string.IsNullOrEmpty(animationAtChannel) ? 1 : 0;
         GameNetworkMessage.WriteBoolToPacket(num != 0 && this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SynchAnimation));
         if (num != 0 && this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SynchAnimation))
         {
             int    animationIndexWithName  = MBAnimation.GetAnimationIndexWithName(animationAtChannel);
             double animationSpeedAtChannel = (double)this.GameEntity.Skeleton.GetAnimationSpeedAtChannel(0);
             GameNetworkMessage.WriteIntToPacket(animationIndexWithName, CompressionBasic.AnimationIndexCompressionInfo);
             CompressionInfo.Float speedCompressionInfo = CompressionBasic.AnimationSpeedCompressionInfo;
             GameNetworkMessage.WriteFloatToPacket((float)animationSpeedAtChannel, speedCompressionInfo);
             GameNetworkMessage.WriteFloatToPacket(this.GameEntity.Skeleton.GetAnimationParameterAtChannel(0), CompressionBasic.UnitVectorCompressionInfo);
             GameNetworkMessage.WriteBoolToPacket(this.GameEntity.IsSkeletonAnimationPaused());
         }
     }
     GameNetworkMessage.WriteBoolToPacket(this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SyncColors));
     if (this._initialSynchFlags.HasAnyFlag <SynchedMissionObject.SynchFlags>(SynchedMissionObject.SynchFlags.SyncColors))
     {
         GameNetworkMessage.WriteUintToPacket(this.Color, CompressionGeneric.ColorCompressionInfo);
         GameNetworkMessage.WriteUintToPacket(this.Color2, CompressionGeneric.ColorCompressionInfo);
     }
     GameNetworkMessage.WriteBoolToPacket(this.IsDisabled);
 }
 public MBAnimation(MBAnimation animation) => this.Index = animation.Index;