One Time

One Time

No permission to download
***** Rate this Resource if you find it useful *****

One Time replaces the need to use timers, it uses events & interfaces instead in creative ways!

Vorspire said:
The concept is neat and the example implementation looks great.
It's easy to use and implement for any dev, which means it's going to be a popular download.


This System uses events and a interface to utilize 6 timers (tick, millisecond, second, minute, hour and day)

All you need to do is hook them up in your scripts, included are TimeTest.cs (event Item) and ITimeTest.cs (interface item) as examples of adding One Time to your scripts!

There is also a Sticky Grass project that will demonstrate different ways to use this system with a more complex method which includes Async.

I advise you read through the discussion, @Vorspire brought up some great points, some of which directly effected this project and the path forward, Thanks again @Vorspire

A few important notes when using events, they cost overhead when you remove them and can mess up the garbage collector if not disposed of when a object is deleted with a event registered in the array.

I have an example in TimeTest.cs of two ways to delete objects with the event registered,

One method is the delayed deletion tag, basically a bool that triggers when it first is targeted for deletion, what this does is shut down the listeners method and makes the object invisible, after next restart, you can then delete them without the overhead of removing events.

The other method is commented out, which is to remove the objects event handle in the OnAfterDelete(), this will cause overhead if there are a lot of objects being deleted at once!

With that said, I have also included NewStickyGrass.cs and Helper.cs which has a event trigger a world item look up and store, this is a great example of using a event outside the objects which allows the objects to be freely deleted without worry of events. Added Async Event example to Helper.cs as of!

Here is the Latest stress test on the sticky grass using async

Here is a video showcasing the New Sticky Grass, which stays hidden until the player is close!

One Time : Code Docs


using Server.OneTime.Events;

OneTimeTickEvent.TickTimerTick += YourMethod();

OneTimeMilliEvent.MilliTimerTick += YourMethod();

OneTimeSecEvent.SecTimerTick += YourMethod();

OneTimeMinEvent.MinTimerTick += YourMethod();

OneTimeHourEvent.HourTimerTick += YourMethod();

OneTimeDayEvent.DayTimerTick += YourMethod();

You can also use a Interface to setup One Time to a Item or Mobile : See ITimeTest.cs for example item


class YourClass : Item, IOneTime //Add interface to your item/mobile class

    public interface IOneTime
        int OneTimeType { get; set; } // 3 = second, 4 = minute, 5 = hour, 6 = day
        void OneTimeTick();

Learn Concept of Events

Learn Basics of Interfaces

Learn Basics of Async
First release
Last update
5.00 star(s) 3 ratings

More resources from GoldDraco13

Latest Updates

  1. Update

    *Updates system, now runs on all servers from RunUO 2.3 to Latest ServUO Repo
  2. Update

    *Cleaned up the code, removed the debug messages! *Added a Pause while Server Saving to avoid...
  3. Update

    *Fixed a potential issue with DateTime.Now

Latest Reviews

I absolutely love this!
Upvote 0
Just figured out how to use this system and i must say it makes timers MUCH easier and streamlined. no need to create timers in each scripts, all you need to do it hook a script up to onetime and your script is connected to a central timer. great idea, works well (we are running runuo).
Thanks for the awesome remarks, I am happy that it works well on RunUO! I look forward to seeing where this project goes overtime, I'm sure it'll get better each update it receives which is driven by feedback! Thanks again!
Upvote 0
awesome idea, i hate writing timers :P
Thanks, I have been working on ways to limit the use of them, which has lead me to creating just one! Combined with Async Methods OnEventTick = Powerful!
Upvote 0