示例#1
0
 public void Sim1000ms(float dt)
 {
     if (!((UnityEngine.Object) this == (UnityEngine.Object)null))
     {
         if ((UnityEngine.Object)navigator == (UnityEngine.Object)null)
         {
             navigator = GetComponent <Navigator>();
         }
         if (!((UnityEngine.Object)navigator != (UnityEngine.Object)null) || navigator.IsMoving())
         {
             if ((UnityEngine.Object)choreDriver == (UnityEngine.Object)null)
             {
                 choreDriver = GetComponent <ChoreDriver>();
             }
             if ((UnityEngine.Object)choreDriver != (UnityEngine.Object)null)
             {
                 Chore currentChore = choreDriver.GetCurrentChore();
                 if (currentChore != null && currentChore is FetchAreaChore)
                 {
                     MinionResume component = GetComponent <MinionResume>();
                     if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                     {
                         component.AddExperienceWithAptitude(Db.Get().SkillGroups.Hauling.Id, dt, SKILLS.ALL_DAY_EXPERIENCE);
                     }
                 }
             }
         }
     }
 }
        public void EnableRedAlert()
        {
            ChoreDriver component = GetComponent <ChoreDriver>();

            if ((Object)component != (Object)null)
            {
                Chore currentChore = component.GetCurrentChore();
                if (currentChore != null)
                {
                    bool flag = false;
                    for (int i = 0; i < currentChore.GetPreconditions().Count; i++)
                    {
                        Chore.PreconditionInstance preconditionInstance = currentChore.GetPreconditions()[i];
                        if (preconditionInstance.id == ChorePreconditions.instance.IsNotRedAlert.id)
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        component.StopChore();
                    }
                }
            }
        }
