Esempio n. 1
0
 public override void InitializeStates(out BaseState default_state)
 {
     default_state     = repaired;
     base.serializable = true;
     forbidden.OnSignal(allow, repaired);
     allowed.Enter(delegate(SMInstance smi)
     {
         smi.master.CreateStorageProxy();
     }).DefaultState(allowed.needMass).EventHandler(GameHashes.BuildingFullyRepaired, delegate(SMInstance smi)
     {
         smi.ConsumeRepairMaterials();
     })
     .EventTransition(GameHashes.BuildingFullyRepaired, repaired, null)
     .OnSignal(forbid, forbidden)
     .Exit(delegate(SMInstance smi)
     {
         smi.DestroyStorageProxy();
     });
     allowed.needMass.Enter(delegate(SMInstance smi)
     {
         Prioritizable.AddRef(smi.master.storageProxy.transform.parent.gameObject);
     }).Exit(delegate(SMInstance smi)
     {
         if (!smi.isMasterNull && (UnityEngine.Object)smi.master.storageProxy != (UnityEngine.Object)null)
         {
             Prioritizable.RemoveRef(smi.master.storageProxy.transform.parent.gameObject);
         }
     }).EventTransition(GameHashes.OnStorageChange, allowed.repairable, (SMInstance smi) => smi.HasRequiredMass())
     .ToggleChore(CreateFetchChore, allowed.repairable, allowed.needMass)
     .ToggleStatusItem(Db.Get().BuildingStatusItems.WaitingForRepairMaterials, (SMInstance smi) => smi.GetRequiredMass());
     allowed.repairable.ToggleRecurringChore(CreateRepairChore, null).ToggleStatusItem(Db.Get().BuildingStatusItems.PendingRepair, (object)null);
     repaired.EventTransition(GameHashes.BuildingReceivedDamage, allowed, (SMInstance smi) => smi.NeedsRepairs()).OnSignal(allow, allowed).OnSignal(forbid, forbidden);
 }
Esempio n. 2
0
    public static void RemoveRef(GameObject go)
    {
        Prioritizable component = go.GetComponent <Prioritizable>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.RemoveRef();
        }
    }
 protected override void OnCleanUp()
 {
     Prioritizable.RemoveRef(base.gameObject);
     if (smi != null)
     {
         smi.StopSM("OnCleanUp");
         smi = null;
     }
     base.OnCleanUp();
 }
Esempio n. 4
0
 private void CancelDisinfection()
 {
     if (isMarkedForDisinfect)
     {
         Prioritizable.RemoveRef(base.gameObject);
         ShowProgressBar(false);
         isMarkedForDisinfect = false;
         chore.Cancel("disinfection cancelled");
         chore = null;
         GetComponent <KSelectable>().RemoveStatusItem(Db.Get().MiscStatusItems.MarkedForDisinfection, this);
     }
 }
Esempio n. 5
0
    protected override void OnCompleteWork(Worker worker)
    {
        base.OnCompleteWork(worker);
        PrimaryElement component = GetComponent <PrimaryElement>();

        component.AddDisease(component.DiseaseIdx, -component.DiseaseCount, "Disinfectable.OnCompleteWork");
        GetComponent <KSelectable>().RemoveStatusItem(Db.Get().MiscStatusItems.MarkedForDisinfection, this);
        isMarkedForDisinfect = false;
        chore = null;
        Game.Instance.userMenu.Refresh(base.gameObject);
        Prioritizable.RemoveRef(base.gameObject);
    }
 private void CancelDeconstruction()
 {
     if (chore != null)
     {
         chore.Cancel("Cancelled deconstruction");
         chore = null;
         GetComponent <KSelectable>().RemoveStatusItem(Db.Get().BuildingStatusItems.PendingDeconstruction, false);
         ShowProgressBar(false);
         isMarkedForDeconstruction = false;
         Prioritizable.RemoveRef(base.gameObject);
     }
 }
