| using System; |
| using System; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Sadle : MonoBehaviour, Interactable, Hoverable, IDoodadController |
| public class Sadle : MonoBehaviour, Interactable, Hoverable, IDoodadController |
| { |
| { |
| private void Awake() |
| private void Awake() |
| { |
| { |
| this.m_character = base.gameObject.GetComponentInParent<Character>(); |
| this.m_character = base.gameObject.GetComponentInParent<Character>(); |
| this.m_nview = this.m_character.GetComponent<ZNetView>(); |
| this.m_nview = this.m_character.GetComponent<ZNetView>(); |
| this.m_tambable = this.m_character.GetComponent<Tameable>(); |
| this.m_tambable = this.m_character.GetComponent<Tameable>(); |
| this.m_monsterAI = this.m_character.GetComponent<MonsterAI>(); |
| this.m_monsterAI = this.m_character.GetComponent<MonsterAI>(); |
| this.m_nview.Register<long>("RequestControl", new Action<long, long>(this.RPC_RequestControl)); |
| this.m_nview.Register<long>("RequestControl", new Action<long, long>(this.RPC_RequestControl)); |
| this.m_nview.Register<long>("ReleaseControl", new Action<long, long>(this.RPC_ReleaseControl)); |
| this.m_nview.Register<long>("ReleaseControl", new Action<long, long>(this.RPC_ReleaseControl)); |
| this.m_nview.Register<bool>("RequestRespons", new Action<long, bool>(this.RPC_RequestRespons)); |
| this.m_nview.Register<bool>("RequestRespons", new Action<long, bool>(this.RPC_RequestRespons)); |
| this.m_nview.Register<Vector3>("RemoveSaddle", new Action<long, Vector3>(this.RPC_RemoveSaddle)); |
| this.m_nview.Register<Vector3>("RemoveSaddle", new Action<long, Vector3>(this.RPC_RemoveSaddle)); |
| this.m_nview.Register<Vector3, int, float>("Controls", new Action<long, Vector3, int, float>(this.RPC_Controls)); |
| this.m_nview.Register<Vector3, int, float>("Controls", new Action<long, Vector3, int, float>(this.RPC_Controls)); |
| } |
| } |
| |
| |
| public bool IsValid() |
| public bool IsValid() |
| { |
| { |
| return this; |
| return this; |
| } |
| } |
| |
| |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private void FixedUpdate() |
| private void FixedUpdate() |
| { |
| { |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.CalculateHaveValidUser(); |
| this.CalculateHaveValidUser(); |
| if (!this.m_character.IsTamed()) |
| if (!this.m_character.IsTamed()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.IsLocalUser()) |
| if (this.IsLocalUser()) |
| { |
| { |
| this.UpdateRidingSkill(Time.fixedDeltaTime); |
| this.UpdateRidingSkill(Time.fixedDeltaTime); |
| } |
| } |
| if (this.m_nview.IsOwner()) |
| if (this.m_nview.IsOwner()) |
| { |
| { |
| float fixedDeltaTime = Time.fixedDeltaTime; |
| float fixedDeltaTime = Time.fixedDeltaTime; |
| this.UpdateStamina(fixedDeltaTime); |
| this.UpdateStamina(fixedDeltaTime); |
| this.UpdateDrown(fixedDeltaTime); |
| this.UpdateDrown(fixedDeltaTime); |
| } |
| } |
| } |
| } |
| |
| |
| private void UpdateDrown(float dt) |
| private void UpdateDrown(float dt) |
| { |
| { |
| if (this.m_character.IsSwimming() && !this.m_character.IsOnGround() && !this.HaveStamina(0f)) |
| if (this.m_character.IsSwimming() && !this.m_character.IsOnGround() && !this.HaveStamina(0f)) |
| { |
| { |
| this.m_drownDamageTimer += dt; |
| this.m_drownDamageTimer += dt; |
| if (this.m_drownDamageTimer > 1f) |
| if (this.m_drownDamageTimer > 1f) |
| { |
| { |
| this.m_drownDamageTimer = 0f; |
| this.m_drownDamageTimer = 0f; |
| float num = Mathf.Ceil(this.m_character.GetMaxHealth() / 20f); |
| float num = Mathf.Ceil(this.m_character.GetMaxHealth() / 20f); |
| HitData hitData = new HitData(); |
| HitData hitData = new HitData(); |
| hitData.m_damage.m_damage = num; |
| hitData.m_damage.m_damage = num; |
| hitData.m_point = this.m_character.GetCenterPoint(); |
| hitData.m_point = this.m_character.GetCenterPoint(); |
| hitData.m_dir = Vector3.down; |
| hitData.m_dir = Vector3.down; |
| hitData.m_pushForce = 10f; |
| hitData.m_pushForce = 10f; |
| hitData.m_hitType = HitData.HitType.Drowning; |
| hitData.m_hitType = HitData.HitType.Drowning; |
| this.m_character.Damage(hitData); |
| this.m_character.Damage(hitData); |
| Vector3 position = base.transform.position; |
| Vector3 position = base.transform.position; |
| position.y = this.m_character.GetLiquidLevel(); |
| position.y = this.m_character.GetLiquidLevel(); |
| this.m_drownEffects.Create(position, base.transform.rotation, null, 1f, -1); |
| this.m_drownEffects.Create(position, base.transform.rotation, null, 1f, -1); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| public bool UpdateRiding(float dt) |
| public bool UpdateRiding(float dt) |
| { |
| { |
| if (!base.isActiveAndEnabled) |
| if (!base.isActiveAndEnabled) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!this.m_character.IsTamed()) |
| if (!this.m_character.IsTamed()) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!this.HaveValidUser()) |
| if (!this.HaveValidUser()) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (this.m_speed == Sadle.Speed.Stop || this.m_controlDir.magnitude == 0f) |
| if (this.m_speed == Sadle.Speed.Stop || this.m_controlDir.magnitude == 0f) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (this.m_speed == Sadle.Speed.Walk || this.m_speed == Sadle.Speed.Run) |
| if (this.m_speed == Sadle.Speed.Walk || this.m_speed == Sadle.Speed.Run) |
| { |
| { |
| if (this.m_speed == Sadle.Speed.Run && !this.HaveStamina(0f)) |
| if (this.m_speed == Sadle.Speed.Run && !this.HaveStamina(0f)) |
| { |
| { |
| this.m_speed = Sadle.Speed.Walk; |
| this.m_speed = Sadle.Speed.Walk; |
| } |
| } |
| this.m_monsterAI.MoveTowards(this.m_controlDir, this.m_speed == Sadle.Speed.Run); |
| this.m_monsterAI.MoveTowards(this.m_controlDir, this.m_speed == Sadle.Speed.Run); |
| float riderSkill = this.GetRiderSkill(); |
| float riderSkill = this.GetRiderSkill(); |
| float num = Mathf.Lerp(1f, 0.5f, riderSkill); |
| float num = Mathf.Lerp(1f, 0.5f, riderSkill); |
| if (this.m_character.IsSwimming()) |
| if (this.m_character.IsSwimming()) |
| { |
| { |
| this.UseStamina(this.m_swimStaminaDrain * num * dt); |
| this.UseStamina(this.m_swimStaminaDrain * num * dt); |
| } |
| } |
| else if (this.m_speed == Sadle.Speed.Run) |
| else if (this.m_speed == Sadle.Speed.Run) |
| { |
| { |
| this.UseStamina(this.m_runStaminaDrain * num * dt); |
| this.UseStamina(this.m_runStaminaDrain * num * dt); |
| } |
| } |
| } |
| } |
| else if (this.m_speed == Sadle.Speed.Turn) |
| else if (this.m_speed == Sadle.Speed.Turn) |
| { |
| { |
| this.m_monsterAI.StopMoving(); |
| this.m_monsterAI.StopMoving(); |
| this.m_character.SetRun(false); |
| this.m_character.SetRun(false); |
| this.m_monsterAI.LookTowards(this.m_controlDir); |
| this.m_monsterAI.LookTowards(this.m_controlDir); |
| } |
| } |
| this.m_monsterAI.ResetRandomMovement(); |
| this.m_monsterAI.ResetRandomMovement(); |
| return true; |
| return true; |
| } |
| } |
| |
| |
| public string GetHoverText() |
| public string GetHoverText() |
| { |
| { |
| if (!this.InUseDistance(Player.m_localPlayer)) |
| if (!this.InUseDistance(Player.m_localPlayer)) |
| { |
| { |
| return Localization.instance.Localize("<color=#888888>$piece_toofar</color>"); |
| return Localization.instance.Localize("<color=#888888>$piece_toofar</color>"); |
| } |
| } |
| string text = Localization.instance.Localize(this.m_hoverText); |
| string text = Localization.instance.Localize(this.m_hoverText); |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use"); |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use"); |
| if (ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive()) |
| if (ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive()) |
| { |
| { |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_AltKeys + $KEY_Use</b></color>] $hud_saddle_remove"); |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_AltKeys + $KEY_Use</b></color>] $hud_saddle_remove"); |
| } |
| } |
| else |
| else |
| { |
| { |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $hud_saddle_remove"); |
| text += Localization.instance.Localize("\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $hud_saddle_remove"); |
| } |
| } |
| return text; |
| return text; |
| } |
| } |
| |
| |
| public string GetHoverName() |
| public string GetHoverName() |
| { |
| { |
| return Localization.instance.Localize(this.m_hoverText); |
| return Localization.instance.Localize(this.m_hoverText); |
| } |
| } |
| |
| |
| public bool Interact(Humanoid character, bool repeat, bool alt) |
| public bool Interact(Humanoid character, bool repeat, bool alt) |
| { |
| { |
| if (repeat) |
| if (repeat) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!this.InUseDistance(character)) |
| if (!this.InUseDistance(character)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!this.m_character.IsTamed()) |
| if (!this.m_character.IsTamed()) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| Player player = character as Player; |
| Player player = character as Player; |
| if (player == null) |
| if (player == null) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (alt) |
| if (alt) |
| { |
| { |
| this.m_nview.InvokeRPC("RemoveSaddle", new object[] { character.transform.position }); |
| this.m_nview.InvokeRPC("RemoveSaddle", new object[] { character.transform.position }); |
| return true; |
| return true; |
| } |
| } |
| this.m_nview.InvokeRPC("RequestControl", new object[] { player.GetZDOID().UserID }); |
| this.m_nview.InvokeRPC("RequestControl", new object[] { player.GetZDOID().UserID }); |
| return false; |
| return false; |
| } |
| } |
| |
| |
| public Character GetCharacter() |
| public Character GetCharacter() |
| { |
| { |
| return this.m_character; |
| return this.m_character; |
| } |
| } |
| |
| |
| public Tameable GetTameable() |
| public Tameable GetTameable() |
| { |
| { |
| return this.m_tambable; |
| return this.m_tambable; |
| } |
| } |
| |
| |
| public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block) |
| public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block) |
| { |
| { |
| if (Player.m_localPlayer == null) |
| if (Player.m_localPlayer == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| float skillFactor = Player.m_localPlayer.GetSkills().GetSkillFactor(Skills.SkillType.Ride); |
| float skillFactor = Player.m_localPlayer.GetSkills().GetSkillFactor(Skills.SkillType.Ride); |
| Sadle.Speed speed = Sadle.Speed.NoChange; |
| Sadle.Speed speed = Sadle.Speed.NoChange; |
| Vector3 vector = Vector3.zero; |
| Vector3 vector = Vector3.zero; |
| if (block || (double)moveDir.z > 0.5 || run) |
| if (block || (double)moveDir.z > 0.5 || run) |
| { |
| { |
| Vector3 vector2 = lookDir; |
| Vector3 vector2 = lookDir; |
| vector2.y = 0f; |
| vector2.y = 0f; |
| vector2.Normalize(); |
| vector2.Normalize(); |
| vector = vector2; |
| vector = vector2; |
| } |
| } |
| if (run) |
| if (run) |
| { |
| { |
| speed = Sadle.Speed.Run; |
| speed = Sadle.Speed.Run; |
| } |
| } |
| else if ((double)moveDir.z > 0.5) |
| else if ((double)moveDir.z > 0.5) |
| { |
| { |
| speed = Sadle.Speed.Walk; |
| speed = Sadle.Speed.Walk; |
| } |
| } |
| else if ((double)moveDir.z < -0.5) |
| else if ((double)moveDir.z < -0.5) |
| { |
| { |
| speed = Sadle.Speed.Stop; |
| speed = Sadle.Speed.Stop; |
| } |
| } |
| else if (block) |
| else if (block) |
| { |
| { |
| speed = Sadle.Speed.Turn; |
| speed = Sadle.Speed.Turn; |
| } |
| } |
| this.m_nview.InvokeRPC("Controls", new object[] |
| this.m_nview.InvokeRPC("Controls", new object[] |
| { |
| { |
| vector, |
| vector, |
| (int)speed, |
| (int)speed, |
| skillFactor |
| skillFactor |
| }); |
| }); |
| } |
| } |
| |
| |
| private void RPC_Controls(long sender, Vector3 rideDir, int rideSpeed, float skill) |
| private void RPC_Controls(long sender, Vector3 rideDir, int rideSpeed, float skill) |
| { |
| { |
| if (!this.m_nview.IsOwner()) |
| if (!this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.m_rideSkill = skill; |
| this.m_rideSkill = skill; |
| if (rideDir != Vector3.zero) |
| if (rideDir != Vector3.zero) |
| { |
| { |
| this.m_controlDir = rideDir; |
| this.m_controlDir = rideDir; |
| } |
| } |
| if (rideSpeed == 4) |
| if (rideSpeed == 4) |
| { |
| { |
| if (this.m_speed == Sadle.Speed.Turn) |
| if (this.m_speed == Sadle.Speed.Turn) |
| { |
| { |
| this.m_speed = Sadle.Speed.Stop; |
| this.m_speed = Sadle.Speed.Stop; |
| } |
| } |
| return; |
| return; |
| } |
| } |
| if (rideSpeed == 3 && (this.m_speed == Sadle.Speed.Walk || this.m_speed == Sadle.Speed.Run)) |
| if (rideSpeed == 3 && (this.m_speed == Sadle.Speed.Walk || this.m_speed == Sadle.Speed.Run)) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.m_speed = (Sadle.Speed)rideSpeed; |
| this.m_speed = (Sadle.Speed)rideSpeed; |
| } |
| } |
| |
| |
| private void UpdateRidingSkill(float dt) |
| private void UpdateRidingSkill(float dt) |
| { |
| { |
| this.m_raiseSkillTimer += dt; |
| this.m_raiseSkillTimer += dt; |
| if (this.m_raiseSkillTimer > 1f) |
| if (this.m_raiseSkillTimer > 1f) |
| { |
| { |
| this.m_raiseSkillTimer = 0f; |
| this.m_raiseSkillTimer = 0f; |
| if (this.m_speed == Sadle.Speed.Run) |
| if (this.m_speed == Sadle.Speed.Run) |
| { |
| { |
| Player.m_localPlayer.RaiseSkill(Skills.SkillType.Ride, 1f); |
| Player.m_localPlayer.RaiseSkill(Skills.SkillType.Ride, 1f); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| private void ResetControlls() |
| private void ResetControlls() |
| { |
| { |
| this.m_controlDir = Vector3.zero; |
| this.m_controlDir = Vector3.zero; |
| this.m_speed = Sadle.Speed.Stop; |
| this.m_speed = Sadle.Speed.Stop; |
| this.m_rideSkill = 0f; |
| this.m_rideSkill = 0f; |
| } |
| } |
| |
| |
| public Component GetControlledComponent() |
| public Component GetControlledComponent() |
| { |
| { |
| return this.m_character; |
| return this.m_character; |
| } |
| } |
| |
| |
| public Vector3 GetPosition() |
| public Vector3 GetPosition() |
| { |
| { |
| return base.transform.position; |
| return base.transform.position; |
| } |
| } |
| |
| |
| private void RPC_RemoveSaddle(long sender, Vector3 userPoint) |
| private void RPC_RemoveSaddle(long sender, Vector3 userPoint) |
| { |
| { |
| if (!this.m_nview.IsOwner()) |
| if (!this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.HaveValidUser()) |
| if (this.HaveValidUser()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.m_tambable.DropSaddle(userPoint); |
| this.m_tambable.DropSaddle(userPoint); |
| } |
| } |
| |
| |
| private void RPC_RequestControl(long sender, long playerID) |
| private void RPC_RequestControl(long sender, long playerID) |
| { |
| { |
| if (!this.m_nview.IsOwner()) |
| if (!this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.CalculateHaveValidUser(); |
| this.CalculateHaveValidUser(); |
| if (this.GetUser() == playerID || !this.HaveValidUser()) |
| if (this.GetUser() == playerID || !this.HaveValidUser()) |
| { |
| { |
| this.m_nview.GetZDO().Set(ZDOVars.s_user, playerID); |
| this.m_nview.GetZDO().Set(ZDOVars.s_user, playerID); |
| this.ResetControlls(); |
| this.ResetControlls(); |
| this.m_nview.InvokeRPC(sender, "RequestRespons", new object[] { true }); |
| this.m_nview.InvokeRPC(sender, "RequestRespons", new object[] { true }); |
| this.m_nview.GetZDO().SetOwner(sender); |
| this.m_nview.GetZDO().SetOwner(sender); |
| return; |
| return; |
| } |
| } |
| this.m_nview.InvokeRPC(sender, "RequestRespons", new object[] { false }); |
| this.m_nview.InvokeRPC(sender, "RequestRespons", new object[] { false }); |
| } |
| } |
| |
| |
| public bool HaveValidUser() |
| public bool HaveValidUser() |
| { |
| { |
| return this.m_haveValidUser; |
| return this.m_haveValidUser; |
| } |
| } |
| |
| |
| private void CalculateHaveValidUser() |
| private void CalculateHaveValidUser() |
| { |
| { |
| this.m_haveValidUser = false; |
| this.m_haveValidUser = false; |
| long user = this.GetUser(); |
| long user = this.GetUser(); |
| if (user == 0L) |
| if (user == 0L) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| foreach (ZDO zdo in ZNet.instance.GetAllCharacterZDOS()) |
| foreach (ZDO zdo in ZNet.instance.GetAllCharacterZDOS()) |
| { |
| { |
| if (zdo.m_uid.UserID == user) |
| if (zdo.m_uid.UserID == user) |
| { |
| { |
| this.m_haveValidUser = Vector3.Distance(zdo.GetPosition(), base.transform.position) < this.m_maxUseRange; |
| this.m_haveValidUser = Vector3.Distance(zdo.GetPosition(), base.transform.position) < this.m_maxUseRange; |
| break; |
| break; |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| private void RPC_ReleaseControl(long sender, long playerID) |
| private void RPC_ReleaseControl(long sender, long playerID) |
| { |
| { |
| if (!this.m_nview.IsOwner()) |
| if (!this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.GetUser() == playerID) |
| if (this.GetUser() == playerID) |
| { |
| { |
| this.m_nview.GetZDO().Set(ZDOVars.s_user, 0L); |
| this.m_nview.GetZDO().Set(ZDOVars.s_user, 0L); |
| this.ResetControlls(); |
| this.ResetControlls(); |
| } |
| } |
| } |
| } |
| |
| |
| private void RPC_RequestRespons(long sender, bool granted) |
| private void RPC_RequestRespons(long sender, bool granted) |
| { |
| { |
| if (!Player.m_localPlayer) |
| if (!Player.m_localPlayer) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (granted) |
| if (granted) |
| { |
| { |
| Player.m_localPlayer.StartDoodadControl(this); |
| Player.m_localPlayer.StartDoodadControl(this); |
| if (this.m_attachPoint != null) |
| if (this.m_attachPoint != null) |
| { |
| { |
| Player.m_localPlayer.AttachStart(this.m_attachPoint, this.m_character.gameObject, false, false, false, this.m_attachAnimation, this.m_detachOffset, null); |
| Player.m_localPlayer.AttachStart(this.m_attachPoint, this.m_character.gameObject, false, false, false, this.m_attachAnimation, this.m_detachOffset, null); |
| return; |
| return; |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| Player.m_localPlayer.Message(MessageHud.MessageType.Center, "$msg_inuse", 0, null); |
| Player.m_localPlayer.Message(MessageHud.MessageType.Center, "$msg_inuse", 0, null); |
| } |
| } |
| } |
| } |
| |
| |
| public void OnUseStop(Player player) |
| public void OnUseStop(Player player) |
| { |
| { |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.m_nview.InvokeRPC("ReleaseControl", new object[] { player.GetZDOID().UserID }); |
| this.m_nview.InvokeRPC("ReleaseControl", new object[] { player.GetZDOID().UserID }); |
| if (this.m_attachPoint != null) |
| if (this.m_attachPoint != null) |
| { |
| { |
| player.AttachStop(); |
| player.AttachStop(); |
| } |
| } |
| } |
| } |
| |
| |
| private bool IsLocalUser() |
| private bool IsLocalUser() |
| { |
| { |
| if (!Player.m_localPlayer) |
| if (!Player.m_localPlayer) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| long user = this.GetUser(); |
| long user = this.GetUser(); |
| return user != 0L && user == Player.m_localPlayer.GetZDOID().UserID; |
| return user != 0L && user == Player.m_localPlayer.GetZDOID().UserID; |
| } |
| } |
| |
| |
| private long GetUser() |
| private long GetUser() |
| { |
| { |
| if (this.m_nview == null || !this.m_nview.IsValid()) |
| if (this.m_nview == null || !this.m_nview.IsValid()) |
| { |
| { |
| return 0L; |
| return 0L; |
| } |
| } |
| return this.m_nview.GetZDO().GetLong(ZDOVars.s_user, 0L); |
| return this.m_nview.GetZDO().GetLong(ZDOVars.s_user, 0L); |
| } |
| } |
| |
| |
| private bool InUseDistance(Humanoid human) |
| private bool InUseDistance(Humanoid human) |
| { |
| { |
| return Vector3.Distance(human.transform.position, this.m_attachPoint.position) < this.m_maxUseRange; |
| return Vector3.Distance(human.transform.position, this.m_attachPoint.position) < this.m_maxUseRange; |
| } |
| } |
| |
| |
| private void UseStamina(float v) |
| private void UseStamina(float v) |
| { |
| { |
| if (v == 0f) |
| if (v == 0f) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (!this.m_nview.IsValid() || !this.m_nview.IsOwner()) |
| if (!this.m_nview.IsValid() || !this.m_nview.IsOwner()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| float num = this.GetStamina(); |
| float num = this.GetStamina(); |
| num -= v; |
| num -= v; |
| if (num < 0f) |
| if (num < 0f) |
| { |
| { |
| num = 0f; |
| num = 0f; |
| } |
| } |
| this.SetStamina(num); |
| this.SetStamina(num); |
| this.m_staminaRegenTimer = 1f; |
| this.m_staminaRegenTimer = 1f; |
| } |
| } |
| |
| |
| private bool HaveStamina(float amount = 0f) |
| private bool HaveStamina(float amount = 0f) |
| { |
| { |
| return this.m_nview.IsValid() && this.GetStamina() > amount; |
| return this.m_nview.IsValid() && this.GetStamina() > amount; |
| } |
| } |
| |
| |
| public float GetStamina() |
| public float GetStamina() |
| { |
| { |
| if (this.m_nview == null) |
| if (this.m_nview == null) |
| { |
| { |
| return 0f; |
| return 0f; |
| } |
| } |
| if (this.m_nview.GetZDO() == null) |
| if (this.m_nview.GetZDO() == null) |
| { |
| { |
| return 0f; |
| return 0f; |
| } |
| } |
| return this.m_nview.GetZDO().GetFloat(ZDOVars.s_stamina, this.GetMaxStamina()); |
| return this.m_nview.GetZDO().GetFloat(ZDOVars.s_stamina, this.GetMaxStamina()); |
| } |
| } |
| |
| |
| private void SetStamina(float stamina) |
| private void SetStamina(float stamina) |
| { |
| { |
| this.m_nview.GetZDO().Set(ZDOVars.s_stamina, stamina); |
| this.m_nview.GetZDO().Set(ZDOVars.s_stamina, stamina); |
| } |
| } |
| |
| |
| public float GetMaxStamina() |
| public float GetMaxStamina() |
| { |
| { |
| return this.m_maxStamina; |
| return this.m_maxStamina; |
| } |
| } |
| |
| |
| private void UpdateStamina(float dt) |
| private void UpdateStamina(float dt) |
| { |
| { |
| this.m_staminaRegenTimer -= dt; |
| this.m_staminaRegenTimer -= dt; |
| if (this.m_staminaRegenTimer > 0f) |
| if (this.m_staminaRegenTimer > 0f) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.m_character.InAttack() || this.m_character.IsSwimming()) |
| if (this.m_character.InAttack() || this.m_character.IsSwimming()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| float num = this.GetStamina(); |
| float num = this.GetStamina(); |
| float maxStamina = this.GetMaxStamina(); |
| float maxStamina = this.GetMaxStamina(); |
| if (num < maxStamina || num > maxStamina) |
| if (num < maxStamina || num > maxStamina) |
| { |
| { |
| float num2 = (this.m_tambable.IsHungry() ? this.m_staminaRegenHungry : this.m_staminaRegen); |
| float num2 = (this.m_tambable.IsHungry() ? this.m_staminaRegenHungry : this.m_staminaRegen); |
| float num3 = num2 + (1f - num / maxStamina) * num2; |
| float num3 = num2 + (1f - num / maxStamina) * num2; |
| num += num3 * dt; |
| num += num3 * dt; |
| if (num > maxStamina) |
| if (num > maxStamina) |
| { |
| { |
| num = maxStamina; |
| num = maxStamina; |
| } |
| } |
| this.SetStamina(num); |
| this.SetStamina(num); |
| } |
| } |
| } |
| } |
| |
| |
| public float GetRiderSkill() |
| public float GetRiderSkill() |
| { |
| { |
| return this.m_rideSkill; |
| return this.m_rideSkill; |
| } |
| } |
| |
| |
| public string m_hoverText = ""; |
| public string m_hoverText = ""; |
| |
| |
| public float m_maxUseRange = 10f; |
| public float m_maxUseRange = 10f; |
| |
| |
| public Transform m_attachPoint; |
| public Transform m_attachPoint; |
| |
| |
| public Vector3 m_detachOffset = new Vector3(0f, 0.5f, 0f); |
| public Vector3 m_detachOffset = new Vector3(0f, 0.5f, 0f); |
| |
| |
| public string m_attachAnimation = "attach_chair"; |
| public string m_attachAnimation = "attach_chair"; |
| |
| |
| public float m_maxStamina = 100f; |
| public float m_maxStamina = 100f; |
| |
| |
| public float m_runStaminaDrain = 10f; |
| public float m_runStaminaDrain = 10f; |
| |
| |
| public float m_swimStaminaDrain = 10f; |
| public float m_swimStaminaDrain = 10f; |
| |
| |
| public float m_staminaRegen = 10f; |
| public float m_staminaRegen = 10f; |
| |
| |
| public float m_staminaRegenHungry = 10f; |
| public float m_staminaRegenHungry = 10f; |
| |
| |
| public EffectList m_drownEffects = new EffectList(); |
| public EffectList m_drownEffects = new EffectList(); |
| |
| |
| . | |
| public Sprite m_mountIcon; |
| |
| |
| private const float m_staminaRegenDelay = 1f; |
| private const float m_staminaRegenDelay = 1f; |
| |
| |
| private Vector3 m_controlDir; |
| private Vector3 m_controlDir; |
| |
| |
| private Sadle.Speed m_speed; |
| private Sadle.Speed m_speed; |
| |
| |
| private float m_rideSkill; |
| private float m_rideSkill; |
| |
| |
| private float m_staminaRegenTimer; |
| private float m_staminaRegenTimer; |
| |
| |
| private float m_drownDamageTimer; |
| private float m_drownDamageTimer; |
| |
| |
| private float m_raiseSkillTimer; |
| private float m_raiseSkillTimer; |
| |
| |
| private Character m_character; |
| private Character m_character; |
| |
| |
| private ZNetView m_nview; |
| private ZNetView m_nview; |
| |
| |
| private Tameable m_tambable; |
| private Tameable m_tambable; |
| |
| |
| private MonsterAI m_monsterAI; |
| private MonsterAI m_monsterAI; |
| |
| |
| private bool m_haveValidUser; |
| private bool m_haveValidUser; |
| |
| |
| private enum Speed |
| private enum Speed |
| { |
| { |
| Stop, |
| Stop, |
| Walk, |
| Walk, |
| Run, |
| Run, |
| Turn, |
| Turn, |
| NoChange |
| NoChange |
| } |
| } |
| } |
| } |
| |
| |