| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| . | public class FootStep : MonoBehaviour |
| public class FootStep : MonoBehaviour, IMonoUpdater |
| { |
| { |
| private void Start() |
| private void Start() |
| { |
| { |
| this.m_animator = base.GetComponentInChildren<Animator>(); |
| this.m_animator = base.GetComponentInChildren<Animator>(); |
| this.m_character = base.GetComponent<Character>(); |
| this.m_character = base.GetComponent<Character>(); |
| this.m_nview = base.GetComponent<ZNetView>(); |
| this.m_nview = base.GetComponent<ZNetView>(); |
| this.m_footstep = this.m_animator.GetFloat(FootStep.s_footstepID); |
| this.m_footstep = this.m_animator.GetFloat(FootStep.s_footstepID); |
| if (this.m_pieceLayer == 0) |
| if (this.m_pieceLayer == 0) |
| { |
| { |
| this.m_pieceLayer = LayerMask.NameToLayer("piece"); |
| this.m_pieceLayer = LayerMask.NameToLayer("piece"); |
| } |
| } |
| Character character = this.m_character; |
| Character character = this.m_character; |
| character.m_onLand = (Action<Vector3>)Delegate.Combine(character.m_onLand, new Action<Vector3>(this.OnLand)); |
| character.m_onLand = (Action<Vector3>)Delegate.Combine(character.m_onLand, new Action<Vector3>(this.OnLand)); |
| . | |
| this.m_lastPosition = this.m_character.transform.position; |
| if (this.m_nview.IsValid()) |
| if (this.m_nview.IsValid()) |
| { |
| { |
| this.m_nview.Register<int, Vector3>("Step", new Action<long, int, Vector3>(this.RPC_Step)); |
| this.m_nview.Register<int, Vector3>("Step", new Action<long, int, Vector3>(this.RPC_Step)); |
| } |
| } |
| } |
| } |
| |
| |
| private void OnEnable() |
| private void OnEnable() |
| { |
| { |
| FootStep.Instances.Add(this); |
| FootStep.Instances.Add(this); |
| } |
| } |
| |
| |
| private void OnDisable() |
| private void OnDisable() |
| { |
| { |
| FootStep.Instances.Remove(this); |
| FootStep.Instances.Remove(this); |
| } |
| } |
| |
| |
| . | public void CustomUpdate(float dt) |
| public void CustomUpdate(float dt, float time) |
| { |
| { |
| if (this.m_nview == null || !this.m_nview.IsOwner()) |
| if (this.m_nview == null || !this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.UpdateFootstep(dt); |
| this.UpdateFootstep(dt); |
| . | |
| this.UpdateFootlessFootstep(dt); |
| } |
| } |
| |
| |
| private void UpdateFootstep(float dt) |
| private void UpdateFootstep(float dt) |
| { |
| { |
| if (this.m_feet.Length == 0) |
| if (this.m_feet.Length == 0) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| Camera mainCamera = Utils.GetMainCamera(); |
| Camera mainCamera = Utils.GetMainCamera(); |
| if (mainCamera == null) |
| if (mainCamera == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (Vector3.Distance(base.transform.position, mainCamera.transform.position) > this.m_footstepCullDistance) |
| if (Vector3.Distance(base.transform.position, mainCamera.transform.position) > this.m_footstepCullDistance) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.UpdateFootstepCurveTrigger(dt); |
| this.UpdateFootstepCurveTrigger(dt); |
| } |
| } |
| |
| |
| . | |
| private void UpdateFootlessFootstep(float dt) |
| |
| { |
| |
| if (this.m_feet.Length != 0 || !this.m_footlessFootsteps) |
| |
| { |
| |
| return; |
| |
| } |
| |
| Vector3 position = base.transform.position; |
| |
| if (!this.m_character.IsOnGround()) |
| |
| { |
| |
| this.m_distanceAccumulator = 0f; |
| |
| } |
| |
| else |
| |
| { |
| |
| this.m_distanceAccumulator += Vector3.Distance(position, this.m_lastPosition); |
| |
| } |
| |
| this.m_lastPosition = position; |
| |
| if (this.m_distanceAccumulator > this.m_footlessTriggerDistance) |
| |
| { |
| |
| this.m_distanceAccumulator -= this.m_footlessTriggerDistance; |
| |
| this.OnFoot(base.transform); |
| |
| } |
| |
| } |
| |
| |
| private void UpdateFootstepCurveTrigger(float dt) |
| private void UpdateFootstepCurveTrigger(float dt) |
| { |
| { |
| this.m_footstepTimer += dt; |
| this.m_footstepTimer += dt; |
| float @float = this.m_animator.GetFloat(FootStep.s_footstepID); |
| float @float = this.m_animator.GetFloat(FootStep.s_footstepID); |
| if (Utils.SignDiffers(@float, this.m_footstep) && Mathf.Max(Mathf.Abs(this.m_animator.GetFloat(FootStep.s_forwardSpeedID)), Mathf.Abs(this.m_animator.GetFloat(FootStep.s_sidewaySpeedID))) > 0.2f && this.m_footstepTimer > 0.2f) |
| if (Utils.SignDiffers(@float, this.m_footstep) && Mathf.Max(Mathf.Abs(this.m_animator.GetFloat(FootStep.s_forwardSpeedID)), Mathf.Abs(this.m_animator.GetFloat(FootStep.s_sidewaySpeedID))) > 0.2f && this.m_footstepTimer > 0.2f) |
| { |
| { |
| this.m_footstepTimer = 0f; |
| this.m_footstepTimer = 0f; |
| this.OnFoot(); |
| this.OnFoot(); |
| } |
| } |
| this.m_footstep = @float; |
| this.m_footstep = @float; |
| } |
| } |
| |
| |
| private Transform FindActiveFoot() |
| private Transform FindActiveFoot() |
| { |
| { |
| Transform transform = null; |
| Transform transform = null; |
| float num = 9999f; |
| float num = 9999f; |
| Vector3 forward = base.transform.forward; |
| Vector3 forward = base.transform.forward; |
| foreach (Transform transform2 in this.m_feet) |
| foreach (Transform transform2 in this.m_feet) |
| { |
| { |
| if (!(transform2 == null)) |
| if (!(transform2 == null)) |
| { |
| { |
| Vector3 vector = transform2.position - base.transform.position; |
| Vector3 vector = transform2.position - base.transform.position; |
| float num2 = Vector3.Dot(forward, vector); |
| float num2 = Vector3.Dot(forward, vector); |
| if (num2 > num || transform == null) |
| if (num2 > num || transform == null) |
| { |
| { |
| transform = transform2; |
| transform = transform2; |
| num = num2; |
| num = num2; |
| } |
| } |
| } |
| } |
| } |
| } |
| return transform; |
| return transform; |
| } |
| } |
| |
| |
| private Transform FindFoot(string name) |
| private Transform FindFoot(string name) |
| { |
| { |
| foreach (Transform transform in this.m_feet) |
| foreach (Transform transform in this.m_feet) |
| { |
| { |
| if (transform.gameObject.name == name) |
| if (transform.gameObject.name == name) |
| { |
| { |
| return transform; |
| return transform; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| public void OnFoot() |
| public void OnFoot() |
| { |
| { |
| Transform transform = this.FindActiveFoot(); |
| Transform transform = this.FindActiveFoot(); |
| this.OnFoot(transform); |
| this.OnFoot(transform); |
| } |
| } |
| |
| |
| public void OnFoot(string name) |
| public void OnFoot(string name) |
| { |
| { |
| Transform transform = this.FindFoot(name); |
| Transform transform = this.FindFoot(name); |
| if (transform == null) |
| if (transform == null) |
| { |
| { |
| ZLog.LogWarning("FAiled to find foot:" + name); |
| ZLog.LogWarning("FAiled to find foot:" + name); |
| return; |
| return; |
| } |
| } |
| this.OnFoot(transform); |
| this.OnFoot(transform); |
| } |
| } |
| |
| |
| private void OnLand(Vector3 point) |
| private void OnLand(Vector3 point) |
| { |
| { |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| FootStep.GroundMaterial groundMaterial = this.GetGroundMaterial(this.m_character, point); |
| FootStep.GroundMaterial groundMaterial = this.GetGroundMaterial(this.m_character, point); |
| int num = this.FindBestStepEffect(groundMaterial, FootStep.MotionType.Land); |
| int num = this.FindBestStepEffect(groundMaterial, FootStep.MotionType.Land); |
| if (num != -1) |
| if (num != -1) |
| { |
| { |
| this.m_nview.InvokeRPC(ZNetView.Everybody, "Step", new object[] { num, point }); |
| this.m_nview.InvokeRPC(ZNetView.Everybody, "Step", new object[] { num, point }); |
| } |
| } |
| } |
| } |
| |
| |
| private void OnFoot(Transform foot) |
| private void OnFoot(Transform foot) |
| { |
| { |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| Vector3 vector = ((foot != null) ? foot.position : base.transform.position); |
| Vector3 vector = ((foot != null) ? foot.position : base.transform.position); |
| FootStep.MotionType motionType = FootStep.GetMotionType(this.m_character); |
| FootStep.MotionType motionType = FootStep.GetMotionType(this.m_character); |
| FootStep.GroundMaterial groundMaterial = this.GetGroundMaterial(this.m_character, vector); |
| FootStep.GroundMaterial groundMaterial = this.GetGroundMaterial(this.m_character, vector); |
| int num = this.FindBestStepEffect(groundMaterial, motionType); |
| int num = this.FindBestStepEffect(groundMaterial, motionType); |
| if (num != -1) |
| if (num != -1) |
| { |
| { |
| this.m_nview.InvokeRPC(ZNetView.Everybody, "Step", new object[] { num, vector }); |
| this.m_nview.InvokeRPC(ZNetView.Everybody, "Step", new object[] { num, vector }); |
| } |
| } |
| } |
| } |
| |
| |
| private static void PurgeOldEffects() |
| private static void PurgeOldEffects() |
| { |
| { |
| while (FootStep.s_stepInstances.Count > 30) |
| while (FootStep.s_stepInstances.Count > 30) |
| { |
| { |
| GameObject gameObject = FootStep.s_stepInstances.Dequeue(); |
| GameObject gameObject = FootStep.s_stepInstances.Dequeue(); |
| if (gameObject) |
| if (gameObject) |
| { |
| { |
| UnityEngine.Object.Destroy(gameObject); |
| UnityEngine.Object.Destroy(gameObject); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| private void DoEffect(FootStep.StepEffect effect, Vector3 point) |
| private void DoEffect(FootStep.StepEffect effect, Vector3 point) |
| { |
| { |
| foreach (GameObject gameObject in effect.m_effectPrefabs) |
| foreach (GameObject gameObject in effect.m_effectPrefabs) |
| { |
| { |
| GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject, point, base.transform.rotation); |
| GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject, point, base.transform.rotation); |
| FootStep.s_stepInstances.Enqueue(gameObject2); |
| FootStep.s_stepInstances.Enqueue(gameObject2); |
| if (gameObject2.GetComponent<ZNetView>() != null) |
| if (gameObject2.GetComponent<ZNetView>() != null) |
| { |
| { |
| ZLog.LogWarning(string.Concat(new string[] |
| ZLog.LogWarning(string.Concat(new string[] |
| { |
| { |
| "Foot step effect ", |
| "Foot step effect ", |
| effect.m_name, |
| effect.m_name, |
| " prefab ", |
| " prefab ", |
| gameObject.name, |
| gameObject.name, |
| " in ", |
| " in ", |
| this.m_character.gameObject.name, |
| this.m_character.gameObject.name, |
| " should not contain a ZNetView component" |
| " should not contain a ZNetView component" |
| })); |
| })); |
| } |
| } |
| } |
| } |
| FootStep.PurgeOldEffects(); |
| FootStep.PurgeOldEffects(); |
| } |
| } |
| |
| |
| private void RPC_Step(long sender, int effectIndex, Vector3 point) |
| private void RPC_Step(long sender, int effectIndex, Vector3 point) |
| { |
| { |
| FootStep.StepEffect stepEffect = this.m_effects[effectIndex]; |
| FootStep.StepEffect stepEffect = this.m_effects[effectIndex]; |
| this.DoEffect(stepEffect, point); |
| this.DoEffect(stepEffect, point); |
| } |
| } |
| |
| |
| private static FootStep.MotionType GetMotionType(Character character) |
| private static FootStep.MotionType GetMotionType(Character character) |
| { |
| { |
| if (character.IsWalking()) |
| if (character.IsWalking()) |
| { |
| { |
| return FootStep.MotionType.Walk; |
| return FootStep.MotionType.Walk; |
| } |
| } |
| if (character.IsSwimming()) |
| if (character.IsSwimming()) |
| { |
| { |
| return FootStep.MotionType.Swimming; |
| return FootStep.MotionType.Swimming; |
| } |
| } |
| if (character.IsWallRunning()) |
| if (character.IsWallRunning()) |
| { |
| { |
| return FootStep.MotionType.Climbing; |
| return FootStep.MotionType.Climbing; |
| } |
| } |
| if (character.IsRunning()) |
| if (character.IsRunning()) |
| { |
| { |
| return FootStep.MotionType.Run; |
| return FootStep.MotionType.Run; |
| } |
| } |
| if (character.IsSneaking()) |
| if (character.IsSneaking()) |
| { |
| { |
| return FootStep.MotionType.Sneak; |
| return FootStep.MotionType.Sneak; |
| } |
| } |
| return FootStep.MotionType.Jog; |
| return FootStep.MotionType.Jog; |
| } |
| } |
| |
| |
| private FootStep.GroundMaterial GetGroundMaterial(Character character, Vector3 point) |
| private FootStep.GroundMaterial GetGroundMaterial(Character character, Vector3 point) |
| { |
| { |
| if (character.InWater()) |
| if (character.InWater()) |
| { |
| { |
| return FootStep.GroundMaterial.Water; |
| return FootStep.GroundMaterial.Water; |
| } |
| } |
| if (character.InLiquid()) |
| if (character.InLiquid()) |
| { |
| { |
| return FootStep.GroundMaterial.Tar; |
| return FootStep.GroundMaterial.Tar; |
| } |
| } |
| . | if (!character.IsOnGround()) |
| |
| { |
| |
| return FootStep.GroundMaterial.None; |
| |
| } |
| |
| Collider lastGroundCollider = character.GetLastGroundCollider(); |
| Collider lastGroundCollider = character.GetLastGroundCollider(); |
| if (lastGroundCollider == null) |
| if (lastGroundCollider == null) |
| { |
| { |
| return FootStep.GroundMaterial.Default; |
| return FootStep.GroundMaterial.Default; |
| } |
| } |
| Heightmap component = lastGroundCollider.GetComponent<Heightmap>(); |
| Heightmap component = lastGroundCollider.GetComponent<Heightmap>(); |
| if (component != null) |
| if (component != null) |
| { |
| { |
| . | float num = Mathf.Acos(Mathf.Clamp01(character.GetLastGroundNormal().y)) * 57.29578f; |
| Vector3 lastGroundNormal = character.GetLastGroundNormal(); |
| Heightmap.Biome biome = component.GetBiome(point); |
| return component.GetGroundMaterial(lastGroundNormal, point, 0.6f); |
| if (biome == Heightmap.Biome.Mountain || biome == Heightmap.Biome.DeepNorth) |
| |
| { |
| |
| if (num < 40f && !component.IsCleared(point)) |
| |
| { |
| |
| return FootStep.GroundMaterial.Snow; |
| |
| } |
| |
| } |
| |
| else if (biome == Heightmap.Biome.Swamp) |
| |
| { |
| |
| if (num < 40f) |
| |
| { |
| |
| return FootStep.GroundMaterial.Mud; |
| |
| } |
| |
| } |
| |
| else if ((biome == Heightmap.Biome.Meadows || biome == Heightmap.Biome.BlackForest) && num < 25f) |
| |
| { |
| |
| return FootStep.GroundMaterial.Grass; |
| |
| } |
| |
| return FootStep.GroundMaterial.GenericGround; |
| |
| } |
| } |
| if (lastGroundCollider.gameObject.layer != this.m_pieceLayer) |
| if (lastGroundCollider.gameObject.layer != this.m_pieceLayer) |
| { |
| { |
| return FootStep.GroundMaterial.Default; |
| return FootStep.GroundMaterial.Default; |
| } |
| } |
| WearNTear componentInParent = lastGroundCollider.GetComponentInParent<WearNTear>(); |
| WearNTear componentInParent = lastGroundCollider.GetComponentInParent<WearNTear>(); |
| if (!componentInParent) |
| if (!componentInParent) |
| { |
| { |
| return FootStep.GroundMaterial.Default; |
| return FootStep.GroundMaterial.Default; |
| } |
| } |
| switch (componentInParent.m_materialType) |
| switch (componentInParent.m_materialType) |
| { |
| { |
| case WearNTear.MaterialType.Wood: |
| case WearNTear.MaterialType.Wood: |
| return FootStep.GroundMaterial.Wood; |
| return FootStep.GroundMaterial.Wood; |
| case WearNTear.MaterialType.Stone: |
| case WearNTear.MaterialType.Stone: |
| case WearNTear.MaterialType.Marble: |
| case WearNTear.MaterialType.Marble: |
| return FootStep.GroundMaterial.Stone; |
| return FootStep.GroundMaterial.Stone; |
| case WearNTear.MaterialType.Iron: |
| case WearNTear.MaterialType.Iron: |
| return FootStep.GroundMaterial.Metal; |
| return FootStep.GroundMaterial.Metal; |
| case WearNTear.MaterialType.HardWood: |
| case WearNTear.MaterialType.HardWood: |
| return FootStep.GroundMaterial.Wood; |
| return FootStep.GroundMaterial.Wood; |
| default: |
| default: |
| return FootStep.GroundMaterial.Default; |
| return FootStep.GroundMaterial.Default; |
| } |
| } |
| } |
| } |
| |
| |
| public void FindJoints() |
| public void FindJoints() |
| { |
| { |
| ZLog.Log("Finding joints"); |
| ZLog.Log("Finding joints"); |
| Transform transform = Utils.FindChild(base.transform, "LeftFootFront", Utils.IterativeSearchType.DepthFirst); |
| Transform transform = Utils.FindChild(base.transform, "LeftFootFront", Utils.IterativeSearchType.DepthFirst); |
| Transform transform2 = Utils.FindChild(base.transform, "RightFootFront", Utils.IterativeSearchType.DepthFirst); |
| Transform transform2 = Utils.FindChild(base.transform, "RightFootFront", Utils.IterativeSearchType.DepthFirst); |
| Transform transform3 = Utils.FindChild(base.transform, "LeftFoot", Utils.IterativeSearchType.DepthFirst); |
| Transform transform3 = Utils.FindChild(base.transform, "LeftFoot", Utils.IterativeSearchType.DepthFirst); |
| if (transform3 == null) |
| if (transform3 == null) |
| { |
| { |
| transform3 = Utils.FindChild(base.transform, "LeftFootBack", Utils.IterativeSearchType.DepthFirst); |
| transform3 = Utils.FindChild(base.transform, "LeftFootBack", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform3 == null) |
| if (transform3 == null) |
| { |
| { |
| transform3 = Utils.FindChild(base.transform, "l_foot", Utils.IterativeSearchType.DepthFirst); |
| transform3 = Utils.FindChild(base.transform, "l_foot", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform3 == null) |
| if (transform3 == null) |
| { |
| { |
| transform3 = Utils.FindChild(base.transform, "Foot.l", Utils.IterativeSearchType.DepthFirst); |
| transform3 = Utils.FindChild(base.transform, "Foot.l", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform3 == null) |
| if (transform3 == null) |
| { |
| { |
| transform3 = Utils.FindChild(base.transform, "foot.l", Utils.IterativeSearchType.DepthFirst); |
| transform3 = Utils.FindChild(base.transform, "foot.l", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| Transform transform4 = Utils.FindChild(base.transform, "RightFoot", Utils.IterativeSearchType.DepthFirst); |
| Transform transform4 = Utils.FindChild(base.transform, "RightFoot", Utils.IterativeSearchType.DepthFirst); |
| if (transform4 == null) |
| if (transform4 == null) |
| { |
| { |
| transform4 = Utils.FindChild(base.transform, "RightFootBack", Utils.IterativeSearchType.DepthFirst); |
| transform4 = Utils.FindChild(base.transform, "RightFootBack", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform4 == null) |
| if (transform4 == null) |
| { |
| { |
| transform4 = Utils.FindChild(base.transform, "r_foot", Utils.IterativeSearchType.DepthFirst); |
| transform4 = Utils.FindChild(base.transform, "r_foot", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform4 == null) |
| if (transform4 == null) |
| { |
| { |
| transform4 = Utils.FindChild(base.transform, "Foot.r", Utils.IterativeSearchType.DepthFirst); |
| transform4 = Utils.FindChild(base.transform, "Foot.r", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| if (transform4 == null) |
| if (transform4 == null) |
| { |
| { |
| transform4 = Utils.FindChild(base.transform, "foot.r", Utils.IterativeSearchType.DepthFirst); |
| transform4 = Utils.FindChild(base.transform, "foot.r", Utils.IterativeSearchType.DepthFirst); |
| } |
| } |
| List<Transform> list = new List<Transform>(); |
| List<Transform> list = new List<Transform>(); |
| if (transform) |
| if (transform) |
| { |
| { |
| list.Add(transform); |
| list.Add(transform); |
| } |
| } |
| if (transform2) |
| if (transform2) |
| { |
| { |
| list.Add(transform2); |
| list.Add(transform2); |
| } |
| } |
| if (transform3) |
| if (transform3) |
| { |
| { |
| list.Add(transform3); |
| list.Add(transform3); |
| } |
| } |
| if (transform4) |
| if (transform4) |
| { |
| { |
| list.Add(transform4); |
| list.Add(transform4); |
| } |
| } |
| this.m_feet = list.ToArray(); |
| this.m_feet = list.ToArray(); |
| } |
| } |
| |
| |
| private int FindBestStepEffect(FootStep.GroundMaterial material, FootStep.MotionType motion) |
| private int FindBestStepEffect(FootStep.GroundMaterial material, FootStep.MotionType motion) |
| { |
| { |
| FootStep.StepEffect stepEffect = null; |
| FootStep.StepEffect stepEffect = null; |
| int num = -1; |
| int num = -1; |
| for (int i = 0; i < this.m_effects.Count; i++) |
| for (int i = 0; i < this.m_effects.Count; i++) |
| { |
| { |
| FootStep.StepEffect stepEffect2 = this.m_effects[i]; |
| FootStep.StepEffect stepEffect2 = this.m_effects[i]; |
| if (((stepEffect2.m_material & material) != FootStep.GroundMaterial.None || (stepEffect == null && (stepEffect2.m_material & FootStep.GroundMaterial.Default) != FootStep.GroundMaterial.None)) && (stepEffect2.m_motionType & motion) != (FootStep.MotionType)0) |
| if (((stepEffect2.m_material & material) != FootStep.GroundMaterial.None || (stepEffect == null && (stepEffect2.m_material & FootStep.GroundMaterial.Default) != FootStep.GroundMaterial.None)) && (stepEffect2.m_motionType & motion) != (FootStep.MotionType)0) |
| { |
| { |
| stepEffect = stepEffect2; |
| stepEffect = stepEffect2; |
| num = i; |
| num = i; |
| } |
| } |
| } |
| } |
| return num; |
| return num; |
| } |
| } |
| |
| |
| . | public static List<FootStep> Instances { get; } = new List<FootStep>(); |
| public static List<IMonoUpdater> Instances { get; } = new List<IMonoUpdater>(); |
| |
| |
| |
| [Header("Footless")] |
| |
| public bool m_footlessFootsteps; |
| |
| |
| . | |
| public float m_footlessTriggerDistance = 1f; |
| |
| |
| |
| [Space(16f)] |
| public float m_footstepCullDistance = 20f; |
| public float m_footstepCullDistance = 20f; |
| |
| |
| public List<FootStep.StepEffect> m_effects = new List<FootStep.StepEffect>(); |
| public List<FootStep.StepEffect> m_effects = new List<FootStep.StepEffect>(); |
| |
| |
| public Transform[] m_feet = Array.Empty<Transform>(); |
| public Transform[] m_feet = Array.Empty<Transform>(); |
| |
| |
| private static readonly int s_footstepID = ZSyncAnimation.GetHash("footstep"); |
| private static readonly int s_footstepID = ZSyncAnimation.GetHash("footstep"); |
| |
| |
| private static readonly int s_forwardSpeedID = ZSyncAnimation.GetHash("forward_speed"); |
| private static readonly int s_forwardSpeedID = ZSyncAnimation.GetHash("forward_speed"); |
| |
| |
| private static readonly int s_sidewaySpeedID = ZSyncAnimation.GetHash("sideway_speed"); |
| private static readonly int s_sidewaySpeedID = ZSyncAnimation.GetHash("sideway_speed"); |
| |
| |
| private static readonly Queue<GameObject> s_stepInstances = new Queue<GameObject>(); |
| private static readonly Queue<GameObject> s_stepInstances = new Queue<GameObject>(); |
| |
| |
| private float m_footstep; |
| private float m_footstep; |
| |
| |
| private float m_footstepTimer; |
| private float m_footstepTimer; |
| |
| |
| private int m_pieceLayer; |
| private int m_pieceLayer; |
| |
| |
| . | |
| private float m_distanceAccumulator; |
| |
| |
| |
| private Vector3 m_lastPosition; |
| |
| |
| private const float c_MinFootstepInterval = 0.2f; |
| private const float c_MinFootstepInterval = 0.2f; |
| |
| |
| private const int c_MaxFootstepInstances = 30; |
| private const int c_MaxFootstepInstances = 30; |
| |
| |
| private Animator m_animator; |
| private Animator m_animator; |
| |
| |
| private Character m_character; |
| private Character m_character; |
| |
| |
| private ZNetView m_nview; |
| private ZNetView m_nview; |
| |
| |
| [Flags] |
| [Flags] |
| public enum MotionType |
| public enum MotionType |
| { |
| { |
| Jog = 1, |
| Jog = 1, |
| Run = 2, |
| Run = 2, |
| Sneak = 4, |
| Sneak = 4, |
| Climbing = 8, |
| Climbing = 8, |
| Swimming = 16, |
| Swimming = 16, |
| Land = 32, |
| Land = 32, |
| Walk = 64 |
| Walk = 64 |
| } |
| } |
| |
| |
| [Flags] |
| [Flags] |
| public enum GroundMaterial |
| public enum GroundMaterial |
| { |
| { |
| None = 0, |
| None = 0, |
| Default = 1, |
| Default = 1, |
| Water = 2, |
| Water = 2, |
| Stone = 4, |
| Stone = 4, |
| Wood = 8, |
| Wood = 8, |
| Snow = 16, |
| Snow = 16, |
| Mud = 32, |
| Mud = 32, |
| Grass = 64, |
| Grass = 64, |
| GenericGround = 128, |
| GenericGround = 128, |
| Metal = 256, |
| Metal = 256, |
| . | Tar = 512 |
| Tar = 512, |
| |
| Ashlands = 1024, |
| |
| Lava = 2048, |
| |
| Everything = 4095 |
| } |
| } |
| |
| |
| [Serializable] |
| [Serializable] |
| public class StepEffect |
| public class StepEffect |
| { |
| { |
| public string m_name = ""; |
| public string m_name = ""; |
| |
| |
| [BitMask(typeof(FootStep.MotionType))] |
| [BitMask(typeof(FootStep.MotionType))] |
| public FootStep.MotionType m_motionType = FootStep.MotionType.Jog; |
| public FootStep.MotionType m_motionType = FootStep.MotionType.Jog; |
| |
| |
| [BitMask(typeof(FootStep.GroundMaterial))] |
| [BitMask(typeof(FootStep.GroundMaterial))] |
| public FootStep.GroundMaterial m_material = FootStep.GroundMaterial.Default; |
| public FootStep.GroundMaterial m_material = FootStep.GroundMaterial.Default; |
| |
| |
| public GameObject[] m_effectPrefabs = Array.Empty<GameObject>(); |
| public GameObject[] m_effectPrefabs = Array.Empty<GameObject>(); |
| } |
| } |
| } |
| } |
| |
| |