public void SendAnimationCommand(ref MyAnimationCommand command) { MyMultiplayer.RaiseEvent(this, x => x.OnAnimationCommand, command); }
void OnAnimationCommand(MyAnimationCommand command) { AddCommand(command); }
public void PlayCharacterAnimation( string animationName, MyBlendOption blendOption, MyFrameOption frameOption, float blendTime, float timeScale = 1, bool sync = false, string influenceArea = null, //use defined boneset area from character definitions bool excludeLegsWhenMoving = false ) { if (UseNewAnimationSystem) return; bool disableAnimations = MySandboxGame.IsDedicated && MyPerGameSettings.DisableAnimationsOnDS; if (disableAnimations && !sync) { return; } if (!m_animationCommandsEnabled) return; if (animationName == null) { System.Diagnostics.Debug.Fail("Cannot play null animation!"); return; } string animationSubtype = null; if (!m_characterDefinition.AnimationNameToSubtypeName.TryGetValue(animationName, out animationSubtype)) { animationSubtype = animationName; } var command = new MyAnimationCommand() { AnimationSubtypeName = animationSubtype, PlaybackCommand = MyPlaybackCommand.Play, BlendOption = blendOption, FrameOption = frameOption, BlendTime = blendTime, TimeScale = timeScale, Area = influenceArea, ExcludeLegsWhenMoving = excludeLegsWhenMoving }; // CH: If we don't want to play the animation ourselves, but it has to be synced, we have to send it to clients at least // MZ: when sync is on, we always want to send the message if (sync) { SendAnimationCommand(ref command); } else { // if animations are disabled and sync is off, don't do anything if (!disableAnimations) AddCommand(command, sync); } }
internal void AddCommand(MyAnimationCommand command, bool sync = false) { if (command.Mode == MyPlayAnimationMode.Immediate) { m_commandQueue.Clear(); } m_commandQueue.Enqueue(command); if (sync) SyncObject.SendAnimationCommand(ref command); }
public override void AddCommand(MyAnimationCommand command, bool sync = false) { if (UseNewAnimationSystem) return; base.AddCommand(command, sync); if (sync) { SendAnimationCommand(ref command); } }
protected override void OnAnimationPlay(MyAnimationDefinition animDefinition,MyAnimationCommand command, ref string bonesArea, ref MyFrameOption frameOption, ref bool useFirstPersonVersion) { var currentMovementState = GetCurrentMovementState(); if (DefinitionId.Value.SubtypeId == medievelMaleSubtypeId) { if (command.ExcludeLegsWhenMoving) { //In this case, we must stop all upper animations correctly if (currentMovementState == MyCharacterMovementEnum.RotatingLeft || currentMovementState == MyCharacterMovementEnum.RotatingRight || currentMovementState == MyCharacterMovementEnum.Standing) bonesArea = TopBody + " LowerBody"; else bonesArea = TopBody; frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption; } else if (m_lastBonesArea == TopBody + " LowerBody") StopLowerCharacterAnimation(0.2f); m_lastBonesArea = bonesArea; } else { if (currentMovementState != MyCharacterMovementEnum.Standing && currentMovementState != MyCharacterMovementEnum.RotatingLeft && currentMovementState != MyCharacterMovementEnum.RotatingRight && command.ExcludeLegsWhenMoving) { //In this case, we must stop all upper animations correctly bonesArea = TopBody; frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption; } } useFirstPersonVersion = IsInFirstPersonView; if (animDefinition.AllowWithWeapon) { if (!UseAnimationForWeapon) { UseAnimationForWeapon = true; m_resetWeaponAnimationState = true; } } }
public override void AddCommand(MyAnimationCommand command, bool sync = false) { base.AddCommand(command, sync); if (sync) SyncObject.SendAnimationCommand(ref command); }
protected override void OnAnimationPlay(MyAnimationDefinition animDefinition,MyAnimationCommand command, ref string bonesArea, ref MyFrameOption frameOption, ref bool useFirstPersonVersion) { var currentMovementState = GetCurrentMovementState(); if (currentMovementState != MyCharacterMovementEnum.Standing && currentMovementState != MyCharacterMovementEnum.RotatingLeft && currentMovementState != MyCharacterMovementEnum.RotatingRight && command.ExcludeLegsWhenMoving) { //In this case, we must stop all upper animations correctly bonesArea = TopBody; frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption; } useFirstPersonVersion = IsInFirstPersonView; if (animDefinition.AllowWithWeapon) { if (!UseAnimationForWeapon) { StoreWeaponRelativeMatrix(); UseAnimationForWeapon = true; m_resetWeaponAnimationState = true; } } if (!animDefinition.LeftHandItem.TypeId.IsNull) { if (m_leftHandItem != null) { (m_leftHandItem as IMyHandheldGunObject<Sandbox.Game.Weapons.MyDeviceBase>).OnControlReleased(); m_leftHandItem.Close(); } m_leftHandItem = MyEntityFactory.CreateEntity(animDefinition.LeftHandItem.TypeId); var ob = MyEntityFactory.CreateObjectBuilder(m_leftHandItem); m_leftHandItem.Init(ob); (m_leftHandItem as IMyHandheldGunObject<Sandbox.Game.Weapons.MyDeviceBase>).OnControlAcquired(this); UpdateLeftHandItemPosition(); MyEntities.Add(m_leftHandItem); } }
protected override void OnAnimationPlay(MyAnimationDefinition animDefinition,MyAnimationCommand command, ref string bonesArea, ref MyFrameOption frameOption, ref bool useFirstPersonVersion) { var currentMovementState = GetCurrentMovementState(); if (DefinitionId.Value.SubtypeId == medievelMaleSubtypeId) { if (command.ExcludeLegsWhenMoving) { //In this case, we must stop all upper animations correctly if (currentMovementState == MyCharacterMovementEnum.RotatingLeft || currentMovementState == MyCharacterMovementEnum.RotatingRight || currentMovementState == MyCharacterMovementEnum.Standing) bonesArea = TopBody + " LowerBody"; else bonesArea = TopBody; frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption; } else if (m_lastBonesArea == TopBody + " LowerBody") StopLowerCharacterAnimation(0.2f); m_lastBonesArea = bonesArea; } else { if (currentMovementState != MyCharacterMovementEnum.Standing && currentMovementState != MyCharacterMovementEnum.RotatingLeft && currentMovementState != MyCharacterMovementEnum.RotatingRight && command.ExcludeLegsWhenMoving) { //In this case, we must stop all upper animations correctly bonesArea = TopBody; frameOption = frameOption != MyFrameOption.JustFirstFrame ? MyFrameOption.PlayOnce : frameOption; } } useFirstPersonVersion = IsInFirstPersonView; if (animDefinition.AllowWithWeapon) { if (!UseAnimationForWeapon) { StoreWeaponRelativeMatrix(); UseAnimationForWeapon = true; m_resetWeaponAnimationState = true; } } if (!animDefinition.LeftHandItem.TypeId.IsNull) { if (m_leftHandItem != null) { (m_leftHandItem as IMyHandheldGunObject<Sandbox.Game.Weapons.MyDeviceBase>).OnControlReleased(); m_leftHandItem.Close(); } // CH: TODO: The entity id is not synced, but it never was in this place. It should be fixed later long handItemId = MyEntityIdentifier.AllocateId(); uint? inventoryItemId = null; var builder = GetObjectBuilderForWeapon(animDefinition.LeftHandItem, ref inventoryItemId, handItemId); var leftHandItem = CreateGun(builder, inventoryItemId); if (leftHandItem != null) { m_leftHandItem = leftHandItem as MyEntity; leftHandItem.OnControlAcquired(this); UpdateLeftHandItemPosition(); MyEntities.Add(m_leftHandItem); } } }