Exemple #1
0
        /// <summary>
        /// Replaces the Refresh method of DecorProvider to handle the decor ourselves.
        /// </summary>
        internal void RefreshDecor()
        {
            // Get status of the object
            var happiness = glumStatus?.attributes?.Get(DecorCellManager.Instance.
                                                        HappinessAttribute);
            // Entombed/disabled = 0 decor, broken = use value in DecorTuning for broken
            bool disabled = (operational != null && !operational.IsFunctional) ||
                            (happiness != null && happiness.GetTotalValue() < 0.0f);
            bool broken = breakStatus != null && breakStatus.IsBroken;

            RefreshCells(broken, disabled);
            // Handle rooms which require an item with 20 decor: has to actually be functional
            bool hasTag   = prefabID.HasTag(RoomConstraints.ConstraintTags.Decor20);
            bool needsTag = provider.decor.GetTotalValue() >= 20f && !broken && !disabled;

            if (hasTag != needsTag)
            {
                int pos = Grid.PosToCell(gameObject);
                // Tag needs to be added/removed
                if (needsTag)
                {
                    prefabID.AddTag(RoomConstraints.ConstraintTags.Decor20, false);
                }
                else
                {
                    prefabID.RemoveTag(RoomConstraints.ConstraintTags.Decor20);
                }
                // Force room recalculation
                if (Grid.IsValidCell(pos))
                {
                    Game.Instance.roomProber.SolidChangedEvent(pos, true);
                }
            }
        }
Exemple #2
0
 public static void Postfix(ref GameObject __result, string onDeathDropID, int onDeathDropCount)
 {
     if (onDeathDropCount > 0 && (onDeathDropID == "Meat" || onDeathDropID == "FishMeat"))
     {
         ExtraMeatSpawner extraMeatSpawner = __result.AddOrGet <ExtraMeatSpawner>();
         extraMeatSpawner.onDeathDropID    = onDeathDropID;
         extraMeatSpawner.onDeathDropCount = onDeathDropCount;
     }
     __result.GetComponent <KPrefabID>().prefabSpawnFn += delegate(GameObject inst)
     {
         if (inst.GetDef <RanchableMonitor.Def>() != null)
         {
             Tag       creatureEligibleTag;
             KPrefabID creature_prefab_id = inst.GetComponent <KPrefabID>();
             if (creature_prefab_id.HasTag(GameTags.SwimmingCreature))
             {
                 creatureEligibleTag = ButcherStation.FisherableCreature;
             }
             else
             {
                 creatureEligibleTag = ButcherStation.ButcherableCreature;
             }
             creature_prefab_id.AddTag(creatureEligibleTag, false);
             WorldInventory.Instance.Discover(creature_prefab_id.PrefabTag, creatureEligibleTag);
         }
     };
 }
Exemple #3
0
    public void OnConditionManagerTagsChanged(object data)
    {
        KPrefabID component = conditionManager.GetComponent <KPrefabID>();

        if (component.HasTag(GameTags.RocketNotOnGround))
        {
            OnLaunch(null);
        }
    }
 private static void TryAddCountableTag(KPrefabID prefab)
 {
     foreach (Tag displayAsUnit in GameTags.DisplayAsUnits)
     {
         if (prefab.HasTag(displayAsUnit))
         {
             AddCountableTag(prefab.PrefabTag);
             break;
         }
     }
 }
        static void Postfix(string newName, DetailsScreen __instance)
        {
            GameObject target = __instance.target;
            KPrefabID  prefab = target?.GetComponent <KPrefabID>();

            if (prefab != null && prefab.HasTag(GameTags.Creature))
            {
                target.AddOrGet <CritterName>().SetName(newName);
                __instance.SetTitle(0);
            }
        }
Exemple #6
0
 private void CreateOverlayIcon()
 {
     if (!((UnityEngine.Object)HarvestWhenReadyOverlayIcon != (UnityEngine.Object)null) && (UnityEngine.Object)GetComponent <AttackableBase>() == (UnityEngine.Object)null)
     {
         HarvestWhenReadyOverlayIcon = Util.KInstantiate(Assets.UIPrefabs.HarvestWhenReadyOverlayIcon, GameScreenManager.Instance.worldSpaceCanvas, null).GetComponent <RectTransform>();
         OccupyArea component  = GetComponent <OccupyArea>();
         Extents    extents    = component.GetExtents();
         KPrefabID  component2 = GetComponent <KPrefabID>();
         TransformExtensions.SetPosition(position: component2.HasTag(GameTags.Hanging) ? new Vector3((float)(extents.x + extents.width / 2) + 0.5f, (float)(extents.y + extents.height)) : new Vector3((float)(extents.x + extents.width / 2) + 0.5f, (float)extents.y), transform: HarvestWhenReadyOverlayIcon.transform);
         RefreshOverlayIcon(null);
     }
 }
