コード例 #1
0
    private void UpdateStatus()
    {
        float       num         = hitPoints / maxHitPoints;
        HealthState healthState = (State == HealthState.Invincible) ? HealthState.Invincible : ((!(num >= 1f)) ? ((num >= 0.85f) ? HealthState.Alright : ((num >= 0.66f) ? HealthState.Scuffed : (((double)num >= 0.33) ? HealthState.Injured : ((num > 0f) ? HealthState.Critical : ((num != 0f) ? HealthState.Dead : HealthState.Incapacitated))))) : HealthState.Perfect);

        if (State != healthState)
        {
            if (State == HealthState.Incapacitated && healthState != HealthState.Dead)
            {
                Recover();
            }
            if (healthState == HealthState.Perfect)
            {
                Trigger(-1491582671, this);
            }
            State = healthState;
            KSelectable component = GetComponent <KSelectable>();
            if (State != HealthState.Dead && State != 0 && State != HealthState.Alright)
            {
                component.SetStatusItem(Db.Get().StatusItemCategories.Hitpoints, Db.Get().CreatureStatusItems.HealthStatus, State);
            }
            else
            {
                component.SetStatusItem(Db.Get().StatusItemCategories.Hitpoints, null, null);
            }
        }
    }
コード例 #2
0
 private void UpdateStatus()
 {
     if (operational.IsActive)
     {
         if (lowTempLag >= 1f && !showingLowTemp)
         {
             statusHandle   = ((!isLiquidConditioner) ? selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.CoolingStalledColdGas, this) : selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.CoolingStalledColdLiquid, this));
             showingLowTemp = true;
             showingHotEnv  = false;
         }
         else if (lowTempLag <= 0f && (showingHotEnv || showingLowTemp))
         {
             statusHandle   = selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.Cooling, null);
             showingLowTemp = false;
             showingHotEnv  = false;
         }
         else if (statusHandle == Guid.Empty)
         {
             statusHandle   = selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.Cooling, null);
             showingLowTemp = false;
             showingHotEnv  = false;
         }
     }
     else
     {
         statusHandle = selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, null, null);
     }
 }
コード例 #3
0
 private void SetStatusItem()
 {
     if (_defaultPermission != 0 || savedPermissions.Count > 0)
     {
         selectable.SetStatusItem(Db.Get().StatusItemCategories.AccessControl, accessControlActive, null);
     }
     else
     {
         selectable.SetStatusItem(Db.Get().StatusItemCategories.AccessControl, null, null);
     }
 }
コード例 #4
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);
                }
            }
        }
    }
コード例 #5
0
    private void UpdateBuildState(Chore chore)
    {
        KSelectable component = GetComponent <KSelectable>();

        if (chore.InProgress())
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.UnderConstruction, null);
        }
        else
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.UnderConstructionNoWorker, null);
        }
    }
コード例 #6
0
        #pragma warning restore 649


        public void Sim200ms(float dt)
        {
            int object_count = object_sender.get_objects_count();

            if (object_count != 0)
            {
                selectable.SetStatusItem(Z.dropBoxStatus,
                                         Z.dropBoxSending,
                                         object_count);
            }
            else
            {
                selectable.SetStatusItem(Z.dropBoxStatus, null, null);
            }
        }
コード例 #7
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     if (!IsThereLiquid())
     {
         base.gameObject.DeleteObject();
     }
     else
     {
         Grid.Objects[Grid.PosToCell(base.gameObject), 8] = base.gameObject;
         new WorkChore <Moppable>(Db.Get().ChoreTypes.Mop, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
         SetWorkTime(float.PositiveInfinity);
         KSelectable component = GetComponent <KSelectable>();
         component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().MiscStatusItems.WaitingForMop, null);
         Subscribe(493375141, OnRefreshUserMenuDelegate);
         overrideAnims = new KAnimFile[1]
         {
             Assets.GetAnim("anim_mop_dirtywater_kanim")
         };
         partitionerEntry = GameScenePartitioner.Instance.Add("Moppable.OnSpawn", base.gameObject, new Extents(Grid.PosToCell(this), new CellOffset[1]
         {
             new CellOffset(0, 0)
         }), GameScenePartitioner.Instance.liquidChangedLayer, OnLiquidChanged);
         Refresh();
         Subscribe(-1432940121, OnReachableChangedDelegate);
         ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
         instance.StartSM();
         SimAndRenderScheduler.instance.Remove(this);
     }
 }
