public static void CheckLights() { foreach (Item item in World.Items.Values) { if (item is BaseLight && item.ParentEntity == null) { BaseLight light = item as BaseLight; int currentHour, currentMinute; Clock.GetTime(light.Map, light.X, light.Y, out currentHour, out currentMinute); if (currentHour > Settings.IgniteHour || currentHour < Settings.DouseHour) { light.Ignite(); } else if (currentHour > Settings.DouseHour || currentHour < Settings.IgniteHour) { light.Douse(); } } } Timer.DelayCall(System.TimeSpan.FromMinutes(Settings.CheckInterval), delegate { CheckLights(); }); }
protected override void OnTick() { foreach (Item item in World.Items.Values) { if (item is BaseLight && item.Parent == null) { BaseLight light = item as BaseLight; int currentHour, currentMinute; Clock.GetTime(light.Map, light.X, light.Y, out currentHour, out currentMinute); if (currentHour > Config.IgniteHour || currentHour < Config.DouseHour) { light.Ignite(); } else if (currentHour > Config.DouseHour || currentHour < Config.IgniteHour) { light.Douse(); } } } }