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);
                }
            }
        }
Пример #2
0
            private void ToggleLight()
            {
                if (lastOn)
                {
                    entity.SetFlag(BaseEntity.Flags.On, false);
                }
                else
                {
                    entity.SetFlag(BaseEntity.Flags.On, true);
                }

                lastOn = !lastOn;
            }
Пример #3
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();
             }
         }
     }
 }
Пример #4
0
        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);
        }
Пример #5
0
            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();
            }
Пример #6
0
        //Overwriting Oven.StartCooking
		void StartCooking(BaseOven oven)
		{
            if ((Settings.UsePermissions && !permission.UserHasPermission(oven.OwnerID.ToString(), permAllow)))
            {
                oven.StartCooking();
                return;
            }
            if (FindBurnable(oven) == null)
            {
                return;
            }
            oven.UpdateAttachmentTemperature();
            var data = oven.transform.GetOrAddComponent<FurnaceData>();
            oven.CancelInvoke(oven.Cook);
            oven.InvokeRepeating(data.CookOverride, 0.5f, 0.5f);
            oven.SetFlag(BaseEntity.Flags.On, true, false);
        }
Пример #7
0
            public void Awake()
            {
                entity = GetComponent <BaseOven>();
                lastOn = false;
                entity.SetFlag(BaseEntity.Flags.On, false);

                var            expEnt    = GameManager.server.CreateEntity("assets/prefabs/tools/c4/explosive.timed.deployed.prefab", entity.transform.position, new Quaternion(), true);
                TimedExplosive explosive = expEnt.GetComponent <TimedExplosive>();

                explosive.timerAmountMax  = ins.configData.Explosives.Timer;
                explosive.timerAmountMin  = ins.configData.Explosives.Timer;
                explosive.explosionRadius = ins.configData.Explosives.Radius;
                explosive.damageTypes     = new List <Rust.DamageTypeEntry> {
                    new Rust.DamageTypeEntry {
                        amount = ins.configData.Explosives.Amount, type = Rust.DamageType.Explosion
                    }
                };
                explosive.Spawn();

                entity.InvokeRepeating(this.ToggleLight, 0.5f, 0.5f);
            }
Пример #8
0
        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);
        }
Пример #9
0
        // 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;
        }