Beispiel #1
0
        private void OnNewDay(object data)
        {
            if (lifeCyclesDone)
            {
                return;
            }
            if (currentStage == null || currentStage.ID == "")
            {
                DebugUtil.LogWarningArgs($"[DuplicantLifeExpectancy]: Life Stage for Duplicant {gameObject.GetProperName()} was null during OnNewDay callback. Should have already been set.");
                currentStage = new LifeStage(LifeStagePreset.FirstState);
            }
            float currCycle = GameClock.Instance.GetCycle();

            if (!currentStage.Started)
            {
                if (currentStage.BeginsOn >= currCycle)
                {
                    Effect         e        = currentStage.GetEffect();
                    EffectInstance instance = effects.Add(e, true);

                    currentStage.Started = true;
                }
            }
            else
            {
                if (currCycle >= currentStage.EndsAfter)
                {
                    string nextStage = currentStage.NextStage;
                    if (nextStage != "")
                    {
                        currentStage = new LifeStage(currentStage.NextStage);
                        if (currentStage.BeginsOn == currCycle)
                        {
                            effects.Add(currentStage.GetEffect(), true);
                            currentStage.Started = true;
                        }
                    }
                    else
                    {
                        if (currentStage.IsDying())
                        {
                            DeathMonitor.Instance smi = gameObject.GetSMI <DeathMonitor.Instance>();
                            if (smi != null)
                            {
                                Death OldAge = new Death("OldAge", Db.Get().Deaths, "Old Age", "{Target} has died of old age", "dead_on_back", "dead_on_back");
                                smi.Kill(OldAge);
                            }
                        }
                        else
                        {
                            //There is no next stage. The current stage will be re-applied
                            Effect e = currentStage.GetEffect();
                            effects.Add(e, true);
                            currentStage.BeginsOn = currCycle;
                        }
                    }
                }
            }
        }
Beispiel #2
0
 private void BeginFirstStage()
 {
     if (currentStage == null)
     {
         float currCycle = GameClock.Instance.GetCycle();
         float currTime  = GameClock.Instance.GetTime();
         currentStage = new LifeStage(LifeStagePreset.FirstState);
         if (currentStage.BeginsOn <= currCycle)
         {
             Effect e = currentStage.GetEffect(currTime * -1);
             effects.Add(e, true);
             currentStage.Started = true;
         }
     }
 }