Esempio n. 7
0
 private void RemoveInsulate()
 {
     Harmony.AccessTools.Field(typeof(PrimaryElement), "_Element").SetValue(primaryElement, null);
     primaryElement.ElementID = SimHashes.Steel;
     ForceRebuild();
     ForceSimUpdate();
     SpawnItemsFromRemoval();
     this.chore = null;
     Prioritizable.RemoveRef(gameObject);
     Game.Instance.userMenu.Refresh(gameObject);
     isMarkedForWork = false;
 }
Esempio n. 8
0
    protected override void OnCompleteWork(Worker worker)
    {
        Status       artist_skill = Status.Ugly;
        MinionResume component    = worker.GetComponent <MinionResume>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            if (component.HasPerk(Db.Get().SkillPerks.CanArtGreat.Id))
            {
                artist_skill = Status.Great;
            }
            else if (component.HasPerk(Db.Get().SkillPerks.CanArtOkay.Id))
            {
                artist_skill = Status.Okay;
            }
        }
        List <Stage> potential_stages = new List <Stage>();

        stages.ForEach(delegate(Stage item)
        {
            potential_stages.Add(item);
        });
        potential_stages.RemoveAll((Stage x) => x.statusItem > artist_skill || x.id == "Default");
        potential_stages.Sort((Stage x, Stage y) => y.statusItem.CompareTo(x.statusItem));
        Status highest_status = potential_stages[0].statusItem;

        potential_stages.RemoveAll((Stage x) => x.statusItem < highest_status);
        potential_stages.Shuffle();
        SetStage(potential_stages[0].id, false);
        if (potential_stages[0].cheerOnComplete)
        {
            new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_cheer_kanim", new HashedString[3]
            {
                "cheer_pre",
                "cheer_loop",
                "cheer_pst"
            }, null);
        }
        else
        {
            new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_disappointed_kanim", new HashedString[3]
            {
                "disappointed_pre",
                "disappointed_loop",
                "disappointed_pst"
            }, null);
        }
        shouldShowSkillPerkStatusItem = false;
        UpdateStatusItem(null);
        Prioritizable.RemoveRef(base.gameObject);
    }
 public void CancelClearing()
 {
     if (isMarkedForClear)
     {
         isMarkedForClear = false;
         GetComponent <KPrefabID>().RemoveTag(GameTags.Garbage);
         Prioritizable.RemoveRef(base.gameObject);
         if (clearHandle.IsValid())
         {
             GlobalChoreProvider.Instance.UnregisterClearable(clearHandle);
             clearHandle.Clear();
         }
         RefreshClearableStatus();
         SimAndRenderScheduler.instance.Remove(this);
     }
 }
Esempio n. 10
0
        protected override void OnCompleteWork(Worker worker)
        {
            Status       scientist_skill = Status.Ugly;
            MinionResume component       = worker.GetComponent <MinionResume>();

            if (component != null)
            {
                if (component.HasPerk(Db.Get().SkillPerks.AllowInterstellarResearch.Id))
                {
                    scientist_skill = Status.Great;
                }
                else if (component.HasPerk(Db.Get().SkillPerks.CanStudyWorldObjects.Id))
                {
                    scientist_skill = Status.Okay;
                }
            }

            List <Stage> potential_stages = new List <Stage>();

            potential_stages = stages.FindAll(s => s.statusItem.Equals(scientist_skill));
            potential_stages.Shuffle();
            SetStage(potential_stages[0].id, false);

            if (potential_stages[0].cheerOnComplete)
            {
                EmoteChore emoteChore1 = new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_cheer_kanim", new HashedString[3]
                {
                    "cheer_pre",
                    "cheer_loop",
                    "cheer_pst"
                }, null);
            }
            else
            {
                EmoteChore emoteChore2 = new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_disappointed_kanim", new HashedString[3]
                {
                    "disappointed_pre",
                    "disappointed_loop",
                    "disappointed_pst"
                }, null);
            }

            shouldShowSkillPerkStatusItem = false;
            UpdateStatusItem(null);
            Prioritizable.RemoveRef(gameObject);
        }
