| using System; |
| using System; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Fireplace : MonoBehaviour, Hoverable, Interactable |
| public class Fireplace : MonoBehaviour, Hoverable, Interactable |
| { |
| { |
| public void Awake() |
| public void Awake() |
| { |
| { |
| this.m_nview = base.gameObject.GetComponent<ZNetView>(); |
| this.m_nview = base.gameObject.GetComponent<ZNetView>(); |
| this.m_piece = base.gameObject.GetComponent<Piece>(); |
| this.m_piece = base.gameObject.GetComponent<Piece>(); |
| if (this.m_nview.GetZDO() == null) |
| if (this.m_nview.GetZDO() == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (Fireplace.m_solidRayMask == 0) |
| if (Fireplace.m_solidRayMask == 0) |
| { |
| { |
| Fireplace.m_solidRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece", "terrain" }); |
| Fireplace.m_solidRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece", "terrain" }); |
| } |
| } |
| if (this.m_nview.IsOwner() && this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, -1f) == -1f) |
| if (this.m_nview.IsOwner() && this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, -1f) == -1f) |
| { |
| { |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, this.m_startFuel); |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, this.m_startFuel); |
| if (this.m_startFuel > 0f) |
| if (this.m_startFuel > 0f) |
| { |
| { |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| } |
| } |
| } |
| } |
| . | this.m_nview.Register("AddFuel", new Action<long>(this.RPC_AddFuel)); |
| this.m_nview.Register("RPC_AddFuel", new Action<long>(this.RPC_AddFuel)); |
| |
| this.m_nview.Register<float>("RPC_AddFuelAmount", new Action<long, float>(this.RPC_AddFuelAmount)); |
| |
| this.m_nview.Register<float>("RPC_SetFuelAmount", new Action<long, float>(this.RPC_SetFuelAmount)); |
| base.InvokeRepeating("UpdateFireplace", 0f, 2f); |
| base.InvokeRepeating("UpdateFireplace", 0f, 2f); |
| base.InvokeRepeating("CheckEnv", 4f, 4f); |
| base.InvokeRepeating("CheckEnv", 4f, 4f); |
| . | |
| if (this.m_igniteInterval > 0f && this.m_igniteCapsuleRadius > 0f) |
| |
| { |
| |
| base.InvokeRepeating("UpdateIgnite", this.m_igniteInterval, this.m_igniteInterval); |
| |
| } |
| } |
| } |
| |
| |
| private void Start() |
| private void Start() |
| { |
| { |
| if (this.m_playerBaseObject && this.m_piece) |
| if (this.m_playerBaseObject && this.m_piece) |
| { |
| { |
| this.m_playerBaseObject.SetActive(this.m_piece.IsPlacedByPlayer()); |
| this.m_playerBaseObject.SetActive(this.m_piece.IsPlacedByPlayer()); |
| } |
| } |
| } |
| } |
| |
| |
| private double GetTimeSinceLastUpdate() |
| private double GetTimeSinceLastUpdate() |
| { |
| { |
| DateTime time = ZNet.instance.GetTime(); |
| DateTime time = ZNet.instance.GetTime(); |
| DateTime dateTime = new DateTime(this.m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, time.Ticks)); |
| DateTime dateTime = new DateTime(this.m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, time.Ticks)); |
| TimeSpan timeSpan = time - dateTime; |
| TimeSpan timeSpan = time - dateTime; |
| this.m_nview.GetZDO().Set(ZDOVars.s_lastTime, time.Ticks); |
| this.m_nview.GetZDO().Set(ZDOVars.s_lastTime, time.Ticks); |
| double num = timeSpan.TotalSeconds; |
| double num = timeSpan.TotalSeconds; |
| if (num < 0.0) |
| if (num < 0.0) |
| { |
| { |
| num = 0.0; |
| num = 0.0; |
| } |
| } |
| return num; |
| return num; |
| } |
| } |
| |
| |
| private void UpdateFireplace() |
| private void UpdateFireplace() |
| { |
| { |
| if (!this.m_nview.IsValid()) |
| if (!this.m_nview.IsValid()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.m_nview.IsOwner() && this.m_secPerFuel > 0f) |
| if (this.m_nview.IsOwner() && this.m_secPerFuel > 0f) |
| { |
| { |
| float num = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| float num = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| double timeSinceLastUpdate = this.GetTimeSinceLastUpdate(); |
| double timeSinceLastUpdate = this.GetTimeSinceLastUpdate(); |
| if (this.IsBurning() && !this.m_infiniteFuel) |
| if (this.IsBurning() && !this.m_infiniteFuel) |
| { |
| { |
| float num2 = (float)(timeSinceLastUpdate / (double)this.m_secPerFuel); |
| float num2 = (float)(timeSinceLastUpdate / (double)this.m_secPerFuel); |
| num -= num2; |
| num -= num2; |
| if (num <= 0f) |
| if (num <= 0f) |
| { |
| { |
| num = 0f; |
| num = 0f; |
| } |
| } |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, num); |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, num); |
| } |
| } |
| } |
| } |
| this.UpdateState(); |
| this.UpdateState(); |
| } |
| } |
| |
| |
| private void CheckEnv() |
| private void CheckEnv() |
| { |
| { |
| this.CheckUnderTerrain(); |
| this.CheckUnderTerrain(); |
| if (this.m_enabledObjectLow != null && this.m_enabledObjectHigh != null) |
| if (this.m_enabledObjectLow != null && this.m_enabledObjectHigh != null) |
| { |
| { |
| this.CheckWet(); |
| this.CheckWet(); |
| } |
| } |
| } |
| } |
| |
| |
| private void CheckUnderTerrain() |
| private void CheckUnderTerrain() |
| { |
| { |
| this.m_blocked = false; |
| this.m_blocked = false; |
| float num; |
| float num; |
| if (Heightmap.GetHeight(base.transform.position, out num) && num > base.transform.position.y + this.m_checkTerrainOffset) |
| if (Heightmap.GetHeight(base.transform.position, out num) && num > base.transform.position.y + this.m_checkTerrainOffset) |
| { |
| { |
| this.m_blocked = true; |
| this.m_blocked = true; |
| return; |
| return; |
| } |
| } |
| RaycastHit raycastHit; |
| RaycastHit raycastHit; |
| if (Physics.Raycast(base.transform.position + Vector3.up * this.m_coverCheckOffset, Vector3.up, out raycastHit, 0.5f, Fireplace.m_solidRayMask)) |
| if (Physics.Raycast(base.transform.position + Vector3.up * this.m_coverCheckOffset, Vector3.up, out raycastHit, 0.5f, Fireplace.m_solidRayMask)) |
| { |
| { |
| this.m_blocked = true; |
| this.m_blocked = true; |
| return; |
| return; |
| } |
| } |
| if (this.m_smokeSpawner && this.m_smokeSpawner.IsBlocked()) |
| if (this.m_smokeSpawner && this.m_smokeSpawner.IsBlocked()) |
| { |
| { |
| this.m_blocked = true; |
| this.m_blocked = true; |
| return; |
| return; |
| } |
| } |
| } |
| } |
| |
| |
| private void CheckWet() |
| private void CheckWet() |
| { |
| { |
| float num; |
| float num; |
| bool flag; |
| bool flag; |
| Cover.GetCoverForPoint(base.transform.position + Vector3.up * this.m_coverCheckOffset, out num, out flag, 0.5f); |
| Cover.GetCoverForPoint(base.transform.position + Vector3.up * this.m_coverCheckOffset, out num, out flag, 0.5f); |
| this.m_wet = false; |
| this.m_wet = false; |
| if (EnvMan.instance.GetWindIntensity() >= 0.8f && num < 0.7f) |
| if (EnvMan.instance.GetWindIntensity() >= 0.8f && num < 0.7f) |
| { |
| { |
| this.m_wet = true; |
| this.m_wet = true; |
| } |
| } |
| . | if (EnvMan.instance.IsWet() && !flag) |
| if (EnvMan.IsWet() && !flag) |
| { |
| { |
| this.m_wet = true; |
| this.m_wet = true; |
| } |
| } |
| } |
| } |
| |
| |
| private void UpdateState() |
| private void UpdateState() |
| { |
| { |
| if (this.IsBurning()) |
| if (this.IsBurning()) |
| { |
| { |
| this.m_enabledObject.SetActive(true); |
| this.m_enabledObject.SetActive(true); |
| if (this.m_enabledObjectHigh && this.m_enabledObjectLow) |
| if (this.m_enabledObjectHigh && this.m_enabledObjectLow) |
| { |
| { |
| this.m_enabledObjectHigh.SetActive(!this.m_wet); |
| this.m_enabledObjectHigh.SetActive(!this.m_wet); |
| this.m_enabledObjectLow.SetActive(this.m_wet); |
| this.m_enabledObjectLow.SetActive(this.m_wet); |
| return; |
| return; |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| this.m_enabledObject.SetActive(false); |
| this.m_enabledObject.SetActive(false); |
| if (this.m_enabledObjectHigh && this.m_enabledObjectLow) |
| if (this.m_enabledObjectHigh && this.m_enabledObjectLow) |
| { |
| { |
| this.m_enabledObjectLow.SetActive(false); |
| this.m_enabledObjectLow.SetActive(false); |
| this.m_enabledObjectHigh.SetActive(false); |
| this.m_enabledObjectHigh.SetActive(false); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| public string GetHoverText() |
| public string GetHoverText() |
| { |
| { |
| if (!this.m_nview.IsValid() || this.m_infiniteFuel) |
| if (!this.m_nview.IsValid() || this.m_infiniteFuel) |
| { |
| { |
| return ""; |
| return ""; |
| } |
| } |
| float @float = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| float @float = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| string text = string.Format("{0}\n( $piece_fire_fuel {1}/{2} )\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use {3}\n[<color=yellow><b>1-8</b></color>] $piece_useitem", new object[] |
| string text = string.Format("{0}\n( $piece_fire_fuel {1}/{2} )\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use {3}\n[<color=yellow><b>1-8</b></color>] $piece_useitem", new object[] |
| { |
| { |
| this.m_name, |
| this.m_name, |
| Mathf.Ceil(@float), |
| Mathf.Ceil(@float), |
| (int)this.m_maxFuel, |
| (int)this.m_maxFuel, |
| this.m_fuelItem.m_itemData.m_shared.m_name |
| this.m_fuelItem.m_itemData.m_shared.m_name |
| }); |
| }); |
| return Localization.instance.Localize(text); |
| return Localization.instance.Localize(text); |
| } |
| } |
| |
| |
| public string GetHoverName() |
| public string GetHoverName() |
| { |
| { |
| return this.m_name; |
| return this.m_name; |
| } |
| } |
| |
| |
| . | |
| public void AddFuel(float fuel) |
| |
| { |
| |
| if (!this.m_nview || !this.m_nview.IsValid()) |
| |
| { |
| |
| return; |
| |
| } |
| |
| float @float = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| |
| if ((fuel < 0f && @float > 0f) || (fuel > 0f && @float < this.m_maxFuel)) |
| |
| { |
| |
| this.m_nview.InvokeRPC("RPC_AddFuelAmount", new object[] { fuel }); |
| |
| } |
| |
| } |
| |
| |
| public bool Interact(Humanoid user, bool hold, bool alt) |
| public bool Interact(Humanoid user, bool hold, bool alt) |
| { |
| { |
| if (hold) |
| if (hold) |
| { |
| { |
| if (this.m_holdRepeatInterval <= 0f) |
| if (this.m_holdRepeatInterval <= 0f) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (Time.time - this.m_lastUseTime < this.m_holdRepeatInterval) |
| if (Time.time - this.m_lastUseTime < this.m_holdRepeatInterval) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| } |
| } |
| if (!this.m_nview.HasOwner()) |
| if (!this.m_nview.HasOwner()) |
| { |
| { |
| this.m_nview.ClaimOwnership(); |
| this.m_nview.ClaimOwnership(); |
| } |
| } |
| Inventory inventory = user.GetInventory(); |
| Inventory inventory = user.GetInventory(); |
| if (inventory == null) |
| if (inventory == null) |
| { |
| { |
| return true; |
| return true; |
| } |
| } |
| if (this.m_infiniteFuel) |
| if (this.m_infiniteFuel) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (!inventory.HaveItem(this.m_fuelItem.m_itemData.m_shared.m_name, true)) |
| if (!inventory.HaveItem(this.m_fuelItem.m_itemData.m_shared.m_name, true)) |
| { |
| { |
| user.Message(MessageHud.MessageType.Center, "$msg_outof " + this.m_fuelItem.m_itemData.m_shared.m_name, 0, null); |
| user.Message(MessageHud.MessageType.Center, "$msg_outof " + this.m_fuelItem.m_itemData.m_shared.m_name, 0, null); |
| return false; |
| return false; |
| } |
| } |
| if ((float)Mathf.CeilToInt(this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f)) >= this.m_maxFuel) |
| if ((float)Mathf.CeilToInt(this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f)) >= this.m_maxFuel) |
| { |
| { |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_cantaddmore", new string[] { this.m_fuelItem.m_itemData.m_shared.m_name }), 0, null); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_cantaddmore", new string[] { this.m_fuelItem.m_itemData.m_shared.m_name }), 0, null); |
| return false; |
| return false; |
| } |
| } |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[] { this.m_fuelItem.m_itemData.m_shared.m_name }), 0, null); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[] { this.m_fuelItem.m_itemData.m_shared.m_name }), 0, null); |
| inventory.RemoveItem(this.m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true); |
| inventory.RemoveItem(this.m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true); |
| . | this.m_nview.InvokeRPC("AddFuel", Array.Empty<object>()); |
| this.m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>()); |
| return true; |
| return true; |
| } |
| } |
| |
| |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| { |
| { |
| if (!(item.m_shared.m_name == this.m_fuelItem.m_itemData.m_shared.m_name) || this.m_infiniteFuel) |
| if (!(item.m_shared.m_name == this.m_fuelItem.m_itemData.m_shared.m_name) || this.m_infiniteFuel) |
| { |
| { |
| int i = 0; |
| int i = 0; |
| while (i < this.m_fireworkItemList.Length) |
| while (i < this.m_fireworkItemList.Length) |
| { |
| { |
| if (item.m_shared.m_name == this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name) |
| if (item.m_shared.m_name == this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name) |
| { |
| { |
| if (!this.IsBurning()) |
| if (!this.IsBurning()) |
| { |
| { |
| user.Message(MessageHud.MessageType.Center, "$msg_firenotburning", 0, null); |
| user.Message(MessageHud.MessageType.Center, "$msg_firenotburning", 0, null); |
| return true; |
| return true; |
| } |
| } |
| if (user.GetInventory().CountItems(this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name, -1, true) < this.m_fireworkItemList[i].m_fireworkItemCount) |
| if (user.GetInventory().CountItems(this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name, -1, true) < this.m_fireworkItemList[i].m_fireworkItemCount) |
| { |
| { |
| user.Message(MessageHud.MessageType.Center, "$msg_toofew " + this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name, 0, null); |
| user.Message(MessageHud.MessageType.Center, "$msg_toofew " + this.m_fireworkItemList[i].m_fireworkItem.m_itemData.m_shared.m_name, 0, null); |
| return true; |
| return true; |
| } |
| } |
| user.GetInventory().RemoveItem(item.m_shared.m_name, this.m_fireworkItemList[i].m_fireworkItemCount, -1, true); |
| user.GetInventory().RemoveItem(item.m_shared.m_name, this.m_fireworkItemList[i].m_fireworkItemCount, -1, true); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_throwinfire", new string[] { item.m_shared.m_name }), 0, null); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_throwinfire", new string[] { item.m_shared.m_name }), 0, null); |
| float num = UnityEngine.Random.Range(-this.m_fireworksMaxRandomAngle, this.m_fireworksMaxRandomAngle); |
| float num = UnityEngine.Random.Range(-this.m_fireworksMaxRandomAngle, this.m_fireworksMaxRandomAngle); |
| float num2 = UnityEngine.Random.Range(-this.m_fireworksMaxRandomAngle, this.m_fireworksMaxRandomAngle); |
| float num2 = UnityEngine.Random.Range(-this.m_fireworksMaxRandomAngle, this.m_fireworksMaxRandomAngle); |
| Quaternion quaternion = Quaternion.Euler(num, 0f, num2); |
| Quaternion quaternion = Quaternion.Euler(num, 0f, num2); |
| this.m_fireworkItemList[i].m_fireworksEffects.Create(base.transform.position, quaternion, null, 1f, -1); |
| this.m_fireworkItemList[i].m_fireworksEffects.Create(base.transform.position, quaternion, null, 1f, -1); |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| return true; |
| return true; |
| } |
| } |
| else |
| else |
| { |
| { |
| i++; |
| i++; |
| } |
| } |
| } |
| } |
| return false; |
| return false; |
| } |
| } |
| if ((float)Mathf.CeilToInt(this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f)) >= this.m_maxFuel) |
| if ((float)Mathf.CeilToInt(this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f)) >= this.m_maxFuel) |
| { |
| { |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_cantaddmore", new string[] { item.m_shared.m_name }), 0, null); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_cantaddmore", new string[] { item.m_shared.m_name }), 0, null); |
| return true; |
| return true; |
| } |
| } |
| Inventory inventory = user.GetInventory(); |
| Inventory inventory = user.GetInventory(); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[] { item.m_shared.m_name }), 0, null); |
| user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[] { item.m_shared.m_name }), 0, null); |
| inventory.RemoveItem(item, 1); |
| inventory.RemoveItem(item, 1); |
| . | this.m_nview.InvokeRPC("AddFuel", Array.Empty<object>()); |
| this.m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>()); |
| return true; |
| return true; |
| } |
| } |
| |
| |
| private void RPC_AddFuel(long sender) |
| private void RPC_AddFuel(long sender) |
| { |
| { |
| if (this.m_nview.IsOwner()) |
| if (this.m_nview.IsOwner()) |
| { |
| { |
| float num = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| float num = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| if ((float)Mathf.CeilToInt(num) >= this.m_maxFuel) |
| if ((float)Mathf.CeilToInt(num) >= this.m_maxFuel) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| num = Mathf.Clamp(num, 0f, this.m_maxFuel); |
| num = Mathf.Clamp(num, 0f, this.m_maxFuel); |
| num += 1f; |
| num += 1f; |
| num = Mathf.Clamp(num, 0f, this.m_maxFuel); |
| num = Mathf.Clamp(num, 0f, this.m_maxFuel); |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, num); |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, num); |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| this.UpdateState(); |
| this.UpdateState(); |
| } |
| } |
| } |
| } |
| |
| |
| . | |
| private void RPC_AddFuelAmount(long sender, float amount) |
| |
| { |
| |
| if (this.m_nview.IsOwner()) |
| |
| { |
| |
| float num = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| |
| num = Mathf.Clamp(num + amount, 0f, this.m_maxFuel); |
| |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, num); |
| |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| |
| this.UpdateState(); |
| |
| } |
| |
| } |
| |
| |
| |
| public void SetFuel(float fuel) |
| |
| { |
| |
| if (!this.m_nview || !this.m_nview.IsValid()) |
| |
| { |
| |
| return; |
| |
| } |
| |
| float @float = this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f); |
| |
| fuel = Mathf.Clamp(fuel, 0f, this.m_maxFuel); |
| |
| if (fuel != @float) |
| |
| { |
| |
| this.m_nview.InvokeRPC("RPC_SetFuelAmount", new object[] { fuel }); |
| |
| } |
| |
| } |
| |
| |
| |
| private void RPC_SetFuelAmount(long sender, float fuel) |
| |
| { |
| |
| if (this.m_nview.IsOwner()) |
| |
| { |
| |
| this.m_nview.GetZDO().Set(ZDOVars.s_fuel, fuel); |
| |
| this.m_fuelAddedEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| |
| this.UpdateState(); |
| |
| } |
| |
| } |
| |
| |
| public bool CanBeRemoved() |
| public bool CanBeRemoved() |
| { |
| { |
| return !this.IsBurning(); |
| return !this.IsBurning(); |
| } |
| } |
| |
| |
| public bool IsBurning() |
| public bool IsBurning() |
| { |
| { |
| if (this.m_blocked) |
| if (this.m_blocked) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| float liquidLevel = Floating.GetLiquidLevel(this.m_enabledObject.transform.position, 1f, LiquidType.All); |
| float liquidLevel = Floating.GetLiquidLevel(this.m_enabledObject.transform.position, 1f, LiquidType.All); |
| return this.m_enabledObject.transform.position.y >= liquidLevel && (this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f) > 0f || this.m_infiniteFuel); |
| return this.m_enabledObject.transform.position.y >= liquidLevel && (this.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f) > 0f || this.m_infiniteFuel); |
| } |
| } |
| |
| |
| private void OnDrawGizmosSelected() |
| private void OnDrawGizmosSelected() |
| { |
| { |
| Gizmos.color = Color.white; |
| Gizmos.color = Color.white; |
| Gizmos.DrawWireSphere(base.transform.position + Vector3.up * this.m_coverCheckOffset, 0.5f); |
| Gizmos.DrawWireSphere(base.transform.position + Vector3.up * this.m_coverCheckOffset, 0.5f); |
| Gizmos.color = Color.yellow; |
| Gizmos.color = Color.yellow; |
| Gizmos.DrawWireCube(base.transform.position + Vector3.up * this.m_checkTerrainOffset, new Vector3(1f, 0.01f, 1f)); |
| Gizmos.DrawWireCube(base.transform.position + Vector3.up * this.m_checkTerrainOffset, new Vector3(1f, 0.01f, 1f)); |
| . | |
| Gizmos.color = Color.red; |
| |
| Utils.DrawGizmoCapsule(base.transform.position + this.m_igniteCapsuleStart, base.transform.position + this.m_igniteCapsuleEnd, this.m_igniteCapsuleRadius); |
| |
| } |
| |
| |
| |
| private void UpdateIgnite() |
| |
| { |
| |
| if (!this.m_nview.IsValid() || !this.m_nview.IsOwner()) |
| |
| { |
| |
| return; |
| |
| } |
| |
| if (!this.m_firePrefab) |
| |
| { |
| |
| return; |
| |
| } |
| |
| if (!this.CanIgnite()) |
| |
| { |
| |
| return; |
| |
| } |
| |
| if (!this.IsBurning()) |
| |
| { |
| |
| return; |
| |
| } |
| |
| int num = Physics.OverlapCapsuleNonAlloc(base.transform.position + this.m_igniteCapsuleStart, base.transform.position + this.m_igniteCapsuleEnd, this.m_igniteCapsuleRadius, Fireplace.s_tempColliders); |
| |
| for (int i = 0; i < num; i++) |
| |
| { |
| |
| Collider collider = Fireplace.s_tempColliders[i]; |
| |
| bool flag; |
| |
| if (!(collider.gameObject == base.gameObject) && (!(collider.transform.parent != null) || !(collider.transform.parent.gameObject == base.gameObject)) && !collider.isTrigger && UnityEngine.Random.Range(0f, 1f) <= this.m_igniteChance && Cinder.CanBurn(collider, collider.transform.position, out flag, 0f)) |
| |
| { |
| |
| CinderSpawner component = UnityEngine.Object.Instantiate<GameObject>(this.m_firePrefab, collider.transform.position + Utils.RandomVector3(-0.1f, 0.1f), Quaternion.identity).GetComponent<CinderSpawner>(); |
| |
| if (component != null) |
| |
| { |
| |
| component.Setup(this.m_igniteSpread, collider.gameObject); |
| |
| } |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| public bool CanIgnite() |
| |
| { |
| |
| return CinderSpawner.CanSpawnCinder(base.transform, ref this.m_biome); |
| } |
| } |
| |
| |
| private ZNetView m_nview; |
| private ZNetView m_nview; |
| |
| |
| private Piece m_piece; |
| private Piece m_piece; |
| |
| |
| [Header("Fire")] |
| [Header("Fire")] |
| public string m_name = "Fire"; |
| public string m_name = "Fire"; |
| |
| |
| public float m_startFuel = 3f; |
| public float m_startFuel = 3f; |
| |
| |
| public float m_maxFuel = 10f; |
| public float m_maxFuel = 10f; |
| |
| |
| public float m_secPerFuel = 3f; |
| public float m_secPerFuel = 3f; |
| |
| |
| public bool m_infiniteFuel; |
| public bool m_infiniteFuel; |
| |
| |
| public float m_checkTerrainOffset = 0.2f; |
| public float m_checkTerrainOffset = 0.2f; |
| |
| |
| public float m_coverCheckOffset = 0.5f; |
| public float m_coverCheckOffset = 0.5f; |
| |
| |
| private const float m_minimumOpenSpace = 0.5f; |
| private const float m_minimumOpenSpace = 0.5f; |
| |
| |
| public float m_holdRepeatInterval = 0.2f; |
| public float m_holdRepeatInterval = 0.2f; |
| |
| |
| public GameObject m_enabledObject; |
| public GameObject m_enabledObject; |
| |
| |
| public GameObject m_enabledObjectLow; |
| public GameObject m_enabledObjectLow; |
| |
| |
| public GameObject m_enabledObjectHigh; |
| public GameObject m_enabledObjectHigh; |
| |
| |
| public GameObject m_playerBaseObject; |
| public GameObject m_playerBaseObject; |
| |
| |
| public ItemDrop m_fuelItem; |
| public ItemDrop m_fuelItem; |
| |
| |
| public SmokeSpawner m_smokeSpawner; |
| public SmokeSpawner m_smokeSpawner; |
| |
| |
| public EffectList m_fuelAddedEffects = new EffectList(); |
| public EffectList m_fuelAddedEffects = new EffectList(); |
| |
| |
| [Header("Fireworks")] |
| [Header("Fireworks")] |
| [Range(0f, 60f)] |
| [Range(0f, 60f)] |
| public float m_fireworksMaxRandomAngle = 5f; |
| public float m_fireworksMaxRandomAngle = 5f; |
| |
| |
| public Fireplace.FireworkItem[] m_fireworkItemList; |
| public Fireplace.FireworkItem[] m_fireworkItemList; |
| |
| |
| . | |
| [Header("Ignite Pieces")] |
| |
| public float m_igniteInterval; |
| |
| |
| |
| public float m_igniteChance; |
| |
| |
| |
| public int m_igniteSpread = 4; |
| |
| |
| |
| public float m_igniteCapsuleRadius; |
| |
| |
| |
| public Vector3 m_igniteCapsuleStart; |
| |
| |
| |
| public Vector3 m_igniteCapsuleEnd; |
| |
| |
| |
| public GameObject m_firePrefab; |
| |
| |
| private bool m_blocked; |
| private bool m_blocked; |
| |
| |
| private bool m_wet; |
| private bool m_wet; |
| |
| |
| . | |
| private Heightmap.Biome m_biome; |
| |
| |
| private float m_lastUseTime; |
| private float m_lastUseTime; |
| |
| |
| . | private static int m_solidRayMask; |
| private static int m_solidRayMask = 0; |
| |
| |
| |
| private static Collider[] s_tempColliders = new Collider[20]; |
| |
| |
| [Serializable] |
| [Serializable] |
| public struct FireworkItem |
| public struct FireworkItem |
| { |
| { |
| public ItemDrop m_fireworkItem; |
| public ItemDrop m_fireworkItem; |
| |
| |
| public int m_fireworkItemCount; |
| public int m_fireworkItemCount; |
| |
| |
| public EffectList m_fireworksEffects; |
| public EffectList m_fireworksEffects; |
| } |
| } |
| } |
| } |
| |
| |