Sub Routines
Craig Dennis
$4.99
Date |
Price |
---|---|
日期和时间 |
价钱($) |
05/30(2022) |
4.99 |
11/17(2024) |
4.99 |
Jump AssetStore
SubRoutines run background tasks based on specific conditions, can be paused and chained for flexibility, and serve as customizable event system in games and other applications.SubRoutines--------------------------------------------------What are SubRoutines and why would I need them?To put it simply once created, a sub routine will run in the background performing an action until a condition is met. Fleshing this idea out further we can build many complex tasks that can run concurrently or within a chain of events, while adding features that makes awkward development much easier to write and code that is easier to read at a glance.Another handy feature is the ability to pause a routine at any time, and chain routines together. This allows for great flexibilty and can act (or be further extended to act) as a very customisable event system for your game. You have full control of how a routine is run.How does it work?Many varieties of tasks can be defined by 2 simple things: a condition and an action. This package provides all of the background work by testing and running these tasks according to the current frame rate while giving a simple interface to create them. The package comes with a static class named SubRoutines which contains a variety of common understandable methods to easily interface with such as “Wait”, “While” and “RunFor”, which act as a great foundation for any type of time / condition based task.See the documentation for more information on how to use the SubRoutines package and what it can be used for.Public static methods (Called with SubRoutines.MethodName)--------------------------------------------------While: The foundational sub routine, use this to create further static routine methods. If condition is true then invoke action, otherwise invoke callback, then the sub routine will be automatically disposed of.Always: Creates a sub routine that invokes action every frame.When: Waits until condition is true and then invokes action.Wait: Waits for the specified time and then invokes action.RunFor: Invokes action every frame until the specified time is met, then finally invokes callback.Repeat: Repeats action a certain number of times (or infinitely) every interval seconds.RunNextFrame: Waits one frame and then calls action.RunAfterXFrames: Waits numFrames frames and then calls action.RunForXFrames: Invoke action for a specified number of frames (numFrames), passing the current number of frames elapsed into action (f), then invokes callback on the last frame.Do: Call action immediately. Note that this is only ever useful within a chain of events.Chain: Invoke a chain of SubRoutines, waiting for one to finish before moving on to the next. Note that Chains can be nested, which will be run concurrently by default.GetInstance: Get game object instance.RemoveSubRoutine: Remove a SubRoutine.RemoveAllSubRoutines: Remove all SubRoutines.Documentation:-----------------------https://mugheadstudios.com/files/SubRoutines_Documentation.pdf?2Contact:-----------------------Any questions or suggestions? Please feel free to contact me at zephni@hotmail.co.uk