Esempio n. 1
0
 public Chore(ChoreType chore_type, ChoreProvider chore_provider, bool run_until_complete, Action <Chore> on_complete, Action <Chore> on_begin, Action <Chore> on_end, PriorityScreen.PriorityClass priority_class, int priority_value, bool is_preemptable, bool allow_in_context_menu, int priority_mod, bool add_to_daily_report, ReportManager.ReportType report_type)
 {
     if (priority_value == 2147483647)
     {
         priority_class = PriorityScreen.PriorityClass.topPriority;
         priority_value = 2;
     }
     if (priority_value < 1 || priority_value > 9)
     {
         Debug.LogErrorFormat("Priority Value Out Of Range: {0}", priority_value);
     }
     masterPriority = new PrioritySetting(priority_class, priority_value);
     priorityMod    = priority_mod;
     id             = ++nextId;
     if ((UnityEngine.Object)chore_provider == (UnityEngine.Object)null)
     {
         chore_provider = GlobalChoreProvider.Instance;
         DebugUtil.Assert((UnityEngine.Object)chore_provider != (UnityEngine.Object)null);
     }
     choreType        = chore_type;
     runUntilComplete = run_until_complete;
     onComplete       = on_complete;
     onEnd            = on_end;
     onBegin          = on_begin;
     IsPreemptable    = is_preemptable;
     AddPrecondition(ChorePreconditions.instance.IsValid, null);
     AddPrecondition(ChorePreconditions.instance.IsPermitted, null);
     AddPrecondition(ChorePreconditions.instance.IsPreemptable, null);
     AddPrecondition(ChorePreconditions.instance.HasUrge, null);
     AddPrecondition(ChorePreconditions.instance.IsMoreSatisfyingEarly, null);
     AddPrecondition(ChorePreconditions.instance.IsMoreSatisfyingLate, null);
     AddPrecondition(ChorePreconditions.instance.IsOverrideTargetNullOrMe, null);
     chore_provider.AddChore(this);
 }
        public void RecoverEmote()
        {
            int num = Random.Range(0, 9);

            if (num == 8)
            {
                ChoreProvider component = base.master.GetComponent <ChoreProvider>();
                new EmoteChore(component, Db.Get().ChoreTypes.EmoteHighPriority, "anim_react_floor_missing_kanim", new HashedString[1]
                {
                    "react"
                }, KAnim.PlayMode.Once, flipRecoverEmote);
            }
        }
    public GameObject Deliver(Vector3 location)
    {
        GameObject gameObject = Util.KInstantiate(Assets.GetPrefab(MinionConfig.ID), null, null);

        gameObject.SetActive(true);
        gameObject.transform.SetLocalPosition(location);
        Apply(gameObject);
        Immigration.Instance.ApplyDefaultPersonalPriorities(gameObject);
        ChoreProvider component = gameObject.GetComponent <ChoreProvider>();

        new EmoteChore(component, Db.Get().ChoreTypes.EmoteHighPriority, "anim_interacts_portal_kanim", Telepad.PortalBirthAnim, null);
        return(gameObject);
    }
    public ChoreConsumerState(ChoreConsumer consumer)
    {
        this.consumer       = consumer;
        navigator           = consumer.GetComponent <Navigator>();
        prefabid            = consumer.GetComponent <KPrefabID>();
        ownable             = consumer.GetComponent <Ownable>();
        gameObject          = consumer.gameObject;
        solidTransferArm    = consumer.GetComponent <SolidTransferArm>();
        hasSolidTransferArm = ((Object)solidTransferArm != (Object)null);
        resume        = consumer.GetComponent <MinionResume>();
        choreDriver   = consumer.GetComponent <ChoreDriver>();
        schedulable   = consumer.GetComponent <Schedulable>();
        traits        = consumer.GetComponent <Traits>();
        choreProvider = consumer.GetComponent <ChoreProvider>();
        MinionIdentity component = consumer.GetComponent <MinionIdentity>();

        if ((Object)component != (Object)null)
        {
            if (component.assignableProxy == null)
            {
                component.assignableProxy = MinionAssignablesProxy.InitAssignableProxy(component.assignableProxy, component);
            }
            assignables = component.GetSoleOwner();
            equipment   = component.GetEquipment();
        }
        else
        {
            assignables = consumer.GetComponent <Assignables>();
            equipment   = consumer.GetComponent <Equipment>();
        }
        storage            = consumer.GetComponent <Storage>();
        consumableConsumer = consumer.GetComponent <ConsumableConsumer>();
        worker             = consumer.GetComponent <Worker>();
        selectable         = consumer.GetComponent <KSelectable>();
        if ((Object)schedulable != (Object)null)
        {
            int blockIdx = Schedule.GetBlockIdx();
            scheduleBlock = schedulable.GetSchedule().GetBlock(blockIdx);
        }
    }
 public void RemoveProvider(ChoreProvider provider)
 {
     providers.Remove(provider);
 }
 public void AddProvider(ChoreProvider provider)
 {
     DebugUtil.Assert((UnityEngine.Object)provider != (UnityEngine.Object)null);
     providers.Add(provider);
 }
    public bool FindNextChore(ref Chore.Precondition.Context out_context)
    {
        if (debug)
        {
            int num = 0;
            num++;
        }
        preconditionSnapshot.Clear();
        consumerState.Refresh();
        if (consumerState.hasSolidTransferArm)
        {
            Debug.Assert(stationaryReach > 0);
            CellOffset offset  = Grid.GetOffset(Grid.PosToCell(this));
            Extents    extents = new Extents(offset.x, offset.y, stationaryReach);
            ListPool <ScenePartitionerEntry, ChoreConsumer> .PooledList pooledList = ListPool <ScenePartitionerEntry, ChoreConsumer> .Allocate();

            GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.fetchChoreLayer, pooledList);
            foreach (ScenePartitionerEntry item in pooledList)
            {
                if (item.obj == null)
                {
                    DebugUtil.Assert(false, "FindNextChore found an entry that was null");
                }
                else
                {
                    FetchChore fetchChore = item.obj as FetchChore;
                    if (fetchChore == null)
                    {
                        DebugUtil.Assert(false, "FindNextChore found an entry that wasn't a FetchChore");
                    }
                    else if (fetchChore.target == null)
                    {
                        DebugUtil.Assert(false, "FindNextChore found an entry with a null target");
                    }
                    else if (fetchChore.isNull)
                    {
                        Debug.LogWarning("FindNextChore found an entry that isNull");
                    }
                    else
                    {
                        int cell = Grid.PosToCell(fetchChore.gameObject);
                        if (consumerState.solidTransferArm.IsCellReachable(cell))
                        {
                            fetchChore.CollectChoresFromGlobalChoreProvider(consumerState, preconditionSnapshot.succeededContexts, preconditionSnapshot.failedContexts, false);
                        }
                    }
                }
            }
            pooledList.Recycle();
        }
        else
        {
            for (int i = 0; i < providers.Count; i++)
            {
                ChoreProvider choreProvider = providers[i];
                choreProvider.CollectChores(consumerState, preconditionSnapshot.succeededContexts, preconditionSnapshot.failedContexts);
            }
        }
        preconditionSnapshot.succeededContexts.Sort();
        List <Chore.Precondition.Context> succeededContexts = preconditionSnapshot.succeededContexts;
        bool flag = ChooseChore(ref out_context, succeededContexts);

        if (flag)
        {
            preconditionSnapshot.CopyTo(lastSuccessfulPreconditionSnapshot);
        }
        return(flag);
    }