Exemplo n.º 1
0
 public void CancelChore()
 {
     if (chore != null)
     {
         chore.Cancel("Manual equip");
         chore = null;
     }
 }
 public void CancelChore()
 {
     if (chore != null)
     {
         chore.Cancel("AutoDisinfectable.CancelChore");
         chore = null;
     }
 }
	protected override void OnAbortWork(Worker worker)
	{
		base.OnAbortWork(worker);
		if (chore != null)
		{
			chore.Cancel("aborted");
		}
		notifier.Remove(notification);
	}
        public void CreateEmptyChore()
        {
            if (emptyChore != null)
            {
                emptyChore.Cancel("dupe");
            }
            DesalinatorWorkableEmpty component = base.master.GetComponent <DesalinatorWorkableEmpty>();

            emptyChore = new WorkChore <DesalinatorWorkableEmpty>(Db.Get().ChoreTypes.EmptyDesalinator, component, null, true, OnEmptyComplete, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, true, true);
        }
        public void CreateEmptyChore()
        {
            if (emptyChore != null)
            {
                emptyChore.Cancel("dupe");
            }
            AlgaeHabitatEmpty component = base.master.GetComponent <AlgaeHabitatEmpty>();

            emptyChore = new WorkChore <AlgaeHabitatEmpty>(Db.Get().ChoreTypes.EmptyStorage, component, null, true, OnEmptyComplete, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, true, true);
        }
Exemplo n.º 6
0
    public void EnergySim200ms(float dt)
    {
        KSelectable component = GetComponent <KSelectable>();

        if (operational.IsActive)
        {
            generator.GenerateJoules(generator.WattageRating * dt, false);
            component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.Wattage, generator);
        }
        else
        {
            generator.ResetJoules();
            component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.GeneratorOffline, null);
            if (operational.IsOperational)
            {
                CircuitManager circuitManager = Game.Instance.circuitManager;
                if (circuitManager != null)
                {
                    ushort circuitID = circuitManager.GetCircuitID(powerCell);
                    bool   flag      = circuitManager.HasBatteries(circuitID);
                    bool   flag2     = false;
                    if (!flag && circuitManager.HasConsumers(circuitID))
                    {
                        flag2 = true;
                    }
                    else if (flag)
                    {
                        if (batteryRefillPercent <= 0f && circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) <= 0f)
                        {
                            flag2 = true;
                        }
                        else if (circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) < batteryRefillPercent)
                        {
                            flag2 = true;
                        }
                    }
                    if (flag2)
                    {
                        if (chore == null && smi.GetCurrentState() == smi.sm.on)
                        {
                            chore = new WorkChore <ManualGenerator>(Db.Get().ChoreTypes.GeneratePower, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
                        }
                    }
                    else if (chore != null)
                    {
                        chore.Cancel("No refill needed");
                        chore = null;
                    }
                    component.ToggleStatusItem(EnergyGenerator.BatteriesSufficientlyFull, !flag2, null);
                }
            }
        }
    }
Exemplo n.º 7
0
            public void CancelToggleChore()
            {
                Debug.Log("Cancel toggle chore!");

                parent.isMarkedForToggle = false;
                if (chore != null)
                {
                    chore.Cancel("User cancelled");
                }
                chore = null;
                selectable.RemoveStatusItem(ToggleStatusItem);
                Game.Instance.userMenu.Refresh(gameObject);
            }
Exemplo n.º 8
0
 public void CreateEmptyChore()
 {
     if (emptyChore != null)
     {
         emptyChore.Cancel("dupe");
     }
     emptyChore = new WorkChore <SmelterWorkableEmpty>(
         chore_type: Db.Get().ChoreTypes.EmptyStorage,
         target: master.GetComponent <SmelterWorkableEmpty>(),
         on_complete: OnEmptyComplete,
         only_when_operational: false,
         ignore_building_assignment: true
         );
 }
Exemplo n.º 9
0
 public void Update(bool update = true)
 {
     if (!updating)
     {
         updating = true;
         int num = 0;
         for (int i = 0; i < choreOffsets.Length; i++)
         {
             CellOffset offset = choreOffsets[i];
             Chore      chore  = chores[i];
             if (update && num < choreCount && IsOffsetValid(offset))
             {
                 num++;
                 if (chore == null || chore.isComplete)
                 {
                     chores[i] = ((CreateChoreCB == null) ? null : CreateChoreCB(i));
                 }
             }
             else if (chore != null)
             {
                 chore.Cancel("locator invalidated");
                 chores[i] = null;
             }
         }
         updating = false;
     }
 }
