public void Execute(ref SpriteAnimComponent animComp, [ReadOnly] ref VelocityComponent velocityComp, [ReadOnly] ref ForceStateComponent forceStateComp) { if (ForceState.None != (ForceState)forceStateComp.state) { animComp.hash = StatePreset.GetStateHash(StatePreset.Type.SomethingDoIt); return; } var stateType = (math.FLT_MIN_NORMAL > math.abs(velocityComp.velocity.x)) ? StatePreset.Type.Idle : StatePreset.Type.Walk; animComp.hash = StatePreset.GetStateHash(stateType); }
protected override void OnUpdate() { var delta = Time.deltaTime; Entities.ForEach((AudioClipComponent audioClipComp, ref SpriteAnimComponent animComp, ref Translation posComp, ref FootfallComponent footfallComp) => { if (animComp.hash != StatePreset.GetStateHash(StatePreset.Type.Walk)) { footfallComp.accumTime = 0.0f; return; } footfallComp.accumTime += delta; if (footfallComp.interval <= footfallComp.accumTime) { footfallComp.accumTime = 0.0f; AudioSource.PlayClipAtPoint(audioClipComp.clip, posComp.Value); } }); }