private static void SetPlayerTransform( SimulationTickNumber simulationTickNumber, MovementSnapshotsComponent movementSnapshotsComponent, CharacterComponent characterComponent, ref Vector3 position, ref Quaternion rotation) { Debug.Assert(movementSnapshotsComponent != null); ref var movementData = ref movementSnapshotsComponent.SnapshotStore.GetOrCreate(simulationTickNumber);
private ClientPredictionSnapshotsComponent _clientPredictionSnapshotsComponent; // Optional component public override void Start() { base.Start(); var parentEntity = Entity.GetParent(); Debug.Assert(parentEntity != null); var networkEntityViewComp = parentEntity.Get <NetworkEntityViewComponent>(); var networkedEntity = networkEntityViewComp.NetworkedEntity; _networkEntityComponent = networkedEntity.Get <NetworkEntityComponent>(); Debug.Assert(_networkEntityComponent != null); _movementSnapshotsComponent = networkedEntity.Get <MovementSnapshotsComponent>(); Debug.Assert(_movementSnapshotsComponent != null); _clientPredictionSnapshotsComponent = networkedEntity.Get <ClientPredictionSnapshotsComponent>(); _gameClockManager = Services.GetSafeServiceAs <GameClockManager>(); _networkService = Services.GetService <IGameNetworkService>(); if (AnimationComponent == null) { throw new InvalidOperationException("The animation component is not set"); } if (AnimationIdle == null) { throw new InvalidOperationException("Idle animation is not set"); } if (AnimationWalk == null) { throw new InvalidOperationException("Walking animation is not set"); } if (AnimationRun == null) { throw new InvalidOperationException("Running animation is not set"); } if (AnimationJumpStart == null) { throw new InvalidOperationException("Jumping animation is not set"); } if (AnimationJumpMid == null) { throw new InvalidOperationException("Airborne animation is not set"); } if (AnimationJumpEnd == null) { throw new InvalidOperationException("Landing animation is not set"); } // By setting a custom blend tree builder we can override the default behavior of the animation system // Instead, BuildBlendTree(FastList<AnimationOperation> blendStack) will be called each frame AnimationComponent.BlendTreeBuilder = this; animEvaluatorIdle = AnimationComponent.Blender.CreateEvaluator(AnimationIdle); animEvaluatorWalk = AnimationComponent.Blender.CreateEvaluator(AnimationWalk); animEvaluatorRun = AnimationComponent.Blender.CreateEvaluator(AnimationRun); animEvaluatorJumpStart = AnimationComponent.Blender.CreateEvaluator(AnimationJumpStart); animEvaluatorJumpMid = AnimationComponent.Blender.CreateEvaluator(AnimationJumpMid); animEvaluatorJumpEnd = AnimationComponent.Blender.CreateEvaluator(AnimationJumpEnd); // Initial walk lerp walkLerpFactor = 0; animEvaluatorWalkLerp1 = animEvaluatorIdle; animEvaluatorWalkLerp2 = animEvaluatorWalk; animationClipWalkLerp1 = AnimationIdle; animationClipWalkLerp2 = AnimationWalk; }