コード例 #8
0
    public virtual void SetStage(string stage_id, bool skip_effect)
    {
        Stage stage = null;

        for (int i = 0; i < stages.Count; i++)
        {
            if (stages[i].id == stage_id)
            {
                stage = stages[i];
                break;
            }
        }
        if (stage == null)
        {
            Debug.LogError("Missing stage: " + stage_id);
        }
        else
        {
            currentStage = stage.id;
            GetComponent <KAnimControllerBase>().Play(stage.anim, KAnim.PlayMode.Once, 1f, 0f);
            if (stage.decor != 0)
            {
                AttributeModifier modifier = new AttributeModifier(Db.Get().BuildingAttributes.Decor.Id, (float)stage.decor, "Art Quality", false, false, true);
                this.GetAttributes().Add(modifier);
            }
            KSelectable component = GetComponent <KSelectable>();
            component.SetName(stage.name);
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, statuses[stage.statusItem], this);
            shouldShowSkillPerkStatusItem = false;
            UpdateStatusItem(null);
        }
    }
コード例 #9
0
 protected virtual void End(string reason)
 {
     if ((UnityEngine.Object)driver != (UnityEngine.Object)null)
     {
         KSelectable component = driver.GetComponent <KSelectable>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             component.SetStatusItem(Db.Get().StatusItemCategories.Main, null, null);
         }
     }
     StateMachine.Instance sMI      = GetSMI();
     StateMachine.Instance instance = sMI;
     instance.OnStop = (Action <string, StateMachine.Status>)Delegate.Remove(instance.OnStop, new Action <string, StateMachine.Status>(OnStateMachineStop));
     sMI.StopSM(reason);
     if (!((UnityEngine.Object)driver == (UnityEngine.Object)null))
     {
         lastDriver = driver;
         driver     = null;
         if (onEnd != null)
         {
             onEnd(this);
         }
         if (onExit != null)
         {
             onExit(this);
         }
         driver = null;
     }
 }
コード例 #10
0
    public virtual void Begin(Precondition.Context context)
    {
        if ((UnityEngine.Object)driver != (UnityEngine.Object)null)
        {
            Debug.LogErrorFormat("Chore.Begin driver already set {0} {1} {2}, provider {3}, driver {4} -> {5}", id, GetType(), choreType.Id, provider, driver, context.consumerState.choreDriver);
        }
        if ((UnityEngine.Object)provider == (UnityEngine.Object)null)
        {
            Debug.LogErrorFormat("Chore.Begin provider is null {0} {1} {2}, provider {3}, driver {4}", id, GetType(), choreType.Id, provider, driver);
        }
        driver = context.consumerState.choreDriver;
        StateMachine.Instance sMI      = GetSMI();
        StateMachine.Instance instance = sMI;
        instance.OnStop = (Action <string, StateMachine.Status>)Delegate.Combine(instance.OnStop, new Action <string, StateMachine.Status>(OnStateMachineStop));
        KSelectable component = driver.GetComponent <KSelectable>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, GetStatusItem(), this);
        }
        sMI.StartSM();
        if (onBegin != null)
        {
            onBegin(this);
        }
    }
コード例 #11
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        int num = Grid.PosToCell(this);

        originalDigElement = Grid.Element[num];
        KSelectable component = GetComponent <KSelectable>();

        component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().MiscStatusItems.WaitingForDig, null);
        UpdateColor(isReachable);
        Grid.Objects[num, 7] = base.gameObject;
        ChoreType chore_type = Db.Get().ChoreTypes.Dig;

        if (choreTypeIdHash.IsValid)
        {
            chore_type = Db.Get().ChoreTypes.GetByHash(choreTypeIdHash);
        }
        chore = new WorkChore <Diggable>(chore_type, this, null, true, null, null, null, true, null, false, true, null, true, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
        SetWorkTime(float.PositiveInfinity);
        partitionerEntry = GameScenePartitioner.Instance.Add("Diggable.OnSpawn", base.gameObject, Grid.PosToCell(this), GameScenePartitioner.Instance.solidChangedLayer, OnSolidChanged);
        OnSolidChanged(null);
        ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
        instance.StartSM();
        Subscribe(493375141, OnRefreshUserMenuDelegate);
        handle = Game.Instance.Subscribe(-1523247426, UpdateStatusItem);
        Components.Diggables.Add(this);
    }