Esempio n. 11
0
 private void OnMenuToggle()
 {
     if (!Toggleable.IsToggleQueued(ToggleIdx))
     {
         if (IsEnabled)
         {
             Trigger(2108245096, "BuildingDisabled");
         }
         Prioritizable.AddRef(base.gameObject);
     }
     else
     {
         Prioritizable.RemoveRef(base.gameObject);
     }
     Toggleable.Toggle(ToggleIdx);
     Game.Instance.userMenu.Refresh(base.gameObject);
 }
Esempio n. 12
0
 private void Insulate()
 {
     //The insulation build chore has been complete. Ensure the storage is empty (consuming the insulation inside) and update the simulation to reflect the insulation of the conduit
     chore = null;
     //The completion of the chore does not necessarily consume the insulation that was stored. Setting mass to 0 effectively removes them from storage.
     storage.ConsumeAllIgnoringDisease();
     foreach (GameObject item in storage.items)
     {
         item.GetComponent <PrimaryElement>().Mass = 0f;
     }
     //Override the private variable _Element. The variable acts as a cache when the PrimaryElement.Element is retrieved, and will not notice that ElementID has been changed unless _Element is null
     Harmony.AccessTools.Field(typeof(PrimaryElement), "_Element").SetValue(primaryElement, null);
     primaryElement.ElementID = SimHashes.SuperInsulator;
     ForceRebuild();
     ForceSimUpdate();
     chore = null;
     Prioritizable.RemoveRef(gameObject);
     Game.Instance.userMenu.Refresh(gameObject);
     isMarkedForWork = false;
 }
 public void MarkForCapture(bool mark, PrioritySetting priority)
 {
     mark = (mark && IsCapturable());
     if (markedForCapture && !mark)
     {
         Prioritizable.RemoveRef(base.gameObject);
     }
     else if (!markedForCapture && mark)
     {
         Prioritizable.AddRef(base.gameObject);
         Prioritizable component = GetComponent <Prioritizable>();
         if ((bool)component)
         {
             component.SetMasterPriority(priority);
         }
     }
     markedForCapture = mark;
     UpdateStatusItem();
     UpdateChore();
 }
Esempio n. 14
0
 //Cancel the current activity
 private void OnCancel()
 {
     if (chore == null && fetchList == null)
     {
         return;
     }
     if (fetchList != null)
     {
         fetchList.Cancel("Cancelled by user");
         fetchList = null;
         DropStorage();
         MaterialNeeds.Instance.UpdateNeed(ElementLoader.FindElementByHash(SimHashes.SuperInsulator).tag, 0 - MassToInsulate);
     }
     if (chore != null)
     {
         this.chore.Cancel("Cancelled by user");
         this.chore = null;
         this.ShowProgressBar(false);
         this.workTimeRemaining = this.workTime;
         DropStorage();
     }
     Prioritizable.RemoveRef(gameObject);
     isMarkedForWork = false;
 }
 protected override void OnCleanUp()
 {
     Prioritizable.RemoveRef(base.gameObject);
     Components.Clinics.Remove(this);
     base.OnCleanUp();
 }
Esempio n. 16
0
 protected override void OnCleanUp()
 {
     Game.Instance.accumulators.Remove(accumulator);
     Prioritizable.RemoveRef(base.gameObject);
     base.OnCleanUp();
 }
 protected override void OnCleanUp()
 {
     AbortDelivery("ManualDeliverKG destroyed");
     Prioritizable.RemoveRef(base.gameObject);
     base.OnCleanUp();
 }
Esempio n. 18
0
 public void HandleToggle()
 {
     Prioritizable.RemoveRef(base.gameObject);
     OnToggle();
 }