示例#3
0
 public override void InitializeStates(out BaseState default_state)
 {
     default_state     = Fresh;
     base.serializable = true;
     root.TagTransition(GameTags.Preserved, Preserved, false).TagTransition(GameTags.Entombed, Preserved, false);
     Fresh.ToggleStatusItem(Db.Get().CreatureStatusItems.Fresh, (Instance smi) => smi).ParamTransition(rotParameter, Stale_Pre, (Instance smi, float p) => p <= smi.def.spoilTime - (smi.def.spoilTime - smi.def.staleTime)).FastUpdate("Rot", rotCB, UpdateRate.SIM_1000ms, true);
     Preserved.TagTransition(PRESERVED_TAGS, Fresh, true).Enter("RefreshModifiers", delegate(Instance smi)
     {
         smi.RefreshModifiers(0f);
     });
     Stale_Pre.Enter(delegate(Instance smi)
     {
         smi.GoTo(Stale);
     });
     Stale.ToggleStatusItem(Db.Get().CreatureStatusItems.Stale, (Instance smi) => smi).ParamTransition(rotParameter, Fresh, (Instance smi, float p) => p > smi.def.spoilTime - (smi.def.spoilTime - smi.def.staleTime)).ParamTransition(rotParameter, Spoiled, GameStateMachine <Rottable, Instance, IStateMachineTarget, Def> .IsLTEZero)
     .FastUpdate("Rot", rotCB, UpdateRate.SIM_1000ms, false);
     Spoiled.Enter(delegate(Instance smi)
     {
         GameObject gameObject = Scenario.SpawnPrefab(Grid.PosToCell(smi.master.gameObject), 0, 0, "RotPile", Grid.SceneLayer.Ore);
         gameObject.gameObject.GetComponent <KSelectable>().SetName(UI.GAMEOBJECTEFFECTS.ROTTEN + " " + smi.master.gameObject.GetProperName());
         gameObject.transform.SetPosition(smi.master.transform.GetPosition());
         gameObject.GetComponent <PrimaryElement>().Mass        = smi.master.GetComponent <PrimaryElement>().Mass;
         gameObject.GetComponent <PrimaryElement>().Temperature = smi.master.GetComponent <PrimaryElement>().Temperature;
         gameObject.SetActive(true);
         PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, ITEMS.FOOD.ROTPILE.NAME, gameObject.transform, 1.5f, false);
         Edible component = smi.GetComponent <Edible>();
         if ((Object)component != (Object)null)
         {
             if ((Object)component.worker != (Object)null)
             {
                 ChoreDriver component2 = component.worker.GetComponent <ChoreDriver>();
                 if ((Object)component2 != (Object)null && component2.GetCurrentChore() != null)
                 {
                     component2.GetCurrentChore().Fail("food rotted");
                 }
             }
             ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, 0f - component.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.ROTTED, "{0}", smi.gameObject.GetProperName()), UI.ENDOFDAYREPORT.NOTES.ROTTED_CONTEXT);
         }
         Util.KDestroyGameObject(smi.gameObject);
     });
 }
    private bool ChooseChore(ref Chore.Precondition.Context out_context, List <Chore.Precondition.Context> succeeded_contexts)
    {
        if (succeeded_contexts.Count == 0)
        {
            return(false);
        }
        Chore currentChore = choreDriver.GetCurrentChore();

        if (currentChore == null)
        {
            for (int num = succeeded_contexts.Count - 1; num >= 0; num--)
            {
                Chore.Precondition.Context context = succeeded_contexts[num];
                if (context.IsSuccess())
                {
                    out_context = context;
                    return(true);
                }
            }
        }
        else
        {
            int interruptPriority = Db.Get().ChoreTypes.TopPriority.interruptPriority;
            int num2 = (currentChore.masterPriority.priority_class != PriorityScreen.PriorityClass.topPriority) ? currentChore.choreType.interruptPriority : interruptPriority;
            for (int num3 = succeeded_contexts.Count - 1; num3 >= 0; num3--)
            {
                Chore.Precondition.Context context2 = succeeded_contexts[num3];
                if (context2.IsSuccess())
                {
                    int num4 = (context2.masterPriority.priority_class != PriorityScreen.PriorityClass.topPriority) ? context2.interruptPriority : interruptPriority;
                    if (num4 > num2 && !currentChore.choreType.interruptExclusion.Overlaps(context2.chore.choreType.tags))
                    {
                        out_context = context2;
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
示例#5
0
        /// <summary>
        /// If the Duplicant has not yet acquired a task, checks for a task that they can
        /// complete during this Finish Tasks block.
        /// </summary>
        private void CheckAcquireChore()
        {
            if (acquireChore)
            {
                var           currentChore = driver.GetCurrentChore();
                PriorityClass pc;
                // Allow acquiring the current chore if it is above idle and below urgent
                if (currentChore != null && (pc = currentChore.masterPriority.priority_class) >
                    PriorityClass.idle && pc < PriorityClass.personalNeeds)
                {
#if DEBUG
                    PUtil.LogDebug("{0} may finish {1}".F(gameObject.name, currentChore.
                                                          GetType().FullName));
#endif
                    acquireChore = false;
                    allowedChore = currentChore;
                }
            }
        }
示例#6
0
 public bool IsEating()
 {
     return(choreDriver.HasChore() && choreDriver.GetCurrentChore().choreType.urge == Db.Get().Urges.Eat);
 }
示例#7
0
        public bool IsEating()
        {
            ChoreDriver component = base.master.GetComponent <ChoreDriver>();

            return(component.HasChore() && component.GetCurrentChore().choreType.urge == Db.Get().Urges.Eat);
        }
 public bool IsEating()
 {
     if ((Object)assigned != (Object)null && assigned.assignee != null)
     {
         GameObject targetGameObject = assigned.assignee.GetSoleOwner().GetComponent <MinionAssignablesProxy>().GetTargetGameObject();
         if ((bool)targetGameObject)
         {
             ChoreDriver component = targetGameObject.GetComponent <ChoreDriver>();
             return((Object)component != (Object)null && component.HasChore() && component.GetCurrentChore().choreType.urge == Db.Get().Urges.Eat);
         }
     }
     return(false);
 }
 public bool IsPeeing()
 {
     return(choreDriver.HasChore() && choreDriver.GetCurrentChore().SatisfiesUrge(Db.Get().Urges.Pee));
 }