public void ToggleLight(bool status) { if (config.Owner && !ins.UserHasToggled(entity.OwnerID, consumeType)) { status = false; } if (isSearchlight) { SearchLight searchLight = entity as SearchLight; if (searchLight != null) { if (status) { Item slot = searchLight.inventory.GetSlot(0); if (slot == null) { ItemManager.Create(searchLight.fuelType).MoveToContainer(searchLight.inventory); } } searchLight.SetFlag(BaseEntity.Flags.On, status); } } else { BaseOven baseOven = entity as BaseOven; if (baseOven != null) { if (config.ConsumeFuel) { if (status) { baseOven.StartCooking(); } else { baseOven.StopCooking(); } } else { if (baseOven.IsOn() != status) { baseOven.SetFlag(BaseEntity.Flags.On, status); } } } } entity.SendNetworkUpdate(); }
object OnOvenToggle(BaseOven oven, BasePlayer player) { string cleanedname = null; if (oven == null || string.IsNullOrEmpty(oven.ShortPrefabName) || player == null || player.UserIDString == null) { return(null); } else { cleanedname = CleanedName(oven.ShortPrefabName); //Puts(oven.ShortPrefabName + " : " + cleanedname + " : " + oven.IsOn()); } if (!permission.UserHasPermission(player.UserIDString, perm_freelights) || !IsLightToggle(cleanedname) //(!IsLightPrefabName(cleanedname)) // && !(IsOvenPrefabName(cleanedname) && ProcessShortPrefabName(oven.ShortPrefabName)))) ) { return(null); } else if (oven.IsOn() != true) { //Puts("off going on and allowed " + oven.temperature.ToString() + " : " + oven.cookingTemperature); oven.SetFlag(BaseEntity.Flags.On, true); oven.StopCooking(); oven.allowByproductCreation = false; oven.SetFlag(BaseEntity.Flags.On, true); } else { //Puts("on going off and allowed " + oven.temperature.ToString() + " : " + oven.cookingTemperature); oven.SetFlag(BaseEntity.Flags.On, false); oven.StopCooking(); oven.SetFlag(BaseEntity.Flags.On, false); } // catch all return(null); }
// This is how we take off or land the carpet! object OnOvenToggle(BaseOven oven, BasePlayer player) { bool rtrn = false; // Must match other plugins with this call to avoid conflicts. QuickSmelt uses false CarpetEntity activecarpet; try { activecarpet = player.GetMounted().GetComponentInParent <CarpetEntity>() ?? null; if (activecarpet == null) { oven.StopCooking(); return(rtrn); } } catch { return(null); } if (activecarpet.carpetlock != null && activecarpet.carpetlock.IsLocked()) { PrintMsgL(player, "carpetlocked"); return(rtrn); } if (!player.isMounted) { return(rtrn); // player offline, does not mean ismounted on carpet } if (player.GetMounted() != activecarpet.entity) { return(rtrn); // online player not in seat on carpet } #if DEBUG Puts("OnOvenToggle: Player cycled lantern!"); #endif if (oven.IsOn()) { oven.StopCooking(); } else { oven.StartCooking(); } if (!activecarpet.FuelCheck()) { if (activecarpet.needfuel) { PrintMsgL(player, "nofuel"); PrintMsgL(player, "landingcarpet"); activecarpet.engineon = false; } } var ison = activecarpet.engineon; if (ison) { activecarpet.islanding = true; PrintMsgL(player, "landingcarpet"); return(null); } if (!ison) { AddPlayerToPilotsList(player); activecarpet.engineon = true; return(null); } return(rtrn); }