Exemple #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var globalTime = m_GlobalGameTimeQuery.GetSingleton <GlobalGameTime>();
            var deltaTime  = globalTime.frameDuration;

            var CharacterInterpolatedDataFromEntity = GetComponentDataFromEntity <Character.InterpolatedData>();

            Entities
            .ForEach((Entity entity, ref AnimSource.Data animSource, ref SystemState state, ref Settings settings,
                      ref AnimSource.AllowWrite allowWrite) =>
            {
                if (!state.ReloadActionAnim.IsValid())
                {
                    return;
                }

                if (allowWrite.FirstUpdate)
                {
                    // Make sure we don't trigger reload blend out on first update. So TimeSinceReloadStart should be at least clip length
                    state.TimeSinceReloadStart = state.ReloadActionAnim.ClipDuration;
                    allowWrite.FirstUpdate     = false;
                    return;
                }

                var charInterpolatedState = CharacterInterpolatedDataFromEntity[animSource.animStateEntity];

                // take the blend length
                // TODO: Expose blend durations and create separate ones for in and out

                // Once the actions starts, start counting time and generate a blend value
                if (charInterpolatedState.charAction == Ability.AbilityAction.Action.Reloading &&
                    state.CurrentBlendOutAimAction != Ability.AbilityAction.Action.Reloading)
                {
                    state.TimeSinceReloadStart = 0;
                }

                // Apply the blend value, possibly smoothed or through an animation curve
                charInterpolatedState.blendOutAim = 0f;
                if (charInterpolatedState.charAction == Ability.AbilityAction.Action.Reloading && settings.ReloadBlendOutAimCurve != BlobAssetReference <KeyframeCurveBlob> .Null)
                {
                    var normalizedTime = state.TimeSinceReloadStart / state.ReloadActionAnim.ClipDuration;
                    charInterpolatedState.blendOutAim = 1f - KeyframeCurveEvaluator.Evaluate(normalizedTime, settings.ReloadBlendOutAimCurve);
                }

                state.CurrentBlendOutAimAction = charInterpolatedState.charAction;
                state.TimeSinceReloadStart    += deltaTime;

                CharacterInterpolatedDataFromEntity[animSource.animStateEntity] = charInterpolatedState;
            }).Run();

            return(default);
Exemple #2
0
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            var chunkTranslations = chunk.GetNativeArray(TranslationType);

            for (var i = 0; i < chunk.Count; i++)
            {
                var pos = chunkTranslations[i].Value;
                pos.y = 3.0f * KeyframeCurveEvaluator.Evaluate(Time, ref Curve);

                chunkTranslations[i] = new Translation
                {
                    Value = pos
                };
            }
        }
Exemple #3
0
 public void Execute(ref Translation pos, ref CurveBlobComponent curve)
 {
     pos.Value.y = 3.0f * KeyframeCurveEvaluator.Evaluate(Time, curve.CurveBlobRef);
 }