internal override void OnPlayerDeath(EventManager.BaseEventPlayer attacker = null, float respawnTime = 5) { AddPlayerDeath(); DestroyUI(); string message = string.Empty; if (LivesRemaining <= 0) { int position = Event.GetAlivePlayerCount(); message = IsOutOfBounds ? string.Format(GetMessage("UI.Death.OOB.Kicked", Player.userID), ToOrdinal(position + 1), position) : string.Format(GetMessage("UI.Death.Killed.Kicked", Player.userID), ToOrdinal(position + 1), position); } else { _respawnDurationRemaining = respawnTime; InvokeHandler.InvokeRepeating(this, RespawnTick, 1f, 1f); message = IsOutOfBounds ? GetMessage("UI.Death.OOB", Player.userID) : GetMessage("UI.Death.Killed", Player.userID); } EMInterface.DisplayDeathScreen(this, message, LivesRemaining > 0); }
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); }
protected override void StartEvent() { base.StartEvent(); GodmodeEnabled = true; InvokeHandler.Invoke(this, StartRound, Configuration.TimeBetweenRounds); BroadcastToPlayers(GetMessage, "Notification.RoundStartsIn", Configuration.TimeBetweenRounds); InvokeHandler.InvokeRepeating(this, UpdateScoreboard, 1f, 1f); }
public void Initialize() { this.OnEnableAgency(); if (this.UseCover) { this.OnEnableCover(); } AiManagerLoadBalancer.aiManagerLoadBalancer.Add(this); if (this.HTNAgency != null) { this.HTNAgency.OnEnableAgency(); if (AiManager.ai_htn_use_agency_tick) { InvokeHandler.InvokeRepeating(this, new Action(this.HTNAgency.InvokedTick), 0f, 0.033f); } } }
public void Initialize() { this.OnEnableAgency(); if (this.UseCover) { this.OnEnableCover(); } AiManagerLoadBalancer.aiManagerLoadBalancer.Add((ILoadBalanced)this); if (this.HTNAgency == null) { return; } this.HTNAgency.OnEnableAgency(); if (!AiManager.ai_htn_use_agency_tick) { return; } InvokeHandler.InvokeRepeating((Behaviour)this, new Action(this.HTNAgency.InvokedTick), 0.0f, 0.033f); }
private void Awake() { entity = GetComponent <BaseEntity>(); npc = entity.GetComponent <BaseNpc>(); npc.CancelInvoke(npc.TickAi); npc.SetAiFlag(BaseNpc.AiFlags.Sleeping, false); animalConfig = GetAnimalSpeed(npc); npc._maxHealth = animalConfig.health; npc.health = animalConfig.health; instance.animalAI[entity] = this; type = animalConfig.agressive ? AType.Aggressive : AType.Passive; originalType = type; state = AIState.Walking; lastPosition = entity.transform.position; InvokeHandler.InvokeRepeating(this, UpdateAI, 0, updateRate); if (IsStucked()) { DestroyAndKill(); } if (config.SleepAtNight) { InvokeHandler.InvokeRepeating(this, CheckTime, updateRate, 10 + updateRate); } }
public void SetHome(Vector3 homePos) { this.homePos = homePos; InvokeHandler.InvokeRepeating(this, CheckLocation, 1f, 20f); }
public void SetInfo(string prefabName, Vector3 homePos) { this.prefabName = prefabName; this.homePos = homePos; InvokeHandler.InvokeRepeating(this, CheckLocation, 1f, 20f); }
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 InvokeRepeating(Action action, float time, float repeat) { InvokeHandler.InvokeRepeating(this, action, time, repeat); }