Exemple #7
0
        /**
         * Checks if the object meets the tag requirements for floatation.
         */
        public static bool HasFloatableTags(Transform obj)
        {
            KPrefabID prefab = obj?.GetComponent <KPrefabID>();

            if (prefab == null)
            {
                return(false);
            }

            if (prefab.HasAnyTags(nonFloatableTags) || !prefab.HasTag(GameTags.Pickupable))
            {
                return(false);
            }

            if (prefab.HasTag(GameTags.Minion) && !prefab.HasTag(GameTags.Corpse))
            {
                return(false);
            }

            return(true);
        }
Exemple #8
0
        public static void Postfix(ref bool __result, GameObject target)
        {
            if (target.GetComponent <KPrefabID>() != null)
            {
                KPrefabID component = target.GetComponent <KPrefabID>();

                if (component.HasTag("FusionReactor".ToTag()))
                {
                    __result = false;
                }
            }
        }
Exemple #9
0
        static bool Prefix(GameObject go, bool upperName, ref string __result)
        {
            KPrefabID   prefab = go.GetComponent <KPrefabID>();
            CritterName name   = go.GetComponent <CritterName>();

            if (prefab != null && name != null && prefab.HasTag(GameTags.Creature) && name.HasName())
            {
                __result = !upperName?go.GetProperName() : StringFormatter.ToUpper(go.GetProperName());

                return(false);
            }
            return(true);
        }
        public bool NeedsToPee()
        {
            DebugUtil.DevAssert(base.master != null, "master ref null");
            DebugUtil.DevAssert(!base.master.isNull, "master isNull");
            KPrefabID component = base.master.GetComponent <KPrefabID>();

            DebugUtil.DevAssert(component, "kpid was null");
            if (component.HasTag(GameTags.Asleep))
            {
                return(false);
            }
            return(bladder.value >= 100f);
        }
Exemple #11
0
 public override bool Success()
 {
     if (Db.Get().TechItems.IsTechItemComplete(upgradeBuilding.Name))
     {
         bool result = false;
         {
             foreach (BuildingComplete item in Components.BuildingCompletes.Items)
             {
                 KPrefabID component = item.GetComponent <KPrefabID>();
                 if (component.HasTag(basicBuilding))
                 {
                     return(false);
                 }
                 if (component.HasTag(upgradeBuilding))
                 {
                     result = true;
                 }
             }
             return(result);
         }
     }
     return(false);
 }
Exemple #12
0
    private KToggleMenu.ToggleInfo[] GetFillers()
    {
        HashSet <Tag> hashSet = new HashSet <Tag>();
        List <KToggleMenu.ToggleInfo> list = new List <KToggleMenu.ToggleInfo>();

        foreach (Pickupable item in Components.Pickupables.Items)
        {
            KPrefabID kPrefabID = item.KPrefabID;
            if (kPrefabID.HasTag(GameTags.Filler) && hashSet.Add(kPrefabID.PrefabTag))
            {
                string text = kPrefabID.GetComponent <PrimaryElement>().Element.id.ToString();
                list.Add(new KToggleMenu.ToggleInfo(text, null, Action.NumActions));
            }
        }
        return(list.ToArray());
    }
Exemple #13
0
 public override void Update()
 {
     if (!prefabid.HasTag(GameTags.Idle))
     {
         cell = Grid.InvalidCell;
     }
     else
     {
         MinionPathFinderAbilities minionPathFinderAbilities = (MinionPathFinderAbilities)navigator.GetCurrentAbilities();
         minionPathFinderAbilities.SetIdleNavMaskEnabled(true);
         IdleCellQuery idleCellQuery = PathFinderQueries.idleCellQuery.Reset(brain, Random.Range(30, 60));
         navigator.RunQuery(idleCellQuery);
         minionPathFinderAbilities.SetIdleNavMaskEnabled(false);
         cell = idleCellQuery.GetResultCell();
     }
 }
Exemple #14
0
        public bool IsSleepingOrSleepSchedule()
        {
            Schedulable component = GetComponent <Schedulable>();

            if ((Object)component != (Object)null && component.IsAllowed(Db.Get().ScheduleBlockTypes.Sleep))
            {
                return(true);
            }
            KPrefabID component2 = GetComponent <KPrefabID>();

            if ((Object)component2 != (Object)null && component2.HasTag(GameTags.Asleep))
            {
                return(true);
            }
            return(false);
        }
