public override void OnItemCreated(Item itemcreated) { float cooktimeLeft = cookTime; itemcreated.onCycle += delegate(Item item, float delta) { float temperature = item.temperature; if (temperature < (float)lowTemp || temperature > (float)highTemp || cooktimeLeft < 0f) { if (setCookingFlag && item.HasFlag(Item.Flag.Cooking)) { item.SetFlag(Item.Flag.Cooking, false); item.MarkDirty(); } } else { if (setCookingFlag && !item.HasFlag(Item.Flag.Cooking)) { item.SetFlag(Item.Flag.Cooking, true); item.MarkDirty(); } cooktimeLeft -= delta; if (!(cooktimeLeft > 0f)) { int position = item.position; if (item.amount > 1) { cooktimeLeft = cookTime; item.amount--; item.MarkDirty(); } else { item.Remove(); } if (becomeOnCooked != null) { Item item2 = ItemManager.Create(becomeOnCooked, amountOfBecome, 0uL); if (item2 != null && !item2.MoveToContainer(item.parent, position) && !item2.MoveToContainer(item.parent)) { item2.Drop(item.parent.dropPosition, item.parent.dropVelocity); if ((bool)item.parent.entityOwner) { BaseOven component = item.parent.entityOwner.GetComponent <BaseOven>(); if (component != null) { component.OvenFull(); } } } } } } }; }
public override void OnItemCreated(Item itemcreated) { float single1 = this.cookTime; itemcreated.onCycle += new Action <Item, float>((Item item, float delta) => { float single = item.temperature; if (single < (float)this.lowTemp || single > (float)this.highTemp || single1 < 0f) { if (this.setCookingFlag && item.HasFlag(Item.Flag.Cooking)) { item.SetFlag(Item.Flag.Cooking, false); item.MarkDirty(); } return; } if (this.setCookingFlag && !item.HasFlag(Item.Flag.Cooking)) { item.SetFlag(Item.Flag.Cooking, true); item.MarkDirty(); } single1 -= delta; if (single1 > 0f) { return; } int num = item.position; if (item.amount <= 1) { item.Remove(0f); } else { single1 = this.cookTime; item.amount--; item.MarkDirty(); } if (this.becomeOnCooked != null) { Item item1 = ItemManager.Create(this.becomeOnCooked, this.amountOfBecome, (ulong)0); if (item1 != null && !item1.MoveToContainer(item.parent, num, true) && !item1.MoveToContainer(item.parent, -1, true)) { item1.Drop(item.parent.dropPosition, item.parent.dropVelocity, new Quaternion()); if (item.parent.entityOwner) { BaseOven component = item.parent.entityOwner.GetComponent <BaseOven>(); if (component != null) { component.OvenFull(); } } } } }); }
void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable) { if (Settings.UsePermissions) { if (permission.UserHasPermission(oven.OwnerID.ToString(), PermAllowed) == false) { return; } } if (oven.inventory.itemList.Any(x => x.info.GetComponent <ItemModCookable>())) { foreach (var item in oven.inventory.itemList) { if (item == fuel) { continue; } if (item.HasFlag(global::Item.Flag.OnFire)) { item.SetFlag(global::Item.Flag.OnFire, false); } } return; } foreach (var item in oven.inventory.itemList.Where(x => x.info.shortname == "wood" && x != fuel).ToList()) { item.SetFlag(global::Item.Flag.OnFire, true); var charcoalMod = item.info.GetComponent <ItemModBurnable>(); if (UnityEngine.Random.Range(0f, 1f) > Settings.CharcoalChance) { var charcoal = ItemManager.Create(charcoalMod.byproductItem, Settings.CharcoalPerWood); if (!charcoal.MoveToContainer(oven.inventory)) { oven.OvenFull(); item.Drop(oven.inventory.dropPosition, oven.inventory.dropVelocity); } } item.UseItem(Settings.WoodSmeltedPerTick); } }
public override void OnItemCreated(Item itemcreated) { float cooktimeLeft = this.cookTime; itemcreated.onCycle += (Action <Item, float>)((item, delta) => { float temperature = item.temperature; if ((double)temperature < (double)this.lowTemp || (double)temperature > (double)this.highTemp || (double)cooktimeLeft < 0.0) { if (!this.setCookingFlag || !item.HasFlag(Item.Flag.Cooking)) { return; } item.SetFlag(Item.Flag.Cooking, false); item.MarkDirty(); } else { if (this.setCookingFlag && !item.HasFlag(Item.Flag.Cooking)) { item.SetFlag(Item.Flag.Cooking, true); item.MarkDirty(); } cooktimeLeft -= delta; if ((double)cooktimeLeft > 0.0) { return; } int position = item.position; if (item.amount > 1) { cooktimeLeft = this.cookTime; --item.amount; item.MarkDirty(); } else { item.Remove(0.0f); } if (!Object.op_Inequality((Object)this.becomeOnCooked, (Object)null)) { return; } Item obj = ItemManager.Create(this.becomeOnCooked, this.amountOfBecome, 0UL); if (obj == null || obj.MoveToContainer(item.parent, position, true) || obj.MoveToContainer(item.parent, -1, true)) { return; } obj.Drop(item.parent.dropPosition, item.parent.dropVelocity, (Quaternion)null); if (!Object.op_Implicit((Object)item.parent.entityOwner)) { return; } BaseOven component = (BaseOven)((Component)item.parent.entityOwner).GetComponent <BaseOven>(); if (!Object.op_Inequality((Object)component, (Object)null)) { return; } component.OvenFull(); } }); }