void CheckOven(BaseOven oven)
        {
            string pfn = oven.PrefabName.ToLower();

            if (pfn.Contains("campfire"))
            {
                if (config.CampFires)
                {
                    oven.StopCooking();
                    oven.SetFlag(BaseEntity.Flags.On, false);
                }
            }
            else if (pfn.Contains("furnace"))
            {
                if (config.Furnaces)
                {
                    oven.StopCooking();
                    oven.SetFlag(BaseEntity.Flags.On, false);
                }
            }
            else
            {
                if (config.Lanterns)
                {
                    oven.StopCooking();
                    oven.SetFlag(BaseEntity.Flags.On, false);
                }
            }
        }
Exemple #2
0
 void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable)
 {
     if (!MessageDone)
     {
         Puts("Fire Burning.... LIGHTS OUT !! time is " + sky.Cycle.DateTime + "|" + oven.ToString());
         //PrintToChat("Night time, Fires Buring.... LIGHTS OUT !! time is " + sky.Cycle.DateTime + " Dont forget to /vote ^_*");
         PrintToChat(lang.GetMessage("nightTime", this).Replace("{time}", sky.Cycle.DateTime.ToString()));
         lightsList.Add("MessageDone");
         MessageDone = true;
     }
     //DEBUG LINE //PrintToChat(" Is Night: " + sky.IsNight.ToString() + "|" + oven.ToString() + "| RUST Time: " + sky.Cycle.DateTime.ToString("HH:mm:ss")); //DEBUG
     //if (sky.Cycle.Hour >= 18 && sky.Cycle.Hour <= 6) // <-- another way to do it with more targeted times ?
     if (sky.IsNight)
     {
         if (lightsList != null)
         {
             if (lightsList.Contains(oven.ToString()) == false)
             {
                 oven.StopCooking();
                 oven.SetFlag(BaseEntity.Flags.On, false);
                 lightsList.Add(oven.ToString());
             }
         }
     }
     else
     {
         if (lightsList != null)
         {
             if (lightsList.Count > 0)
             {
                 lightsList.Clear();
             }
         }
     }
 }
Exemple #3
0
        void StopCooking(BaseOven oven)
        {
            var data = oven.transform.GetOrAddComponent <FurnaceData>();

            oven.CancelInvoke(data.CookOverride);
            oven.StopCooking();
        }
        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);
        }
            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();
            }
        private object OnFindBurnable(BaseOven oven)
        {
            bool hasperm = false;

            if (oven == null || string.IsNullOrEmpty(oven.ShortPrefabName) ||
                oven.OwnerID == null || oven.OwnerID == 0U || oven.OwnerID.ToString() == null)
            {
                return(null);
            }
            else
            {
                hasperm = permission.UserHasPermission(oven.OwnerID.ToString(), perm_freelights);
            }

            if (hasperm != true ||
                !ProcessShortPrefabName(oven.ShortPrefabName) ||
                !IsLightPrefabName(oven.ShortPrefabName))
            {
                return(null);
            }
            else
            {
                //Puts("OnFindBurnable: " + oven.ShortPrefabName + " : " + oven.cookingTemperature);
                oven.StopCooking();
                oven.allowByproductCreation = false;
                oven.SetFlag(BaseEntity.Flags.On, true);
                if (oven.fuelType != null && oven.fuelType.itemid != null)
                {
                    return(ItemManager.CreateByItemID(oven.fuelType.itemid));
                }
                else
                {
                    return(null);
                }
            }
            // catch all
            return(null);
        }
        // for jack o laterns
        private void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable)
        {
            if (oven == null || string.IsNullOrEmpty(oven.ShortPrefabName) ||
                oven.OwnerID == null || oven.OwnerID == 0U || oven.OwnerID.ToString() == null)
            {
                return;
            }

            if (!permission.UserHasPermission(oven.OwnerID.ToString(), perm_freelights) ||
                !ProcessShortPrefabName(oven.ShortPrefabName) ||
                !IsLightPrefabName(oven.ShortPrefabName))
            {
                return;
            }
            else
            {
                fuel.amount += 1;
                oven.StopCooking();
                oven.allowByproductCreation = false;
                oven.SetFlag(BaseEntity.Flags.On, true);
            }
            // catch all
            return;
        }
        // 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);
        }