/// <summary> /// Prefix which returns false every time to skip the original method and other prefixes so that we're not /// needlessly setting fuel value twice /// </summary> /// <param name="__instance"></param> /// <param name="___m_nview"></param> /// <returns>false</returns> private static bool Prefix(ref Fireplace __instance, ref ZNetView ___m_nview) { if (!__instance.m_nview.IsValid()) { return(false); // don't run other prefixes or original } if (__instance.m_nview.IsOwner()) { if (Configuration.Current.Fireplace.IsEnabled) { FireplaceExtension.ApplyFuel(__instance, ref ___m_nview); } else { // original method float num1 = __instance.m_nview.GetZDO().GetFloat("fuel"); double timeSinceLastUpdate = __instance.GetTimeSinceLastUpdate(); if (__instance.IsBurning()) { float num2 = (float)timeSinceLastUpdate / __instance.m_secPerFuel; float num3 = num1 - num2; if ((double)num3 <= 0.0) { num3 = 0.0f; } __instance.m_nview.GetZDO().Set("fuel", num3); } } } __instance.UpdateState(); return(false); // don't run other prefixes or original }
public override void Damage(float amoutToDamage) { //print(fireplace); fireplace = GameObject.FindGameObjectWithTag("Fireplace").GetComponent <Fireplace>(); if (fireplace.IsInBounds(this.transform)) { inBounds = true; } base.Damage(amoutToDamage); DamageEffect(); if (this.currentHealth <= 0) { /*this.gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = cutDown; * this.gameObject.tag = "stump"; * this.GetComponent<Collider2D>().enabled = false; * this.gameObject.transform.GetChild(0).GetComponent<Collider2D>().enabled = false; * this.gameObject.transform.Find("ObjectArea").gameObject.SetActive(false);*/ DeathEffect(); if (inBounds) { update.Raise(); } } }
public override void EnterState(AIViliger _owner) { thisViliger = _owner; script = new Script(); script.Globals["Wait"] = (Func <int, bool>)Wait; script.Globals["ViligerStateChange"] = (Func <string, bool>)thisViliger.ViligerStateChange; script.Globals["AddToStateChain"] = (Func <string, bool>)thisViliger.AddToStateChain; script.Globals["FindClosestJob"] = (Func <bool>)FindClosestJob; script.Globals["CountObjects"] = (Func <int>)CountObjects; Fireplace fireplace = GameObject.FindGameObjectWithTag("Fireplace").GetComponent <Fireplace>(); seeker = _owner.GetComponent <Seeker>(); if (_owner.gameObject.GetComponent <Tool>().Item.name == "Axe") { objects = fireplace.trees.ToArray(); } if (_owner.gameObject.GetComponent <Tool>().Item.name == "Hammer") { objects = GameObject.FindGameObjectsWithTag("ToBuild"); } if (_owner.gameObject.GetComponent <Tool>().Item.name == "Pick") { objects = fireplace.stones.ToArray(); } }
static void Postfix(Fireplace __instance) { if (__instance.name.Contains("groundtorch") && customSFX.ContainsKey("groundtorch")) { Dbgl("Replacing ground torch audio"); __instance.m_enabledObjectHigh.GetComponentInChildren <AudioSource>().clip = customSFX["groundtorch"]; } else if (__instance.name.Contains("walltorch") && customSFX.ContainsKey("walltorch")) { Dbgl("Replacing walltorch audio"); __instance.m_enabledObjectHigh.GetComponentInChildren <AudioSource>().clip = customSFX["walltorch"]; } else if (__instance.name.Contains("fire_pit") && customSFX.ContainsKey("fire_pit")) { Dbgl("Replacing fire_pit audio"); __instance.m_enabledObjectHigh.GetComponentInChildren <AudioSource>().clip = customSFX["fire_pit"]; } else if (__instance.name.Contains("bonfire") && customSFX.ContainsKey("bonfire")) { Dbgl("Replacing bonfire audio"); __instance.m_enabledObjectHigh.GetComponentInChildren <AudioSource>().clip = customSFX["bonfire"]; } else if (__instance.name.Contains("hearth") && customSFX.ContainsKey("hearth")) { Dbgl("Replacing hearth audio"); __instance.m_enabledObjectHigh.GetComponentInChildren <AudioSource>().clip = customSFX["hearth"]; } }
private void CheckHeat(float delta) { var fireplaces = GetTree().GetNodesInGroup("fireplace"); float heatRate = -FreezeSpeed; foreach (Node node in fireplaces) { Fireplace fireplace = node as Fireplace; if (fireplace != null) { float distance = fireplace.GlobalPosition.DistanceTo(GlobalPosition); if (distance < fireplace.HeatInnerRadius) { heatRate += fireplace.HeatSpeed; } else if (distance < fireplace.HeatOuterRadius) { heatRate += fireplace.HeatSpeed * (fireplace.HeatOuterRadius - distance) / (fireplace.HeatOuterRadius - fireplace.HeatInnerRadius); } } } _healthParticles.Emitting = false; _globals.PlayerHealth += heatRate * delta; if (_globals.PlayerHealth < 100.0f && heatRate > 0.0f) { _healthParticles.Emitting = true; } }
private static void AddFuelFromNearbyChests(Fireplace __instance) { int toMaxFuel = (int)__instance.m_maxFuel - (int)Math.Ceiling(__instance.m_nview.GetZDO().GetFloat("fuel")); if (toMaxFuel > 0) { Stopwatch delta = GameObjectAssistant.GetStopwatch(__instance.gameObject); if (delta.IsRunning && delta.ElapsedMilliseconds < 1000) { return; } delta.Restart(); ItemDrop.ItemData fuelItemData = __instance.m_fuelItem.m_itemData; int addedFuel = InventoryAssistant.RemoveItemInAmountFromAllNearbyChests(__instance.gameObject, Helper.Clamp(Configuration.Current.FireSource.autoRange, 1, 50), fuelItemData, toMaxFuel, !Configuration.Current.FireSource.ignorePrivateAreaCheck); for (int i = 0; i < addedFuel; i++) { __instance.m_nview.InvokeRPC("AddFuel", new object[] { }); } if (addedFuel > 0) { ZLog.Log("Added " + addedFuel + " fuel(" + fuelItemData.m_shared.m_name + ") in " + __instance.m_name); } } }
void Start() { light = GetComponentInChildren <Light>(); initIntensity = light.intensity; GameObject fireplace = GameObject.Find("Fireplace"); _fireplace = fireplace.GetComponent <Fireplace>(); }
public void Change() { if (fireplace = GameObject.FindGameObjectWithTag("Fireplace").GetComponent <Fireplace>()) { if (transform.Find("Text") != null) { transform.Find("Text").GetComponent <TextMeshProUGUI>().text = fireplace.fireplaceStats.maxViligers.Value.ToString() + "/" + GameObject.FindGameObjectsWithTag("Viliger").Length; } } }
static bool Prefix(Fireplace __instance, Humanoid user, bool hold, ref bool __result, ZNetView ___m_nview) { __result = false; if (!AllowByKey()) { return(true); } if (hold) { return(false); } if (!___m_nview.HasOwner()) { ___m_nview.ClaimOwnership(); } Inventory inventory = user.GetInventory(); if (inventory == null) { __result = true; return(false); } if (!inventory.HaveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name) && (float)Mathf.CeilToInt(___m_nview.GetZDO().GetFloat("fuel", 0f)) < __instance.m_maxFuel) { List <Container> nearbyContainers = GetNearbyContainers(__instance.transform.position); foreach (Container c in nearbyContainers) { ItemDrop.ItemData item = c.GetInventory().GetItem(__instance.m_fuelItem.m_itemData.m_shared.m_name); if (item != null) { if (fuelDisallowTypes.Value.Split(',').Contains(item.m_dropPrefab.name)) { Dbgl($"container at {c.transform.position} has {item.m_stack} {item.m_dropPrefab.name} but it's forbidden by config"); continue; } Dbgl($"container at {c.transform.position} has {item.m_stack} {item.m_dropPrefab.name}, taking one"); c.GetInventory().RemoveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name, 1); typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c, new object[] { }); typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c.GetInventory(), new object[] { }); user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[] { __instance.m_fuelItem.m_itemData.m_shared.m_name }), 0, null); inventory.RemoveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name, 1); ___m_nview.InvokeRPC("AddFuel", new object[] { }); __result = true; return(false); } } } return(true); }
public static void Postfix(Fireplace __instance, ZNetView ___m_nview) { __instance.m_secPerFuel = 0.000001f; if (___m_nview != null) { ZDO zdo = ___m_nview.GetZDO(); if (zdo != null) { zdo.Set("fuel", __instance.m_maxFuel + 1); } } }
private void FeedFireplace(Fireplace fireplace) { foreach (var collectable in new List <ICollectable>(inventory.GetCollectables())) { if (collectable is IFuel) { fireplace.Feed((IFuel)collectable); //addScore GameObject.Find("GameManager").GetComponent <GameManager>().AddScore(firePlaceScore); inventory.Remove(collectable); } } }
public static void Postfix(Fireplace __instance) { foreach (MobAIBase mob in MobManager.AliveMobs.Where(m => m.Value.HasInstance()).Where(m => (m.Value.Instance as MonsterAI).GetFollowTarget() == Player.m_localPlayer.gameObject).Select(m => m.Value)) { string interactName = Common.GetPrefabName(__instance.gameObject.name); if (mob.m_trainedAssignments.Contains(interactName)) { Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: Already know how to operate the {interactName}!"); return; } if (Vector3.Distance(mob.Character.transform.position, __instance.transform.position) < 5 && !mob.m_trainedAssignments.Contains(interactName)) { if (mob.learningTask == interactName) { mob.learningRate += 1; } else { mob.learningTask = interactName; mob.learningRate = 0; Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: Introduced to operate the {interactName}."); } if (mob.learningRate == 1) { Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: Greyling is shaking the head when looking at {interactName}."); } if (mob.learningRate == 2) { Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: Increasing the understanding of {interactName}."); } if (mob.learningRate == 3) { Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: Got the basic consept of {interactName}."); } if (mob.learningRate == 4) { Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: There is a shine in the greylings eyes when loocking at the {interactName}."); } if (mob.learningRate == 5) { mob.m_trainedAssignments.Add(interactName); mob.NView.GetZDO().Set(Constants.Z_trainedAssignments, mob.m_trainedAssignments.Join()); mob.NView.InvokeRPC(ZNetView.Everybody, Constants.Z_updateTrainedAssignments, mob.UniqueID, mob.m_trainedAssignments.Join()); Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: The greyling have now learnt how to operate {interactName}."); Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, $"{mob.Character.GetHoverName()}: List of known assignments: {mob.m_trainedAssignments.Join()}."); mob.learningTask = ""; mob.learningRate = 0; } } } }
public override void Run() { int numDead = 0; Fireplace survivor = null; foreach (Fireplace f in inGameFirePlaces) { if (f.Dead) { numDead++; } else { survivor = f; } } if (numDead >= GameManager.instance.AllPlayers.Count - 1) { winnerFound -= Data.GameManager.instance.DeltaTime; if (winnerFound < 0) { for (int i = 0; i < GameManager.instance.AllPlayers.Count; i++) { GameManager.instance.AllPlayers[i].ThrowObject(); } for (int i = 0; i < inGameLogs.Count; i++) { Destroy(inGameLogs[i].gameObject); } for (int i = 0; i < inGameFirePlaces.Count; i++) { if (inGameFirePlaces[i] != null) { Destroy(inGameFirePlaces[i].gameObject); } } if (survivor) { Winners.Add(GameManager.instance.CharacterToPlayer[survivor.linkedCharacter]); } finished = true; winnerFound = 2f; } } }
private static void Postfix(Fireplace __instance, ref ZNetView ___m_nview) { if (Configuration.Current.Fireplace.IsEnabled) { if (Configuration.Current.Fireplace.OnlyTorches) { if (__instance.GetHoverText().Contains("torch") || __instance.GetHoverText().Contains("Scounce") || __instance.GetHoverText().Contains("brazier")) { ___m_nview.GetZDO().Set("fuel", 1f); } } else { ___m_nview.GetZDO().Set("fuel", 3f); } } }
private static void Postfix(Fireplace __instance, ref ZNetView ___m_nview) { if (Settings.isEnabled("Fireplace")) { if (Settings.getBool("Fireplace", "onlyTorches")) { if (__instance.GetHoverText().Contains("torch") || __instance.GetHoverText().Contains("Scounce") || __instance.GetHoverText().Contains("brazier")) { ___m_nview.GetZDO().Set("fuel", 1f); } } else { ___m_nview.GetZDO().Set("fuel", 1f); } } }
internal static void ApplyFuel(Fireplace __instance, ref ZNetView ___m_nview) { if (Configuration.Current.Fireplace.onlyTorches) { if (__instance.m_piece.m_name.Equals(woodTorchName) || __instance.m_piece.m_name.Equals(sconceName) || __instance.m_piece.m_name.Equals(ironTorchName) || __instance.m_piece.m_name.Equals(brazierName) || __instance.m_piece.m_name.Equals(greenTorchName)) { ___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel); // setting to max won't waste rss on fill attempts } } else { ___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel); // setting to max won't waste rss on fill attempts } }
public void PlaceFireplace() { for (int i = 0; i < inventory.slots.Count; i++) { if (inventory.slots[i].name == "Fireplace") { inventory.RemoveItem("Fireplace"); GameObject fireplace = GameObject.Instantiate <GameObject>(fireplacePrefab); fireplaceScript = fireplace.GetComponent <Fireplace>(); Vector3 location = player.GetComponent <Transform>().position; Vector3 fireplaceOffset = new Vector3(0f, 0.25f, 0f); fireplace.transform.position = location + fireplaceOffset; // fireplace.transform.position = new Vector3(100f, 3f, 61f); break; } } }
public static bool Prefix(Fireplace __instance, ref bool __result, Humanoid user, bool hold) { if (hold) { __result = false; return(false); } if (!__instance.m_nview.HasOwner()) { __instance.m_nview.ClaimOwnership(); } Inventory inventory = user.GetInventory(); if (inventory == null) { __result = true; return(false); } var fuelItem = GetAvailableFuelItem(inventory, __instance.m_fuelItem.m_itemData.m_shared.m_name); Debug.Log($"Try adding: {fuelItem}"); if (!string.IsNullOrEmpty(fuelItem)) { if ((double)Mathf.CeilToInt(__instance.m_nview.GetZDO().GetFloat("fuel")) >= (double)__instance.m_maxFuel) { user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_cantaddmore", __instance.m_fuelItem.m_itemData.m_shared.m_name)); __result = false; return(false); } user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", fuelItem)); inventory.RemoveItem(fuelItem, 1); __instance.m_nview.InvokeRPC("AddFuel", (object[])Array.Empty <object>()); __result = true; return(false); } user.Message(MessageHud.MessageType.Center, "$msg_outof " + __instance.m_fuelItem.m_itemData.m_shared.m_name); __result = false; return(false); }
public void PlaceFireplace() { for (int i = 0; i < inventory.slots.Count; i++) { if (inventory.slots[i].name == "Fireplace") { inventory.RemoveItem("Fireplace"); GameObject fireplace = GameObject.Instantiate<GameObject>(fireplacePrefab); fireplaceScript = fireplace.GetComponent<Fireplace>(); Vector3 location = player.GetComponent<Transform>().position; Vector3 fireplaceOffset = new Vector3(0f, 0.25f, 0f); fireplace.transform.position = location + fireplaceOffset; // fireplace.transform.position = new Vector3(100f, 3f, 61f); break; } } }
/// <summary> /// If fire source is configured to keep fire source lit, reset time since being lit to 0 /// </summary> private static void Postfix(ref double __result, ref Fireplace __instance) { if (!Configuration.Current.FireSource.IsEnabled) { return; } if (FireplaceExtensions.IsTorch(__instance.m_name)) { if (Configuration.Current.FireSource.torches) { __result = 0.0; } } else if (Configuration.Current.FireSource.fires) { __result = 0.0; } }
static void Postfix(Fireplace __instance, ZNetView ___m_nview) { if (!Player.m_localPlayer || !isOn.Value || !___m_nview.IsOwner() || (__instance.name.Contains("groundtorch") && !refuelStandingTorches.Value) || (__instance.name.Contains("walltorch") && !refuelWallTorches.Value) || (__instance.name.Contains("fire_pit") && !refuelFirePits.Value)) { return; } if (Time.time - lastFuel < 0.1) { fuelCount++; RefuelTorch(__instance, ___m_nview, fuelCount * 33); } else { fuelCount = 0; lastFuel = Time.time; RefuelTorch(__instance, ___m_nview, 0); } }
/// <summary> /// When fire source is loaded in view, check for configurations and set its start fuel and current fuel to max fuel /// </summary> private static void Postfix(ref Fireplace __instance) { if (!Configuration.Current.FireSource.IsEnabled || !__instance.m_nview || __instance.m_nview.m_zdo == null) { return; } if (FireplaceExtensions.IsTorch(__instance.m_nview.GetPrefabName())) { if (Configuration.Current.FireSource.torches) { __instance.m_startFuel = __instance.m_maxFuel; __instance.m_nview.GetZDO().Set("fuel", __instance.m_maxFuel); } } else if (Configuration.Current.FireSource.fires) { __instance.m_startFuel = __instance.m_maxFuel; __instance.m_nview.GetZDO().Set("fuel", __instance.m_maxFuel); } }
private static bool Prefix(Fireplace __instance, Humanoid user, ItemDrop.ItemData item, ref bool __result) { if (!HatchingEgg.Value) { return(true); } if (item.m_dropPrefab.name == "DragonEgg") { if (!__instance.IsBurning()) { user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("You need to add more fuel before you are hatch the egg")); __result = true; return(false); } Inventory inventory = user.GetInventory(); user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("The egg is hatching")); inventory.RemoveItem(item, 1); var go = Instantiate(ZNetScene.instance.GetPrefab("HatchingDragonEgg")); go.transform.localPosition = user.transform.position + new Vector3(0, 2, 0); __result = true; return(false); } return(true); }
public void Interact() { if (Main.GetInstance().inCutScene) { Debug.Log("ativou cutscene"); DesactivateAnimHand(); return; } rayToInteract = Player.GetCamera().ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); if (Physics.Raycast(rayToInteract, out hitInfo, rangeInteract)) { switch (hitInfo.collider.tag) { case "InteractItem": ActivateAnimHand(); GetInteractItem(hitInfo); break; case "Item": if (IsActiveItem(hitInfo)) { //if (hitInfo.collider.gameObject.name.Contains ("celular")) { // SubtitleManager.GetInstance ().SetText ("[ESPACO] para interagir"); //} ActivateAnimHand(); GetItem(hitInfo); } break; case "Door": ActivateAnimHand(); OpenDoor(hitInfo); break; case "Fireplace": ActivateAnimHand(); Fireplace firePlace = hitInfo.transform.gameObject.GetComponent <Fireplace>(); if (Input.GetKeyDown(KeyCode.Space)) { if (Player.GetInstance().Items.Contains(Constants.PictureItem)) { if (Player.GetInstance().items.Contains(Constants.StockWood)) { HelperUtil.FindGameObject(GameObject.Find("Audio"), "SoundLareira").SetActive(true); Player.GetInstance().items.Remove(Constants.StockWood); firePlace.light.intensity = firePlace.lightIntensity; firePlace.fireParticle.GetComponent <ParticleSystem>().emissionRate = 6; //firePlace.fireParticle.GetComponent<ParticleSystem>().emissionRate = 3; //firePlace.fireParticle.GetComponent<ParticleSystem>().Play(); //firePlace.fireParticle.GetComponent<ParticleSystem>().enableEmission = true; } if (hasDestroyedPicture || firePlace.light.intensity > firePlace.minlightIntensity) { HelperUtil.FindGameObject(GameObject.Find("Audio"), "SoundPersecution").SetActive(false); EventManager.GetInstance().SetEvent("babyRest"); hasDestroyedPicture = true; } else { if (firePlace.light.intensity < firePlace.minlightIntensity) { SubtitleManager.GetInstance().SetText("Recarregue a lareira para queimar o quadro."); } else { SubtitleManager.GetInstance().SetText("Recarregou a lareira. Destrua o quadro"); hasDestroyedPicture = true; } } } else { if (Player.GetInstance().items.Contains(Constants.StockWood)) { HelperUtil.FindGameObject(GameObject.Find("Audio"), "SoundLareira").SetActive(true); firePlace.light.intensity = firePlace.lightIntensity; firePlace.fireParticle.GetComponent <ParticleSystem>().emissionRate = 6; Debug.Log(firePlace.light.intensity); Player.GetInstance().items.Remove(Constants.StockWood); SubtitleManager.GetInstance().SetText("Recarregou a lareira."); } else { SubtitleManager.GetInstance().SetText("Pegue lenha"); } } } Debug.Log("Lareira"); break; default: DesactivateAnimHand(); break; } } else { DesactivateAnimHand(); } }
public static async void RefuelTorch(Fireplace fireplace, ZNetView znview, int delay) { await Task.Delay(delay); int maxFuel = (int)(fireplace.m_maxFuel - Mathf.Ceil(znview.GetZDO().GetFloat("fuel", 0f))); List <Container> nearbyContainers = GetNearbyContainers(fireplace.transform.position, fireplaceRange.Value); Vector3 position = fireplace.transform.position + Vector3.up; foreach (Collider collider in Physics.OverlapSphere(position, dropRange.Value, LayerMask.GetMask(new string[] { "item" }))) { if (collider?.attachedRigidbody) { ItemDrop item = collider.attachedRigidbody.GetComponent <ItemDrop>(); //Dbgl($"nearby item name: {item.m_itemData.m_dropPrefab.name}"); if (item?.GetComponent <ZNetView>()?.IsValid() != true) { continue; } string name = GetPrefabName(item.gameObject.name); if (item.m_itemData.m_shared.m_name == fireplace.m_fuelItem.m_itemData.m_shared.m_name && maxFuel > 0) { if (fuelDisallowTypes.Value.Split(',').Contains(name)) { //Dbgl($"ground has {item.m_itemData.m_dropPrefab.name} but it's forbidden by config"); continue; } Dbgl($"auto adding fuel {name} from ground"); int amount = Mathf.Min(item.m_itemData.m_stack, maxFuel); maxFuel -= amount; for (int i = 0; i < amount; i++) { if (item.m_itemData.m_stack <= 1) { if (znview.GetZDO() == null) { Destroy(item.gameObject); } else { ZNetScene.instance.Destroy(item.gameObject); } znview.InvokeRPC("AddFuel", new object[] { }); break; } item.m_itemData.m_stack--; znview.InvokeRPC("AddFuel", new object[] { }); Traverse.Create(item).Method("Save").GetValue(); } } } } foreach (Container c in nearbyContainers) { if (fireplace.m_fuelItem && maxFuel > 0) { ItemDrop.ItemData fuelItem = c.GetInventory().GetItem(fireplace.m_fuelItem.m_itemData.m_shared.m_name); if (fuelItem != null) { maxFuel--; if (fuelDisallowTypes.Value.Split(',').Contains(fuelItem.m_dropPrefab.name)) { //Dbgl($"container at {c.transform.position} has {item.m_stack} {item.m_dropPrefab.name} but it's forbidden by config"); continue; } Dbgl($"container at {c.transform.position} has {fuelItem.m_stack} {fuelItem.m_dropPrefab.name}, taking one"); znview.InvokeRPC("AddFuel", new object[] { }); c.GetInventory().RemoveItem(fireplace.m_fuelItem.m_itemData.m_shared.m_name, 1); typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c, new object[] { }); typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c.GetInventory(), new object[] { }); } } } }
public override string GetInteractionName(Sim actor, Fireplace target, InteractionObjectPair iop) { return(base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target))); }
private void CheckHeat(float delta) { var fireplaces = GetTree().GetNodesInGroup("fireplace"); // Defines how fast (in % of FreezeSpeed) the player's health will decay. // Take the smallest value - freeze factor is the percent distance of the player // from the inner radius of the fire to the outer radius. // Valid between -1.0f and 1.0f. // A value of less than 0.0f indicates that the player is being healed // in which case, the max heal speed will be set according to that fireplace's // heal speed. float minFreezeFactor = 1.0f; // Heal float maxHealSpeed = 0.0f; foreach (Node node in fireplaces) { Fireplace fireplace = node as Fireplace; if (fireplace != null) { float distance = fireplace.GlobalPosition.DistanceTo(GlobalPosition); // Note - multiple fires healing the player at once could be weird! // Not currently handled if (fireplace.HealEnabled && distance < fireplace.HealInnerRadius) { minFreezeFactor = -1.0f; maxHealSpeed = fireplace.HealSpeed; break; } else if (fireplace.HealEnabled && distance < fireplace.HealOuterRadius) { float freezeFactor = -(distance - fireplace.HealInnerRadius) / (fireplace.HealOuterRadius - fireplace.HealInnerRadius); if (freezeFactor < minFreezeFactor) { minFreezeFactor = freezeFactor; maxHealSpeed = fireplace.HealSpeed; } } else if (distance < fireplace.HeatInnerRadius) { if (minFreezeFactor > 0.0f) { minFreezeFactor = 0.0f; } } else if (distance < fireplace.HeatOuterRadius) { float freezeFactor = (distance - fireplace.HeatInnerRadius) / (fireplace.HeatOuterRadius - fireplace.HeatInnerRadius); if (freezeFactor < minFreezeFactor) { minFreezeFactor = freezeFactor; } } } } if (minFreezeFactor > 0.0f) { _globals.PlayerHealth -= FreezeSpeed * minFreezeFactor * delta; } else { _globals.PlayerHealth -= maxHealSpeed * minFreezeFactor * delta; } }
public static void Fireplace_UpdateFireplace(Fireplace __instance, ref ZNetView ___m_nview) { ___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel); }
static void Postfix(Fireplace __instance) { if (!modEnabled.Value) { return; } string name = __instance.name; Dbgl($"starting fireplace {name}"); FieldInfo lfi = typeof(LightFlicker).GetField("m_baseIntensity", BindingFlags.NonPublic | BindingFlags.Instance); if (name.Contains("groundtorch")) { LightFlicker lf = __instance.m_enabledObject.GetComponentInChildren <LightFlicker>(); Light light = lf.GetComponent <Light>(); //Dbgl($"color: {light.color}"); //Dbgl($"range: {light.range}"); //Dbgl($"bounceIntensity: {light.bounceIntensity}"); //Dbgl($"useColorTemperature: {light.useColorTemperature}"); //Dbgl($"colorTemperature: {light.colorTemperature}"); //Dbgl($"shadowStrength: {light.shadowStrength}"); //Dbgl($"intensity: {lfi.GetValue(lf)}"); light.color = standingTorchColor.Value; light.range = standingTorchRange.Value; light.bounceIntensity = standingTorchBounceIntensity.Value; light.useColorTemperature = standingTorchUseColorTemperature.Value; light.colorTemperature = standingTorchColorTemperature.Value; light.shadowStrength = standingTorchShadowStrength.Value; lfi.SetValue(lf, standingTorchIntensity.Value); } else if (name.Contains("walltorch")) { LightFlicker lf = __instance.m_enabledObject.GetComponentInChildren <LightFlicker>(); Light light = lf.GetComponent <Light>(); light.color = sconceColor.Value; light.range = sconceRange.Value; light.bounceIntensity = sconceBounceIntensity.Value; light.useColorTemperature = sconceUseColorTemperature.Value; light.colorTemperature = sconceColorTemperature.Value; light.shadowStrength = sconceShadowStrength.Value; lfi.SetValue(lf, sconceIntensity.Value); } else if (name.Contains("fire_pit")) { LightFlicker lf = __instance.m_enabledObjectLow.GetComponentInChildren <LightFlicker>(); Light light = lf.GetComponent <Light>(); light.color = firePitColorLow.Value; light.range = firePitRangeLow.Value; light.bounceIntensity = firePitBounceIntensityLow.Value; light.useColorTemperature = firePitUseColorTemperatureLow.Value; light.colorTemperature = firePitColorTemperatureLow.Value; light.shadowStrength = firePitShadowStrengthLow.Value; lfi.SetValue(lf, firePitIntensityLow.Value); LightFlicker lf2 = __instance.m_enabledObjectHigh.GetComponentInChildren <LightFlicker>(); Light light2 = lf2.GetComponent <Light>(); light2.color = firePitColorHigh.Value; light2.range = firePitRangeHigh.Value; light2.bounceIntensity = firePitBounceIntensityHigh.Value; light2.useColorTemperature = firePitUseColorTemperatureHigh.Value; light2.colorTemperature = firePitColorTemperatureHigh.Value; light2.shadowStrength = firePitShadowStrengthHigh.Value; lfi.SetValue(lf2, firePitIntensityHigh.Value); } else if (name.Contains("bonfire")) { LightFlicker lf = __instance.m_enabledObjectLow.GetComponentInChildren <LightFlicker>(); Light light = lf.GetComponent <Light>(); light.color = bonfireColorLow.Value; light.range = bonfireRangeLow.Value; light.bounceIntensity = bonfireBounceIntensityLow.Value; light.useColorTemperature = bonfireUseColorTemperatureLow.Value; light.colorTemperature = bonfireColorTemperatureLow.Value; light.shadowStrength = bonfireShadowStrengthLow.Value; lfi.SetValue(lf, bonfireIntensityLow.Value); LightFlicker lf2 = __instance.m_enabledObjectHigh.GetComponentInChildren <LightFlicker>(); Light light2 = lf2.GetComponent <Light>(); light2.color = bonfireColorHigh.Value; light2.range = bonfireRangeHigh.Value; light2.bounceIntensity = bonfireBounceIntensityHigh.Value; light2.useColorTemperature = bonfireUseColorTemperatureHigh.Value; light2.colorTemperature = bonfireColorTemperatureHigh.Value; light2.shadowStrength = bonfireShadowStrengthHigh.Value; lfi.SetValue(lf2, bonfireIntensityHigh.Value); } else if (name.Contains("hearth")) { LightFlicker lf = __instance.m_enabledObjectLow.GetComponentInChildren <LightFlicker>(); Light light = lf.GetComponent <Light>(); light.color = hearthColorLow.Value; light.range = hearthRangeLow.Value; light.bounceIntensity = hearthBounceIntensityLow.Value; light.useColorTemperature = hearthUseColorTemperatureLow.Value; light.colorTemperature = hearthColorTemperatureLow.Value; light.shadowStrength = hearthShadowStrengthLow.Value; lfi.SetValue(lf, hearthIntensityLow.Value); LightFlicker lf2 = __instance.m_enabledObjectHigh.GetComponentInChildren <LightFlicker>(); Light light2 = lf2.GetComponent <Light>(); light2.color = hearthColorHigh.Value; light2.range = hearthRangeHigh.Value; light2.bounceIntensity = hearthBounceIntensityHigh.Value; light2.useColorTemperature = hearthUseColorTemperatureHigh.Value; light2.colorTemperature = hearthColorTemperatureHigh.Value; light2.shadowStrength = hearthShadowStrengthHigh.Value; lfi.SetValue(lf2, hearthIntensityHigh.Value); } }
public UpgradeFireplaceAlteration(Fireplace.Tuning tuning, float factor) { Add(new UpgradeAlteration(tuning.UpgradeAutoLight, factor)); Add(new UpgradeAlteration(tuning.UpgradeChangeColor, factor)); Add(new UpgradeAlteration(tuning.UpgradeFireproof, factor)); }
bool IsInBounds() { Fireplace fireplace = GameObject.FindGameObjectWithTag("Fireplace").GetComponent <Fireplace>(); return(fireplace.IsInBounds(currentBuilding)); }
public void Start() { fireplace = transform.parent.GetComponent <Fireplace>(); }