Beispiel #1
0
 protected void OnDestroy()
 {
     if (singleton == this)
     {
         singleton = null;
     }
 }
Beispiel #2
0
    public TimeState timeState; //NOTE: We are not able to revert time simulation, its local time reversion and NPC scedule checking

    #endregion

    //PROBLEM: Time ticks are not suitable for anything but local behaviour, we need to base it on time passed
    // Think:   Simulating 500 years by doing 500 1-year-ticks might work, but
    //          simulating a 1 year tick makes one year pass within a tick!!!
    //          This is even a problem when considering a 1-day-tick.
    //          That 1-day-tick will only apply whatever it does after 24h, but then suddenly in one instant, which is wrong!
    //          Theoretically multiple days can pass in one town:
    //          --- sending a 1 day simulation tick to all neighbour regions will only update if one complete day passed!
    //          --- going to that region after 23 hours will not change a thing, then staying there for 1h will suddenly update everything!
    //SOLUTION:
    //          - Ask yourself: What does the year tick do? --> it only does something when we simulate a year passing
    //          - The year tick does not actually simulate year but define what happens the next year? ---> thats not a simulation thats a oracle
    //          - We need some detailed ticks and some Time-Passed simulation
    //

    //FIXME:  We might only need a time passed event, howmuch time has passed is provided with it

    //Stuff that might be on the right track:
    //  A) take all exits of a region and see the needed travel time. Simulate only ticks larger than that time
    //  ---> e.g. if it is < 1h, simulate minutes
    //  ---> Check all regions and find shortest path
    //  ---> Problem: we dont want far away regions to only update every year :(
    //  B) like above, simulate neighbours in minute / hour detail, but simulate everything else at least per day
    //Stuff that wont work:
    //  - Only simulate area when player loads into it. Remember last time plyer was there and take the difference
    //  ---> Problem: The whole world will never change, only regions the player enters :(


    #region init
    protected void Awake()
    {
        if (singleton == null)
        {
            singleton = this;
            DontDestroyOnLoad(singleton);
            init();
        }
        else
        {
            Destroy(this);
        }
    }