Exemplo n.º 10
0
 public void CancelChore(object param)
 {
     if (chore != null)
     {
         chore.Cancel("User cancelled");
         chore = null;
     }
 }
 public void CancelChore()
 {
     if (chore != null)
     {
         chore.Cancel("Studyable.CancelChore");
         chore = null;
     }
 }
Exemplo n.º 12
0
 private void CheckHasMaterial(object o = null)
 {
     if (!HasMaterial() && chore != null)
     {
         chore.Cancel("No material remaining");
         chore = null;
     }
 }
Exemplo n.º 13
0
 protected override void OnCompleteWork(Worker worker)
 {
     base.OnCompleteWork(worker);
     if (chore != null && !chore.isComplete)
     {
         chore.Cancel("completed but not complete??");
     }
     chore = CreateChore();
 }
Exemplo n.º 14
0
        protected override void OnCompleteWork(Worker worker)
        {
            base.OnCompleteWork(worker);
            bool flag = (Random.Range(0f, 100f) > vomitChancePercent);

            var effects = worker.GetComponent <Effects>();

            if (effects != null)
            {
                effects.Add(trackingEffectName, true);
                if (flag)
                {
                    effects.Add(specificEffectName, true);
                }

                var chore_provider = worker.GetComponent <ChoreProvider>();
                if (chore_provider != null)
                {
                    if (flag)
                    {
                        int i = Random.Range(0, emote_anims.Length);
                        new EmoteChore(
                            target: chore_provider,
                            chore_type: Db.Get().ChoreTypes.EmoteHighPriority,
                            emote_kanim: emote_anims[i].first,
                            emote_anims: emote_anims[i].second,
                            get_status_item: null
                            );
                    }
                    else
                    {
                        var notification = new Notification(
                            title: STRINGS.DUPLICANTS.STATUSITEMS.CAROUSELVOMITING.NOTIFICATION_NAME,
                            type: NotificationType.BadMinor,
                            tooltip: (List <Notification> notificationList, object data) => STRINGS.DUPLICANTS.STATUSITEMS.CAROUSELVOMITING.NOTIFICATION_TOOLTIP + notificationList.ReduceMessages(false)
#if VANILLA
                            , group: HashedString.Invalid
#endif

                            );
                        new VomitChore(
                            chore_type: Db.Get().ChoreTypes.Vomit,
                            target: chore_provider,
                            status_item: vomitStatusItem,
                            notification: notification
                            );
                    }
                }
            }
            if (chore != null && !chore.isComplete)
            {
                chore.Cancel("completed but not complete??");
            }
            chore = CreateChore();
        }
Exemplo n.º 15
0
 private void CancelEmptying()
 {
     CleanUpVisualization();
     if (chore != null)
     {
         chore.Cancel("Cancel");
         chore = null;
         shouldShowSkillPerkStatusItem = false;
         UpdateStatusItem(null);
     }
 }
 private void UpdateChore()
 {
     if (markedForCapture && chore == null)
     {
         chore = new WorkChore <Capturable>(Db.Get().ChoreTypes.Capture, this, null, true, null, null, null, true, null, false, true, null, true, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
     }
     else if (!markedForCapture && chore != null)
     {
         chore.Cancel("not marked for capture");
         chore = null;
     }
 }
 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);
     }
 }
Exemplo n.º 18
0
 private void OnAssign(IAssignableIdentity obj)
 {
     if (obj != null)
     {
         CreateChore();
     }
     else if (chore != null)
     {
         chore.Cancel("Unassigned");
         chore = null;
     }
 }
 protected virtual void OnCancel(object data)
 {
     if (chore != null)
     {
         chore.Cancel("Cancel harvest");
         chore = null;
         KSelectable component = GetComponent <KSelectable>();
         component.RemoveStatusItem(Db.Get().MiscStatusItems.PendingHarvest, false);
         harvestDesignatable.SetHarvestWhenReady(false);
     }
     harvestDesignatable.MarkedForHarvest = false;
 }
Exemplo n.º 20
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);
     }
 }
