private void OnDestroy() { InvokeHandler.CancelInvoke(this, CheckLocation); if (npc != null && !npc.IsDestroyed && !naturalDeath) { npc.Kill(); } }
void StartCooking(BaseOven oven, BaseEntity entity, float ovenMultiplier) { if (FindBurnable(oven) == null) { return; } oven.inventory.temperature = CookingTemperature(oven.temperature); oven.UpdateAttachmentTemperature(); InvokeHandler.CancelInvoke(entity.GetComponent <MonoBehaviour>(), new Action(oven.Cook)); InvokeHandler.InvokeRepeating(entity.GetComponent <MonoBehaviour>(), new Action(oven.Cook), 0.5f / ovenMultiplier, 0.5f / ovenMultiplier); entity.SetFlag(BaseEntity.Flags.On, true, false); }
private void PickupFlag(CaptureTheFlagPlayer eventPlayer) { FlagHolder = eventPlayer; eventPlayer.IsCarryingFlag = true; IsAtBase = false; InvokeHandler.CancelInvoke(this, DroppedTimeExpired); primary.SetParent(eventPlayer.Player); tr.localPosition = new Vector3(0f, 0.25f, -0.75f); captureTheFlagEvent.BroadcastToPlayers(GetMessage, "Notification.FlagPickedUp", eventPlayer.Player.displayName, Team, captureTheFlagEvent.GetTeamColor(eventPlayer.Team), captureTheFlagEvent.GetTeamColor(Team)); }
private void CancelInvoke(string methodName, object obj) { if (string.IsNullOrEmpty(methodName) || obj == null) { return; } if (!IsInvoking(methodName, obj)) { return; } var action = InvokeList.Where(p => (p.Key.action?.Target ?? null) == obj && (p.Key.action?.Method?.Name ?? string.Empty) == methodName).FirstOrDefault().Key; if (action != null) { InvokeHandler.CancelInvoke(action.sender, action.action); } }
private void ResetFlag() { if (FlagHolder != null) { FlagHolder.IsCarryingFlag = false; FlagHolder = null; } InvokeHandler.CancelInvoke(this, DroppedTimeExpired); primary.SetParent(null); tr.position = basePosition; primary.UpdateNetworkGroup(); primary.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); IsAtBase = true; }
private void OnDisable() { if (Rust.Application.isQuitting) { return; } this.OnDisableAgency(); if (this.UseCover) { this.OnDisableCover(); } AiManagerLoadBalancer.aiManagerLoadBalancer.Remove(this); if (this.HTNAgency != null) { this.HTNAgency.OnDisableAgency(); if (AiManager.ai_htn_use_agency_tick) { InvokeHandler.CancelInvoke(this, new Action(this.HTNAgency.InvokedTick)); } } }
private void OnDestroy() { InvokeHandler.CancelInvoke(this, CheckLocation); }
void OnServerInitialized() { if (expertModeEnabled) { // Reset fuel consumption and byproduct amount - fix for previous versions var wood = ItemManager.FindItemDefinition("wood"); var burnable = wood?.GetComponent <ItemModBurnable>(); if (burnable != null) { burnable.byproductAmount = 1; burnable.byproductChance = 0.5f; } // Check if meat should be overcooked if (overcookMeat) { return; } // Loop through item definitions var itemDefinitions = ItemManager.itemList; foreach (var item in itemDefinitions) { // Skip any item definitions other than cooked meat if (!item.shortname.Contains(".cooked")) { continue; } // Lower high temperature on item definition to prevent burning var cookable = item.GetComponent <ItemModCookable>(); if (cookable != null) { cookable.highTemp = 150; } } return; } if (!overcookMeat) { foreach (var item in ItemManager.GetItemDefinitions()) { if (item.shortname.Contains(".cooked")) { var cookable = item.GetComponent <ItemModCookable>(); if (cookable != null) { if (cookInFurnaces) { cookable.highTemp = 800; } else { cookable.highTemp = 150; } } } } } if (cookInFurnaces) { foreach (var item in ItemManager.GetItemDefinitions()) { if (item.shortname.Contains("raw") || item.shortname.Contains("meat.boar") || item.shortname == ("bearmeat")) { var cookable = item.GetComponent <ItemModCookable>(); if (cookable != null) { cookable.lowTemp = 800; cookable.highTemp = 1200; } } } } foreach (var item in ItemManager.GetItemDefinitions()) { ItemModBurnable component = item.GetComponent <ItemModBurnable>(); if (component && component.name == "wood.item") { if (charcoalPercentLoss > 100) { charcoalPercentLoss = 100; } if (charcoalPercentLoss < 0) { charcoalPercentLoss = 0; } component.byproductChance = Convert.ToSingle(charcoalPercentLoss) / 100; if (woodFuelAmount < 0.1f) { woodFuelAmount = 0.1f; } component.fuelAmount = Convert.ToSingle(woodFuelAmount); if (charcoalMultiplier < 1) { charcoalMultiplier = 1; } component.byproductAmount = Convert.ToInt32(charcoalMultiplier); } } foreach (var itemDef in ItemManager.GetItemDefinitions()) { ItemModCookable component = itemDef.GetComponent <ItemModCookable>(); if (component) { if (cookTimes.ContainsKey(component.name.Replace(".item", ""))) { float time = Convert.ToSingle(cookTimes[component.name.Replace(".item", "")]); if (time < 0.1f) { time = 0.1f; } component.cookTime = time; } if (amountsOfBecome.ContainsKey(component.name.Replace(".item", ""))) { int amount = Convert.ToInt32(amountsOfBecome[component.name.Replace(".item", "")]); if (amount < 1) { amount = 1; } component.amountOfBecome = amount; } } } var baseOvens = Resources.FindObjectsOfTypeAll <BaseOven>().Where(c => c.isActiveAndEnabled && !(c is BaseFuelLightSource)).Cast <BaseEntity>().ToList(); foreach (var oven in baseOvens) { if (usePermissions && !permission.UserHasPermission(oven.OwnerID.ToString(), permAllow)) { continue; } if (oven.HasFlag(BaseEntity.Flags.On)) { object checkMultiplier; if (!ovenMultipliers.TryGetValue(oven.ShortPrefabName, out checkMultiplier)) { continue; } float ovenMultiplier = Convert.ToSingle(checkMultiplier); if (ovenMultiplier > 10f) { ovenMultiplier = 10f; } if (ovenMultiplier < 0.1f) { ovenMultiplier = 0.1f; } InvokeHandler.CancelInvoke(oven.GetComponent <MonoBehaviour>(), new Action((oven as BaseOven).Cook)); (oven as BaseOven).inventory.temperature = CookingTemperature((oven as BaseOven).temperature); (oven as BaseOven).UpdateAttachmentTemperature(); InvokeHandler.InvokeRepeating(oven.GetComponent <MonoBehaviour>(), new Action((oven as BaseOven).Cook), 0.5f / ovenMultiplier, 0.5f / ovenMultiplier); } } }
public void CancelInvoke(Action action) { InvokeHandler.CancelInvoke(this, action); }
internal override void EndEvent() { InvokeHandler.CancelInvoke(this, UpdateScoreboard); base.EndEvent(); }