Exemple #15
0
 public override bool Success()
 {
     foreach (BuildingComplete item in Components.BuildingCompletes.Items)
     {
         KPrefabID component = item.GetComponent <KPrefabID>();
         if (component.HasTag(GameTags.TemplateBuilding))
         {
             Unsealable component2 = item.GetComponent <Unsealable>();
             if ((Object)component2 != (Object)null && component2.unsealed)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
    private static void CheckLightLevel(Instance smi, float dt)
    {
        KPrefabID component = smi.GetComponent <KPrefabID>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.HasTag(GameTags.Shaded))
        {
            smi.sm.lightLevel.Set(0f, smi);
        }
        else
        {
            int num = Grid.PosToCell(smi.gameObject);
            if (Grid.IsValidCell(num))
            {
                smi.sm.lightLevel.Set((float)Grid.LightIntensity[num], smi);
            }
        }
    }
 private static void DumpIncorrectFertilizers(Storage storage, PlantElementAbsorber.ConsumeInfo[] consumed_infos, bool validate_solids)
 {
     if (!((Object)storage == (Object)null))
     {
         for (int num = storage.items.Count - 1; num >= 0; num--)
         {
             GameObject gameObject = storage.items[num];
             if (!((Object)gameObject == (Object)null))
             {
                 PrimaryElement component = gameObject.GetComponent <PrimaryElement>();
                 if (!((Object)component == (Object)null) && !((Object)gameObject.GetComponent <ElementChunk>() == (Object)null))
                 {
                     if (validate_solids)
                     {
                         if (!component.Element.IsSolid)
                         {
                             continue;
                         }
                     }
                     else if (!component.Element.IsLiquid)
                     {
                         continue;
                     }
                     bool      flag       = false;
                     KPrefabID component2 = component.GetComponent <KPrefabID>();
                     if (consumed_infos != null)
                     {
                         for (int i = 0; i < consumed_infos.Length; i++)
                         {
                             PlantElementAbsorber.ConsumeInfo consumeInfo = consumed_infos[i];
                             if (component2.HasTag(consumeInfo.tag))
                             {
                                 flag = true;
                                 break;
                             }
                         }
                     }
                     if (!flag)
                     {
                         storage.Drop(gameObject, true);
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Gets the type of a critter.
        /// </summary>
        /// <param name="id">The creature's prefab ID.</param>
        /// <returns>The critter type.</returns>
        public static CritterType GetCritterType(this KPrefabID id)
        {
            var result = CritterType.Wild;

            if (id != null && id.TryGetComponent(out StateMachineController smc))
            {
                if (smc.GetDef <RobotBatteryMonitor.Def>() != null)
                {
                    result = CritterType.Artificial;
                }
                else if (!id.HasTag(GameTags.Creatures.Wild) && smc.
                         GetDef <WildnessMonitor.Def>() != null)
                {
                    result = CritterType.Tame;
                }
            }
            return(result);
        }
Exemple #19
0
    private void DamageThings(Vector3 pos, int cell, int damage)
    {
        if (Grid.IsValidCell(cell))
        {
            GameObject gameObject = Grid.Objects[cell, 1];
            if ((Object)gameObject != (Object)null)
            {
                BuildingHP component  = gameObject.GetComponent <BuildingHP>();
                Building   component2 = gameObject.GetComponent <Building>();
                if ((Object)component != (Object)null && !damagedEntities.Contains(gameObject))
                {
                    KPrefabID component3 = gameObject.GetComponent <KPrefabID>();
                    float     f          = (!component3.HasTag(GameTags.Bunker)) ? ((float)damage) : ((float)damage * bunkerDamageMultiplier);
                    if ((Object)component2 != (Object)null && (Object)component2.Def != (Object)null)
                    {
                        PlayBuildingDamageSound(component2.Def, Grid.CellToPos(cell));
                    }
                    component.gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
                    {
                        damage    = Mathf.RoundToInt(f),
                        source    = (string)BUILDINGS.DAMAGESOURCES.COMET,
                        popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
                    });
                    damagedEntities.Add(gameObject);
                }
            }
            ListPool <ScenePartitionerEntry, Comet> .PooledList pooledList = ListPool <ScenePartitionerEntry, Comet> .Allocate();

            GameScenePartitioner.Instance.GatherEntries((int)pos.x, (int)pos.y, 1, 1, GameScenePartitioner.Instance.pickupablesLayer, pooledList);
            foreach (ScenePartitionerEntry item in pooledList)
            {
                Pickupable pickupable = item.obj as Pickupable;
                Health     component4 = pickupable.GetComponent <Health>();
                if ((Object)component4 != (Object)null && !damagedEntities.Contains(pickupable.gameObject))
                {
                    KPrefabID component5 = pickupable.GetComponent <KPrefabID>();
                    float     amount     = (!component5.HasTag(GameTags.Bunker)) ? ((float)damage) : ((float)damage * bunkerDamageMultiplier);
                    component4.Damage(amount);
                    damagedEntities.Add(pickupable.gameObject);
                }
            }
            pooledList.Recycle();
        }
    }
Exemple #20
0
        private bool HasTileableNeighbour(int neighbour_cell)
        {
            GameObject gameObject = Grid.Objects[neighbour_cell, (int)this.objectLayer];

            if (gameObject != null)
            {
                SimCellOccupier simCell = gameObject.GetComponent <SimCellOccupier>();
                if (simCell != null)
                {
                    return(true);
                }
                KPrefabID component = gameObject.GetComponent <KPrefabID>();
                if (component != null && component.HasTag(Patches.tag_Stairs))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #21
0
 public override bool Success()
 {
     foreach (LogicCircuitNetwork network in Game.Instance.logicCircuitSystem.GetNetworks())
     {
         if (network.Receivers.Count > 0 && network.Senders.Count > 0)
         {
             bool flag = false;
             foreach (ILogicEventReceiver receiver in network.Receivers)
             {
                 GameObject gameObject = Grid.Objects[receiver.GetLogicCell(), 1];
                 if ((Object)gameObject != (Object)null)
                 {
                     KPrefabID component = gameObject.GetComponent <KPrefabID>();
                     if (!component.HasTag(GameTags.TemplateBuilding))
                     {
                         flag = true;
                         break;
                     }
                 }
             }
             bool flag2 = false;
             foreach (ILogicEventSender sender in network.Senders)
             {
                 GameObject gameObject2 = Grid.Objects[sender.GetLogicCell(), 1];
                 if ((Object)gameObject2 != (Object)null)
                 {
                     KPrefabID component2 = gameObject2.GetComponent <KPrefabID>();
                     if (!component2.HasTag(GameTags.TemplateBuilding))
                     {
                         flag2 = true;
                         break;
                     }
                 }
             }
             if (flag && flag2)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #22
0
        static void Postfix(int selectedTabIndex, DetailsScreen __instance, EditableTitleBar ___TabTitle)
        {
            GameObject target = __instance.target;
            KPrefabID  prefab = target?.GetComponent <KPrefabID>();

            if (prefab != null && prefab.HasTag(GameTags.Creature))
            {
                ___TabTitle.SetUserEditable(true);

                string properName = UI.StripLinkFormatting(target.GetProperName());

                ___TabTitle.SetTitle(properName);
                ___TabTitle.SetSubText("");

                string originalProperName = TagManager.GetProperName(prefab.PrefabTag, stripLink: true);
                if (properName != originalProperName)
                {
                    ___TabTitle.SetSubText(originalProperName);
                }
            }
        }
Exemple #23
0
    public void Refresh()
    {
        splat.Clear();
        splat = new Splat(this);
        KPrefabID component = GetComponent <KPrefabID>();
        bool      flag      = component.HasTag(RoomConstraints.ConstraintTags.Decor20);
        bool      flag2     = decor.GetTotalValue() >= 20f;

        if (flag != flag2)
        {
            if (flag2)
            {
                component.AddTag(RoomConstraints.ConstraintTags.Decor20, false);
            }
            else
            {
                component.RemoveTag(RoomConstraints.ConstraintTags.Decor20);
            }
            Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(this), true);
        }
    }
Exemple #24
0
 /// <summary>
 /// Updates the sensors only once a second, as opposed to every frame.
 /// </summary>
 private void RunUpdate()
 {
     if (id != null && !id.HasTag(GameTags.Dead))
     {
         // The order of sensors matters here
         if (pathSensor != null)
         {
             PathProberSensorUpdater.Update(pathSensor);
         }
         if (pickupSensor != null)
         {
             PickupableSensorUpdater.Update(pickupSensor);
         }
         if (edibleSensor != null)
         {
             ClosestEdibleSensorUpdater.Update(edibleSensor);
         }
         if (balloonSensor != null && traits.HasTrait("BalloonArtist"))
         {
             BalloonStandCellSensorUpdater.Update(balloonSensor);
         }
         if (idleSensor != null)
         {
             IdleCellSensorUpdater.Update(idleSensor);
         }
         if (mingleSensor != null)
         {
             MingleCellSensorUpdater.Update(mingleSensor);
         }
         if (safeSensor != null)
         {
             SafeCellSensorUpdater.Update(safeSensor);
         }
         if (toiletSensor != null)
         {
             ToiletSensorUpdater.Update(toiletSensor);
         }
         // AssignableReachabilitySensor and BreathableAreaSensor are pretty cheap
     }
 }
 internal static bool Prefix(int cell)
 {
     try
     {
         GameObject go = Grid.Objects[cell, 1];
         if (go != null)
         {
             KPrefabID id = go.GetComponent <KPrefabID>();
             if (id != null)
             {
                 if (id.HasTag(GameTags.Bunker))
                 {
                     return(false);
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     return(true);
 }
Exemple #26
0
        public override bool Success()
        {
            WorldDetailSave worldDetailSave = SaveLoader.Instance.worldDetailSave;

            for (int i = 0; i < worldDetailSave.overworldCells.Count; i++)
            {
                WorldDetailSave.OverworldCell overworldCell = worldDetailSave.overworldCells[i];
                if (overworldCell.tags != null && !overworldCell.tags.Contains(WorldGenTags.StartWorld))
                {
                    Polygon poly = overworldCell.poly;
                    foreach (BuildingComplete item in Components.BuildingCompletes.Items)
                    {
                        KPrefabID component = item.GetComponent <KPrefabID>();
                        if (!component.HasTag(GameTags.TemplateBuilding) && poly.PointInPolygon(item.transform.GetPosition()))
                        {
                            Game.Instance.unlocks.Unlock("buildoutsidestartingbiome");
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 public override void Update()
 {
     if (!prefabid.HasTag(GameTags.Idle))
     {
         cell = Grid.InvalidCell;
     }
     else
     {
         bool flag = HasSafeCell();
         RunSafeCellQuery(false);
         bool flag2 = HasSafeCell();
         if (flag2 != flag)
         {
             if (flag2)
             {
                 sensors.Trigger(982561777, null);
             }
             else
             {
                 sensors.Trigger(506919987, null);
             }
         }
     }
 }
Exemple #28
0
	public void TryToOffsetIfBuried()
	{
		if (!KPrefabID.HasTag(GameTags.Stored) && !KPrefabID.HasTag(GameTags.Equipped))
		{
			int num = Grid.PosToCell(this);
			if (Grid.IsValidCell(num))
			{
				if ((base.gameObject.GetSMI<DeathMonitor.Instance>()?.IsDead() ?? true) && ((Grid.Solid[num] && Grid.Foundation[num]) || Grid.Properties[num] != 0))
				{
					for (int i = 0; i < displacementOffsets.Length; i++)
					{
						int num2 = Grid.OffsetCell(num, displacementOffsets[i]);
						if (Grid.IsValidCell(num2) && !Grid.Solid[num2])
						{
							Vector3 position = Grid.CellToPosCBC(num2, Grid.SceneLayer.Move);
							KCollider2D component = GetComponent<KCollider2D>();
							if ((UnityEngine.Object)component != (UnityEngine.Object)null)
							{
								float y = position.y;
								Vector3 position2 = base.transform.GetPosition();
								float y2 = position2.y;
								Vector3 min = component.bounds.min;
								position.y = y + (y2 - min.y);
							}
							base.transform.SetPosition(position);
							num = num2;
							RemoveFaller();
							AddFaller(Vector2.zero);
							break;
						}
					}
				}
				HandleSolidCell(num);
			}
		}
	}
    private bool MinionOnCooldown(MinionIdentity minion)
    {
        KPrefabID component = minion.GetComponent <KPrefabID>();

        return(!component.HasTag(GameTags.AlwaysConverse) && ((lastConvoTimeByMinion.ContainsKey(minion) && GameClock.Instance.GetTime() < lastConvoTimeByMinion[minion] + TuningData <Tuning> .Get().minionCooldownTime) || GameClock.Instance.GetTime() / 600f < TuningData <Tuning> .Get().cyclesBeforeFirstConversation));
    }
    public override bool IsValidForTarget(GameObject target)
    {
        KPrefabID component = target.GetComponent <KPrefabID>();

        return((UnityEngine.Object)component != (UnityEngine.Object)null && component.HasTag(GameTags.HasChores) && !component.HasTag(GameTags.Minion));
    }