コード例 #12
0
ファイル: StirlingEngine.cs プロジェクト: romen-h/ONI-Mods
            public void UpdateStatusItems()
            {
                KSelectable component = GetComponent <KSelectable>();

                insufficientGradientHandle = UpdateStatusItem(insufficientTemperatureGradientStatusItem, insufficientGradient, insufficientGradientHandle, component);
                buildingTooHotHandle       = UpdateStatusItem(buildingTooHotStatusItem, buildingTooHot, buildingTooHotHandle, component);
                heatPumpedHandle           = UpdateStatusItem(heatPumpedStatusItem, true, heatPumpedHandle, component);

                StatusItem power_status_item = base.master.operational.IsActive ? activeWattageStatusItem : Db.Get().BuildingStatusItems.GeneratorOffline;

                activeWattageHandle = component.SetStatusItem(Db.Get().StatusItemCategories.Power, power_status_item, base.master);

                StatusItem heat_status_item = base.master.operational.IsActive ? heatProducedStatusItem : Db.Get().BuildingStatusItems.GeneratorOffline;

                heatProductionHandle = component.SetStatusItem(Db.Get().StatusItemCategories.Heat, heat_status_item, base.master);
            }
コード例 #13
0
 protected void OnActiveChanged(object is_active)
 {
     if (operational.IsActive)
     {
         KSelectable component = GetComponent <KSelectable>();
         component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.ManualGeneratorChargingUp, null);
     }
 }
コード例 #14
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            selectable.SetStatusItem(Db.Get().StatusItemCategories.Main,
                                     Z.coordinates, (object)this);

            Grid.CellToXY(Grid.PosToCell(this), out x, out y);
        }
コード例 #15
0
    public static void SetStatusItems(KSelectable selectable, bool refrigerated, RotAtmosphereQuality atmoshpere)
    {
        selectable.SetStatusItem(Db.Get().StatusItemCategories.PreservationTemperature, (!refrigerated) ? Db.Get().CreatureStatusItems.Unrefrigerated : Db.Get().CreatureStatusItems.Refrigerated, selectable);
        switch (atmoshpere)
        {
        case RotAtmosphereQuality.Normal:
            selectable.SetStatusItem(Db.Get().StatusItemCategories.PreservationAtmosphere, null, null);
            break;

        case RotAtmosphereQuality.Contaminating:
            selectable.SetStatusItem(Db.Get().StatusItemCategories.PreservationAtmosphere, Db.Get().CreatureStatusItems.ContaminatedAtmosphere, null);
            break;

        case RotAtmosphereQuality.Sterilizing:
            selectable.SetStatusItem(Db.Get().StatusItemCategories.PreservationAtmosphere, Db.Get().CreatureStatusItems.SterilizingAtmosphere, null);
            break;
        }
    }
コード例 #16
0
        #pragma warning restore 649


        public void Sim200ms(float dt)
        {
            string error = Z.net.get_connection_error();

            if (error != null)
            {
                Z.notConnected.AddNotification("",
                                               Z.notConnected.GetName(error),
                                               Z.notConnected.GetTooltip(error)
                                               );
                selectable.SetStatusItem(Z.serverStatus,
                                         Z.notConnected,
                                         error);
            }
            else
            {
                selectable.SetStatusItem(Z.serverStatus, null, null);
            }
        }
コード例 #17
0
    private void UpdateStatusString()
    {
        KSelectable component = GetComponent <KSelectable>();

        if (!((Object)component == (Object)null))
        {
            StatusItem statusItem = null;
            component.SetStatusItem(status_item: (assignee == null) ? Db.Get().BuildingStatusItems.Unassigned : ((assignee is MinionIdentity) ? Db.Get().BuildingStatusItems.AssignedTo : ((!(assignee is Room)) ? Db.Get().BuildingStatusItems.AssignedTo : Db.Get().BuildingStatusItems.AssignedTo)), category: Db.Get().StatusItemCategories.Main, data: this);
        }
    }