Exemplo n.º 21
0
 private void CancelChore()
 {
     if (!cancelling)
     {
         cancelling = true;
         if (chore != null)
         {
             chore.Cancel("order cancelled");
             chore = null;
         }
         cancelling = false;
     }
 }
 public void QueueStateChange(ControlState nextState)
 {
     if (requestedState != nextState)
     {
         requestedState = nextState;
     }
     else
     {
         requestedState = controlState;
     }
     if (requestedState == controlState)
     {
         if (changeStateChore != null)
         {
             changeStateChore.Cancel("Change state");
             changeStateChore = null;
             GetComponent <KSelectable>().RemoveStatusItem(Db.Get().BuildingStatusItems.ChangeDoorControlState, false);
         }
     }
     else if (DebugHandler.InstantBuildMode)
     {
         controlState = requestedState;
         RefreshControlState();
         OnOperationalChanged(null);
         GetComponent <KSelectable>().RemoveStatusItem(Db.Get().BuildingStatusItems.ChangeDoorControlState, false);
         Open();
         Close();
     }
     else
     {
         if (changeStateChore != null)
         {
             changeStateChore.Cancel("Change state");
         }
         GetComponent <KSelectable>().AddStatusItem(Db.Get().BuildingStatusItems.ChangeDoorControlState, this);
         changeStateChore = new WorkChore <Door>(Db.Get().ChoreTypes.Toggle, this, null, true, null, null, null, true, null, false, false, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
     }
 }
Exemplo n.º 23
0
 private void UpdateChore()
 {
     if (operational.IsOperational && EggNeedsAttention())
     {
         if (chore == null)
         {
             chore = new WorkChore <EggIncubatorWorkable>(Db.Get().ChoreTypes.EggSing, workable, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
         }
     }
     else if (chore != null)
     {
         chore.Cancel("now is not the time for song");
         chore = null;
     }
 }
Exemplo n.º 24
0
 public void Sim1000ms(float dt)
 {
     if (KMonoBehaviour.isLoadingScene)
     {
         return;
     }
     if (geyser.FindComponent <Storage>() == null || geyser.FindComponent <ManualDeliveryKG>() == null)
     {
         return;
     }
     if (!geyser.FindComponent <Storage>().showInUI)
     {
         return;
     }
     if (markedForCracking && !maxCracked)
     {
         geyser.GetComponent <ManualDeliveryKG>().Pause(false, "Cracking requested");
         if (chore == null)
         {
             if (geyser.GetComponent <Storage>().MassStored() >= SingletonOptions <ConfigData> .Instance.KgPerCrack)
             {
                 chore = new WorkChore <Crackable>(
                     Db.Get().ChoreTypes.Research, this, null, true,
                     new System.Action <Chore>(OnCracked), null, null, false,
                     null, false, false, null, false, true, true,
                     PriorityScreen.PriorityClass.basic, 5, false, false);
             }
         }
     }
     else
     {
         if (maxCracked)
         {
             geyser.GetComponent <ManualDeliveryKG>().Pause(true, "Cracking complete");
             geyser.GetComponent <Storage>().showInUI = false;
         }
         else
         {
             geyser.GetComponent <ManualDeliveryKG>().Pause(true, "Cracking cancelled");
         }
         if (chore != null)
         {
             chore.Cancel("Cancelled");
             chore = null;
         }
     }
 }
 public void DropAll()
 {
     if (DebugHandler.InstantBuildMode)
     {
         OnCompleteWork(null);
     }
     else if (chore == null)
     {
         chore = new WorkChore <DropAllWorkable>(Db.Get().ChoreTypes.EmptyStorage, this, null, true, null, null, null, true, null, false, false, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
     }
     else
     {
         chore.Cancel("Cancelled emptying");
         chore = null;
         GetComponent <KSelectable>().RemoveStatusItem(workerStatusItem, false);
         ShowProgressBar(false);
     }
 }
    public void UpdateChore()
    {
        IUserControlledCapacity component = GetComponent <IUserControlledCapacity>();

        if (component != null && component.AmountStored > component.UserMaxCapacity)
        {
            if (chore == null)
            {
                chore = new WorkChore <DropToUserCapacity>(Db.Get().ChoreTypes.EmptyStorage, this, null, true, null, null, null, true, null, false, false, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
            }
        }
        else if (chore != null)
        {
            chore.Cancel("Cancelled emptying");
            chore = null;
            GetComponent <KSelectable>().RemoveStatusItem(workerStatusItem, false);
            ShowProgressBar(false);
        }
    }
 public void ToggleDumping()
 {
     if (DebugHandler.InstantBuildMode)
     {
         OnCompleteWork(null);
     }
     else if (isMarkedForDumping)
     {
         isMarkedForDumping = false;
         chore.Cancel("Cancel Dumping!");
         chore = null;
         ShowProgressBar(false);
     }
     else
     {
         isMarkedForDumping = true;
         chore = new WorkChore <Dumpable>(Db.Get().ChoreTypes.EmptyStorage, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
     }
 }
 public void UpdateChores(bool update = true)
 {
     for (int i = 0; i < choreOffsets.Length; i++)
     {
         Chore chore = chores[i];
         if (update)
         {
             if (chore == null || chore.isComplete)
             {
                 chores[i] = CreateChore(i);
             }
         }
         else if (chore != null)
         {
             chore.Cancel("locator invalidated");
             chores[i] = null;
         }
     }
 }
Exemplo n.º 29
0
            public static bool Prefix(AutoDisinfectable __instance, PrimaryElement ___primaryElement, ref Chore ___chore)
            {
                if (KMonoBehaviour.isLoadingScene)
                {
                    return(true);
                }
                if (___primaryElement.DiseaseIdx != RadiationGerms.Index)
                {
                    return(true);
                }

                if (___chore != null)
                {
                    ___chore.Cancel("AutoDisinfect Radiation");
                    ___chore = null;
                }

                return(false);
            }
Exemplo n.º 30
0
 private void PlaceDiggables()
 {
     if (waitForFetchesBeforeDigging && fetchList != null && !hasLadderNearby)
     {
         OnDiggableReachabilityChanged(null);
     }
     else
     {
         bool digs_complete = true;
         if (!solidPartitionerEntry.IsValid())
         {
             Extents validPlacementExtents = building.GetValidPlacementExtents();
             solidPartitionerEntry = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.solidChangedLayer, OnSolidChangedOrDigDestroyed);
             digPartitionerEntry   = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.digDestroyedLayer, OnSolidChangedOrDigDestroyed);
         }
         if (!IsReplacementTile)
         {
             building.RunOnArea(delegate(int offset_cell)
             {
                 PrioritySetting masterPriority = GetComponent <Prioritizable>().GetMasterPriority();
                 if (Diggable.IsDiggable(offset_cell))
                 {
                     digs_complete     = false;
                     Diggable diggable = Diggable.GetDiggable(offset_cell);
                     if ((UnityEngine.Object)diggable == (UnityEngine.Object)null)
                     {
                         diggable = GameUtil.KInstantiate(Assets.GetPrefab(new Tag("DigPlacer")), Grid.SceneLayer.Move, null, 0).GetComponent <Diggable>();
                         diggable.gameObject.SetActive(true);
                         diggable.transform.SetPosition(Grid.CellToPosCBC(offset_cell, Grid.SceneLayer.Move));
                         diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged);
                         Grid.Objects[offset_cell, 7] = diggable.gameObject;
                     }
                     else
                     {
                         diggable.Unsubscribe(-1432940121, OnDiggableReachabilityChanged);
                         diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged);
                     }
                     diggable.choreTypeIdHash = Db.Get().ChoreTypes.BuildDig.IdHash;
                     diggable.GetComponent <Prioritizable>().SetMasterPriority(masterPriority);
                     RenderUtil.EnableRenderer(diggable.transform, false);
                     SaveLoadRoot component = diggable.GetComponent <SaveLoadRoot>();
                     if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                     {
                         UnityEngine.Object.Destroy(component);
                     }
                 }
             });
             OnDiggableReachabilityChanged(null);
         }
         bool flag = building.Def.IsValidBuildLocation(base.gameObject, base.transform.GetPosition(), building.Orientation);
         if (flag)
         {
             notifier.Remove(invalidLocation);
         }
         else
         {
             notifier.Add(invalidLocation, string.Empty);
         }
         GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.InvalidBuildingLocation, !flag, this);
         bool flag2 = digs_complete && flag && fetchList == null;
         if (flag2 && buildChore == null)
         {
             buildChore = new WorkChore <Constructable>(Db.Get().ChoreTypes.Build, this, null, true, UpdateBuildState, UpdateBuildState, UpdateBuildState, true, null, false, true, null, true, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
             UpdateBuildState(buildChore);
         }
         else if (!flag2 && buildChore != null)
         {
             buildChore.Cancel("Need to dig");
             buildChore = null;
         }
     }
 }