Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.
pointcache edited this page Jan 17, 2017 · 4 revisions

System is a simple MonoBehavior that most likely will use URSA's magic methods in conjunction with SystemsExecutor. To get nice looking label you can inherit from SystemBase.

This is an example of a system:

publicclassTimeSystem:SystemBase{publicdoubledayDelta,prevDayTotal;publicdoubleprevTotaltime;intprevhour=-1;intcurrentHour;voidorderedFixedUpdate(){vartime=Pool<TimeData>.First.data;time.TotalTimePassed+=GetScaledDelta(time);time.DoubleTimeOfDay=time.TotalTimePassed%1;time.DoubleDelta=time.TotalTimePassed-prevTotaltime;time.TimeOfDay.Value=(float)(time.TotalTimePassed%1);if(currentHour!=prevhour){time.Hour.Value=currentHour;prevhour=time.Hour;}currentHour=(int)time.TimeOfDay.Remap(0f,1f,0f,24f);time.Delta=(float)time.DoubleDelta;if(time.TotalTimePassed-prevDayTotal>1.0){time.DoubleTimeOfDay=0.0+time.DoubleDelta;time.TimeOfDay.Value=(float)time.DoubleTimeOfDay;prevDayTotal=time.TotalTimePassed;}prevTotaltime=time.TotalTimePassed;}intGetCurrentHour(doubletod){return(int)(tod*24.0);}doubleGetDaylenght(TimeData.Datatime){return1440.0/time.DayLength;}doubleGetScaledDelta(TimeData.Datatime){doublescaled=Time.deltaTime*GetDaylenght(time);doublescaleBacktoHour=scaled.Remap(0,1440,0,1);doublegetMinute=scaleBacktoHour/60.0;doubleapplyMult=getMinute*time.SpeedMultiplier;returnapplyMult;}}

Despite most other systems being dependent on the work of this one, since all it does is modify the Time component, it is completely decoupled from the rest of the game. You can destroy it and no error will be thrown.

Clone this wiki locally