コード例 #18
0
            public void UpdateStatusItems()
            {
                KSelectable component = base.GetComponent <KSelectable>();

                this.insufficientMassHandle        = this.UpdateStatusItem(SteamTurbine.insufficientMassStatusItem, this.insufficientMass, this.insufficientMassHandle, component);
                this.insufficientTemperatureHandle = this.UpdateStatusItem(SteamTurbine.insufficientTemperatureStatusItem, this.insufficientTemperature, this.insufficientTemperatureHandle, component);
                this.buildingTooHotHandle          = this.UpdateStatusItem(SteamTurbine.buildingTooHotItem, this.buildingTooHot, this.buildingTooHotHandle, component);
                bool       isActive    = base.master.operational.IsActive;
                StatusItem status_item = (!isActive) ? Db.Get().BuildingStatusItems.GeneratorOffline : SteamTurbine.activeWattageStatusItem;

                this.activeWattageHandle = component.SetStatusItem(Db.Get().StatusItemCategories.Power, status_item, base.master);
            }
コード例 #19
0
ファイル: InfiniteSource.cs プロジェクト: romen-h/ONI-Mods
        protected override void OnSpawn()
        {
            base.OnSpawn();

            outputCell = building.GetUtilityOutputCell();

            Conduit.GetFlowManager(conduitType).AddConduitUpdater(ConduitUpdate);

            filterable.onFilterChanged += new Action <Tag>(OnFilterChanged);
            OnFilterChanged(filterable.SelectedTag);

            selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, filterStatusItem, this);
        }
コード例 #20
0
    protected void UpdateStatusItem()
    {
        KSelectable component = GetComponent <KSelectable>();

        if ((Object)Occupant != (Object)null)
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.EntityReceptacle, null, null);
        }
        else if (fetchChore != null)
        {
            bool flag = (Object)fetchChore.fetcher != (Object)null;
            if (!flag)
            {
                Tag[] tags = fetchChore.tags;
                foreach (Tag tag in tags)
                {
                    if (WorldInventory.Instance.GetTotalAmount(tag) > 0f)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if (flag)
            {
                component.SetStatusItem(Db.Get().StatusItemCategories.EntityReceptacle, statusItemAwaitingDelivery, null);
            }
            else
            {
                component.SetStatusItem(Db.Get().StatusItemCategories.EntityReceptacle, statusItemNoneAvailable, null);
            }
        }
        else
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.EntityReceptacle, statusItemNeed, null);
        }
    }
コード例 #21
0
ファイル: UVCleaner.cs プロジェクト: ragzilla/sky-oni-mods
 private void UpdateStatus()
 {
     if (operational.IsActive)
     {
         if (statusHandle == Guid.Empty)
         {
             statusHandle = selectable.SetStatusItem(Db.Get().StatusItemCategories.Main,
                                                     Db.Get().BuildingStatusItems.Working);
         }
         else
         {
             selectable.ReplaceStatusItem(statusHandle, Db.Get().BuildingStatusItems.Working);
         }
     }
     else
     {
         if (statusHandle != Guid.Empty)
         {
             statusHandle = selectable.RemoveStatusItem(statusHandle);
         }
     }
 }
コード例 #22
0
        protected override void OnPrefabInit()
        {
            base.OnPrefabInit();

            if (EggCritterSurplus.capacityStatusItem == null)
            {
                EggCritterSurplus.capacityStatusItem = new StatusItem("StorageLocker", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022);
                EggCritterSurplus.capacityStatusItem.resolveStringCallback = (Func <string, object, string>)((str, data) =>
                {
                    IUserControlledCapacity controlledCapacity = (IUserControlledCapacity)data;
                    string newValue1 = Util.FormatWholeNumber(Mathf.Floor(controlledCapacity.AmountStored));
                    string newValue2 = Util.FormatWholeNumber(controlledCapacity.UserMaxCapacity);
                    str = str.Replace("{Stored}", newValue1).Replace("{Capacity}", newValue2).Replace("{Units}", (string)controlledCapacity.CapacityUnits);
                    return(str);
                });
            }
            KSelectable selectable = this.GetComponent <KSelectable>();

            if (selectable != null)
            {
                selectable.SetStatusItem(Db.Get().StatusItemCategories.Main, EggCritterSurplus.capacityStatusItem, (object)this);
            }
        }