private void FindClimbableTree() { climbTarget = null; ListPool <ScenePartitionerEntry, GameScenePartitioner> .PooledList pooledList = ListPool <ScenePartitionerEntry, GameScenePartitioner> .Allocate(); ListPool <KMonoBehaviour, ClimbableTreeMonitor> .PooledList pooledList2 = ListPool <KMonoBehaviour, ClimbableTreeMonitor> .Allocate(); Vector3 position = base.master.transform.GetPosition(); Extents extents = new Extents(Grid.PosToCell(position), 10); GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.plants, pooledList); GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.completeBuildings, pooledList); Navigator component = GetComponent <Navigator>(); foreach (ScenePartitionerEntry item in pooledList) { KMonoBehaviour kMonoBehaviour = item.obj as KMonoBehaviour; if (!kMonoBehaviour.HasTag(GameTags.Creatures.ReservedByCreature)) { int cell = Grid.PosToCell(kMonoBehaviour); if (component.CanReach(cell)) { BuddingTrunk component2 = kMonoBehaviour.GetComponent <BuddingTrunk>(); StorageLocker component3 = kMonoBehaviour.GetComponent <StorageLocker>(); if ((Object)component2 != (Object)null) { if (!component2.ExtraSeedAvailable) { continue; } } else { if (!((Object)component3 != (Object)null)) { continue; } Storage component4 = component3.GetComponent <Storage>(); if (!component4.allowItemRemoval || component4.IsEmpty()) { continue; } } pooledList2.Add(kMonoBehaviour); } } } if (pooledList2.Count > 0) { int index = Random.Range(0, pooledList2.Count); KMonoBehaviour kMonoBehaviour2 = pooledList2[index]; climbTarget = kMonoBehaviour2.gameObject; } pooledList.Recycle(); pooledList2.Recycle(); }
public static void ApplyModifierToBranch(TreeBud branch, BuddingTrunk buddingTrunk) { var parentEffects = buddingTrunk?.GetComponent <Effects>(); var branchEffects = branch?.GetComponent <Effects>(); if (parentEffects != null && branchEffects != null && parentEffects.HasEffect(FARMTINKEREFFECTID)) { branchEffects.Add(FARMTINKEREFFECTID, false).timeRemaining = parentEffects.Get(FARMTINKEREFFECTID).timeRemaining; } }
public GameObject CreatePrefab() { string id = "ForestTree"; string name = STRINGS.CREATURES.SPECIES.WOOD_TREE.NAME; string desc = STRINGS.CREATURES.SPECIES.WOOD_TREE.DESC; float mass = 2f; KAnimFile anim = Assets.GetAnim("tree_kanim"); string initialAnim = "idle_empty"; EffectorValues tIER = DECOR.BONUS.TIER1; List <Tag> additionalTags = new List <Tag>(); GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Building, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, additionalTags, 298.15f); EntityTemplates.ExtendEntityToBasicPlant(gameObject, 258.15f, 288.15f, 313.15f, 448.15f, null, true, 0f, 0.15f, "WoodLog", true, true, true, false, 2400f); gameObject.AddOrGet <BuddingTrunk>(); gameObject.UpdateComponentRequirement <Harvestable>(false); Tag tag = ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag; EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = tag, massConsumptionRate = 0.116666667f } }); EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = GameTags.Dirt, massConsumptionRate = 0.0166666675f } }); gameObject.AddComponent <StandardCropPlant>(); UprootedMonitor component = gameObject.GetComponent <UprootedMonitor>(); component.monitorCell = new CellOffset(0, -1); BuddingTrunk buddingTrunk = gameObject.AddOrGet <BuddingTrunk>(); buddingTrunk.budPrefabID = "ForestTreeBranch"; GameObject plant = gameObject; SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Hidden; initialAnim = "ForestTreeSeed"; desc = STRINGS.CREATURES.SPECIES.SEEDS.WOOD_TREE.NAME; name = STRINGS.CREATURES.SPECIES.SEEDS.WOOD_TREE.DESC; anim = Assets.GetAnim("seed_tree_kanim"); additionalTags = new List <Tag>(); additionalTags.Add(GameTags.CropSeed); additionalTags = additionalTags; GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, additionalTags, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 4, STRINGS.CREATURES.SPECIES.WOOD_TREE.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.3f, 0.3f, null, string.Empty, false); EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "ForestTree_preview", Assets.GetAnim("tree_kanim"), "place", 3, 3); return(gameObject); }
public static void ApplyModifierToBranch(TreeBud branch, BuddingTrunk buddingTrunk) { var parentEffects = buddingTrunk?.GetComponent <Effects>(); var branchEffects = branch?.GetComponent <Effects>(); if (parentEffects != null && branchEffects != null) { foreach (var effect_id in CropTendingEffects) { var effectInstanceTrunk = parentEffects.Get(effect_id); if (effectInstanceTrunk != null) { var effectInstanceBranch = branchEffects.Add(effect_id, false); if (effectInstanceBranch != null) { effectInstanceBranch.timeRemaining = effectInstanceTrunk.timeRemaining; } } } } }