Exemplo n.º 1
0
        public void Sim200ms(float dt)
        {
            var roomOfGameObject = Game.Instance.roomProber.GetRoomOfGameObject(gameObject);

            if (roomOfGameObject != null)
            {
                _currentCritters = roomOfGameObject.cavity.creatures.Count;

                var newState = ActivateAboveThreshold ? _currentCritters > Threshold : _currentCritters < Threshold;

                SetState(newState);

                if (!_selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
                {
                    return;
                }
                _selectable.RemoveStatusItem(_roomStatusGuid);
            }
            else
            {
                if (!_selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
                {
                    _roomStatusGuid = _selectable.AddStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom);
                }

                SetState(false);
            }
        }
    private void UpdateUnworkableStatusItems()
    {
        KSelectable component = GetComponent <KSelectable>();

        if (!base.smi.EnvironmentNeedsCooling())
        {
            if (!component.HasStatusItem(Db.Get().BuildingStatusItems.CannotCoolFurther))
            {
                component.AddStatusItem(Db.Get().BuildingStatusItems.CannotCoolFurther, null);
            }
        }
        else if (component.HasStatusItem(Db.Get().BuildingStatusItems.CannotCoolFurther))
        {
            component.RemoveStatusItem(Db.Get().BuildingStatusItems.CannotCoolFurther, false);
        }
        if (!base.smi.EnvironmentHighEnoughPressure())
        {
            if (!component.HasStatusItem(Db.Get().BuildingStatusItems.UnderPressure))
            {
                component.AddStatusItem(Db.Get().BuildingStatusItems.UnderPressure, null);
            }
        }
        else if (component.HasStatusItem(Db.Get().BuildingStatusItems.UnderPressure))
        {
            component.RemoveStatusItem(Db.Get().BuildingStatusItems.UnderPressure, false);
        }
    }
Exemplo n.º 3
0
        public static bool Prefix(
            LogicCritterCountSensor __instance,
            bool ___activateOnGreaterThan,
            int ___countThreshold,
            KSelectable ___selectable,
            float dt)
        {
            var roomOfGameObject = Game.Instance.roomProber.GetRoomOfGameObject(__instance.gameObject);

            if (roomOfGameObject != null)
            {
//                Debug.Log("房间系统" + roomOfGameObject);
                var currentCount = 0;

                var context = __instance.FindOrAddComponent <LogicCritterCountSensorContext>();

                if (context.CountCreatures)
                {
                    var count = roomOfGameObject.cavity.creatures.Count;
//                    Debug.Log("小动物:" + count);
                    currentCount += count;
                }

                if (context.CountEggs)
                {
                    var count = roomOfGameObject.cavity.eggs.Count;
//                    Debug.Log("蛋:" + count);
                    currentCount += count;
                }

                __instance.SetCurrentCount(currentCount);

                Traverse.Create(__instance).Method("SetState", new[] { typeof(bool) }, new object[]
                {
                    !___activateOnGreaterThan
                            ? currentCount <___countThreshold
                                            : currentCount> ___countThreshold
                })
                .GetValue();
                if (!___selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
                {
                    return(false);
                }
                ___selectable.RemoveStatusItem(Traverse.Create(__instance).Field("roomStatusGUID").GetValue <Guid>());
            }
            else
            {
//                Debug.Log("没有房间");

                if (!___selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
                {
                    Traverse.Create(__instance).Field("roomStatusGUID")
                    .SetValue(___selectable.AddStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom));
                }
                Traverse.Create(__instance).Method("SetState", new[] { typeof(bool) }, new object[] { false })
                .GetValue();
            }

            return(false);
        }
Exemplo n.º 4
0
 private void UpdateStatusItem()
 {
     if (element.id == SimHashes.Vacuum || element.id == SimHashes.Void)
     {
         mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.ElementalCategory, true);
         mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.ElementalTemperature, true);
         mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.ElementalMass, true);
         mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.ElementalDisease, true);
     }
     else
     {
         if (!mSelectable.HasStatusItem(Db.Get().MiscStatusItems.ElementalCategory))
         {
             Func <Element> data = () => element;
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.ElementalCategory, data);
         }
         if (!mSelectable.HasStatusItem(Db.Get().MiscStatusItems.ElementalTemperature))
         {
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.ElementalTemperature, this);
         }
         if (!mSelectable.HasStatusItem(Db.Get().MiscStatusItems.ElementalMass))
         {
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.ElementalMass, this);
         }
         if (!mSelectable.HasStatusItem(Db.Get().MiscStatusItems.ElementalDisease))
         {
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.ElementalDisease, this);
         }
     }
 }
Exemplo n.º 5
0
    public void Sim200ms(float dt)
    {
        Room roomOfGameObject = Game.Instance.roomProber.GetRoomOfGameObject(base.gameObject);

        if (roomOfGameObject != null)
        {
            currentCount = roomOfGameObject.cavity.creatures.Count;
            if (countEggs)
            {
                currentCount += roomOfGameObject.cavity.eggs.Count;
            }
            bool state = (!activateOnGreaterThan) ? (currentCount < countThreshold) : (currentCount > countThreshold);
            SetState(state);
            if (selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
            {
                selectable.RemoveStatusItem(roomStatusGUID, false);
            }
        }
        else
        {
            if (!selectable.HasStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom))
            {
                roomStatusGUID = selectable.AddStatusItem(Db.Get().BuildingStatusItems.NotInAnyRoom, null);
            }
            SetState(false);
        }
    }