public GameObject CreatePrefab() { string id = "BeanPlant"; string name = STRINGS.CREATURES.SPECIES.BEAN_PLANT.NAME; string desc = STRINGS.CREATURES.SPECIES.BEAN_PLANT.DESC; float mass = 2f; KAnimFile anim = Assets.GetAnim("beanplant_kanim"); string initialAnim = "idle_empty"; EffectorValues tIER = DECOR.BONUS.TIER1; GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingFront, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, null, 258.15f); EntityTemplates.ExtendEntityToBasicPlant(gameObject, 198.15f, 248.15f, 273.15f, 323.15f, null, true, 0f, 0.15f, "BeanPlantSeed", true, true, true, true, 2400f); EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = SimHashes.Ethanol.CreateTag(), massConsumptionRate = 0.0333333351f } }); EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = SimHashes.Dirt.CreateTag(), massConsumptionRate = 0.008333334f } }); PressureVulnerable pressureVulnerable = gameObject.AddOrGet <PressureVulnerable>(); PressureVulnerable pressureVulnerable2 = pressureVulnerable; mass = 0.025f; float pressureLethalLow = 0f; SimHashes[] safeAtmospheres = new SimHashes[1] { SimHashes.CarbonDioxide }; pressureVulnerable2.Configure(mass, pressureLethalLow, 10f, 30f, safeAtmospheres); UprootedMonitor component = gameObject.GetComponent <UprootedMonitor>(); component.monitorCell = new CellOffset(0, -1); gameObject.AddOrGet <StandardCropPlant>(); GameObject plant = gameObject; SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Harvest; initialAnim = "BeanPlantSeed"; desc = STRINGS.CREATURES.SPECIES.SEEDS.BEAN_PLANT.NAME; name = STRINGS.CREATURES.SPECIES.SEEDS.BEAN_PLANT.DESC; anim = Assets.GetAnim("seed_beanplant_kanim"); List <Tag> list = new List <Tag>(); list.Add(GameTags.CropSeed); list = list; GameObject gameObject2 = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 4, STRINGS.CREATURES.SPECIES.BEAN_PLANT.DOMESTICATEDDESC, EntityTemplates.CollisionShape.RECTANGLE, 0.6f, 0.3f, null, string.Empty, false); EntityTemplates.ExtendEntityToFood(gameObject2, FOOD.FOOD_TYPES.BEAN); EntityTemplates.CreateAndRegisterPreviewForPlant(gameObject2, "BeanPlant_preview", Assets.GetAnim("beanplant_kanim"), "place", 1, 2); return(gameObject); }
public GameObject CreatePrefab() { string id = "SaltPlant"; string name = STRINGS.CREATURES.SPECIES.SALTPLANT.NAME; string desc = STRINGS.CREATURES.SPECIES.SALTPLANT.DESC; float mass = 2f; KAnimFile anim = Assets.GetAnim("saltplant_kanim"); string initialAnim = "idle_empty"; EffectorValues tIER = DECOR.PENALTY.TIER1; List <Tag> list = new List <Tag>(); list.Add(GameTags.Hanging); list = list; GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingFront, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, list, 258.15f); EntityTemplates.MakeHangingOffsets(gameObject, 1, 2); GameObject template = gameObject; mass = 198.15f; float temperature_warning_low = 248.15f; float temperature_warning_high = 323.15f; float temperature_lethal_high = 393.15f; initialAnim = 381665462.ToString(); EntityTemplates.ExtendEntityToBasicPlant(template, mass, temperature_warning_low, temperature_warning_high, temperature_lethal_high, null, true, 0f, 0.15f, initialAnim, true, true, true, true, 2400f); gameObject.AddOrGet <SaltPlant>(); EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = SimHashes.Sand.CreateTag(), massConsumptionRate = 0.0116666667f } }); PressureVulnerable pressureVulnerable = gameObject.AddOrGet <PressureVulnerable>(); PressureVulnerable pressureVulnerable2 = pressureVulnerable; temperature_lethal_high = 0.025f; temperature_warning_high = 0f; SimHashes[] safeAtmospheres = new SimHashes[1] { SimHashes.ChlorineGas }; pressureVulnerable2.Configure(temperature_lethal_high, temperature_warning_high, 10f, 30f, safeAtmospheres); KPrefabID component = gameObject.GetComponent <KPrefabID>(); component.prefabInitFn += delegate(GameObject inst) { PressureVulnerable component3 = inst.GetComponent <PressureVulnerable>(); component3.safe_atmospheres.Add(ElementLoader.FindElementByHash(SimHashes.ChlorineGas)); }; Storage storage = gameObject.AddOrGet <Storage>(); storage.showInUI = false; storage.capacityKg = 1f; ElementConsumer elementConsumer = gameObject.AddOrGet <ElementConsumer>(); elementConsumer.showInStatusPanel = true; elementConsumer.showDescriptor = true; elementConsumer.storeOnConsume = false; elementConsumer.elementToConsume = SimHashes.ChlorineGas; elementConsumer.configuration = ElementConsumer.Configuration.Element; elementConsumer.consumptionRadius = 4; elementConsumer.sampleCellOffset = new Vector3(0f, -1f); elementConsumer.consumptionRate = 0.006f; UprootedMonitor component2 = gameObject.GetComponent <UprootedMonitor>(); component2.monitorCell = new CellOffset(0, 1); gameObject.AddOrGet <StandardCropPlant>(); template = gameObject; SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Harvest; initialAnim = "SaltPlantSeed"; desc = STRINGS.CREATURES.SPECIES.SEEDS.SALTPLANT.NAME; name = STRINGS.CREATURES.SPECIES.SEEDS.SALTPLANT.DESC; anim = Assets.GetAnim("seed_saltplant_kanim"); list = new List <Tag>(); list.Add(GameTags.CropSeed); list = list; GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(template, productionType, initialAnim, desc, name, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Bottom, default(Tag), 4, STRINGS.CREATURES.SPECIES.SALTPLANT.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.35f, 0.35f, null, string.Empty, false); GameObject template2 = EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "SaltPlant_preview", Assets.GetAnim("saltplant_kanim"), "place", 1, 2); EntityTemplates.MakeHangingOffsets(template2, 1, 2); return(gameObject); }
public GameObject CreatePrefab() { string id = "Oxyfern"; string name = STRINGS.CREATURES.SPECIES.OXYFERN.NAME; string desc = STRINGS.CREATURES.SPECIES.OXYFERN.DESC; float mass = 1f; KAnimFile anim = Assets.GetAnim("oxy_fern_kanim"); string initialAnim = "idle_full"; EffectorValues tIER = DECOR.PENALTY.TIER1; GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingBack, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, null, 293f); gameObject.AddOrGet <ReceptacleMonitor>(); gameObject.AddOrGet <EntombVulnerable>(); gameObject.AddOrGet <WiltCondition>(); gameObject.AddOrGet <Prioritizable>(); gameObject.AddOrGet <Uprootable>(); gameObject.AddOrGet <UprootedMonitor>(); gameObject.AddOrGet <DrowningMonitor>(); TemperatureVulnerable temperatureVulnerable = gameObject.AddOrGet <TemperatureVulnerable>(); temperatureVulnerable.Configure(273.15f, 253.15f, 313.15f, 373.15f); Tag tag = ElementLoader.FindElementByHash(SimHashes.Water).tag; EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = tag, massConsumptionRate = 0.0316666663f } }); EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1] { new PlantElementAbsorber.ConsumeInfo { tag = GameTags.Dirt, massConsumptionRate = 0.006666667f } }); gameObject.AddOrGet <Oxyfern>(); gameObject.AddOrGet <OccupyArea>().objectLayers = new ObjectLayer[1] { ObjectLayer.Building }; gameObject.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true; PressureVulnerable pressureVulnerable = gameObject.AddOrGet <PressureVulnerable>(); PressureVulnerable pressureVulnerable2 = pressureVulnerable; mass = 0.025f; float pressureLethalLow = 0f; SimHashes[] safeAtmospheres = new SimHashes[1] { SimHashes.CarbonDioxide }; pressureVulnerable2.Configure(mass, pressureLethalLow, 10f, 30f, safeAtmospheres); KPrefabID component = gameObject.GetComponent <KPrefabID>(); component.prefabInitFn += delegate(GameObject inst) { PressureVulnerable component2 = inst.GetComponent <PressureVulnerable>(); component2.safe_atmospheres.Add(ElementLoader.FindElementByHash(SimHashes.CarbonDioxide)); }; gameObject.AddOrGet <LoopingSounds>(); Storage storage = gameObject.AddOrGet <Storage>(); storage.showInUI = false; storage.capacityKg = 1f; ElementConsumer elementConsumer = gameObject.AddOrGet <ElementConsumer>(); elementConsumer.showInStatusPanel = false; elementConsumer.storeOnConsume = true; elementConsumer.storage = storage; elementConsumer.elementToConsume = SimHashes.CarbonDioxide; elementConsumer.configuration = ElementConsumer.Configuration.Element; elementConsumer.consumptionRadius = 2; elementConsumer.EnableConsumption(true); elementConsumer.sampleCellOffset = new Vector3(0f, 0f); elementConsumer.consumptionRate = 0.000156250011f; ElementConverter elementConverter = gameObject.AddOrGet <ElementConverter>(); elementConverter.OutputMultiplier = 50f; elementConverter.consumedElements = new ElementConverter.ConsumedElement[1] { new ElementConverter.ConsumedElement(1960575215.ToString().ToTag(), 0.000625000044f) }; elementConverter.outputElements = new ElementConverter.OutputElement[1] { new ElementConverter.OutputElement(0.0312500037f, SimHashes.Oxygen, 0f, true, false, 0f, 1f, 0.75f, byte.MaxValue, 0) }; GameObject plant = gameObject; SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Hidden; initialAnim = "OxyfernSeed"; desc = STRINGS.CREATURES.SPECIES.SEEDS.OXYFERN.NAME; name = STRINGS.CREATURES.SPECIES.SEEDS.OXYFERN.DESC; anim = Assets.GetAnim("seed_oxyfern_kanim"); List <Tag> list = new List <Tag>(); list.Add(GameTags.CropSeed); list = list; GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 2, STRINGS.CREATURES.SPECIES.OXYFERN.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.3f, 0.3f, null, string.Empty, false); EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "Oxyfern_preview", Assets.GetAnim("oxy_fern_kanim"), "place", 1, 2); SoundEventVolumeCache.instance.AddVolume("oxy_fern_kanim", "MealLice_harvest", NOISE_POLLUTION.CREATURES.TIER3); SoundEventVolumeCache.instance.AddVolume("oxy_fern_kanim", "MealLice_LP", NOISE_POLLUTION.CREATURES.TIER4); return(gameObject); }
public static GameObject ExtendEntityToBasicPlant(GameObject template, float temperature_lethal_low = 218.15f, float temperature_warning_low = 283.15f, float temperature_warning_high = 303.15f, float temperature_lethal_high = 398.15f, SimHashes[] safe_elements = null, bool pressure_sensitive = true, float pressure_lethal_low = 0f, float pressure_warning_low = 0.15f, string crop_id = null, bool can_drown = true, bool can_tinker = true, bool require_solid_tile = true, bool should_grow_old = true, float max_age = 2400f) { template.AddOrGet <EntombVulnerable>(); PressureVulnerable pressureVulnerable = template.AddOrGet <PressureVulnerable>(); if (pressure_sensitive) { PressureVulnerable pressureVulnerable2 = pressureVulnerable; SimHashes[] safeAtmospheres = safe_elements; pressureVulnerable2.Configure(pressure_warning_low, pressure_lethal_low, 10f, 30f, safeAtmospheres); } else { pressureVulnerable.Configure(safe_elements); } template.AddOrGet <WiltCondition>(); template.AddOrGet <Prioritizable>(); template.AddOrGet <Uprootable>(); if (require_solid_tile) { template.AddOrGet <UprootedMonitor>(); } template.AddOrGet <ReceptacleMonitor>(); template.AddOrGet <Notifier>(); if (can_drown) { template.AddOrGet <DrowningMonitor>(); } TemperatureVulnerable temperatureVulnerable = template.AddOrGet <TemperatureVulnerable>(); temperatureVulnerable.Configure(temperature_warning_low, temperature_lethal_low, temperature_warning_high, temperature_lethal_high); template.AddOrGet <OccupyArea>().objectLayers = new ObjectLayer[1] { ObjectLayer.Building }; KPrefabID component = template.GetComponent <KPrefabID>(); if (crop_id != null) { GeneratedBuildings.RegisterWithOverlay(OverlayScreen.HarvestableIDs, component.PrefabID().ToString()); Crop.CropVal cropval = CROPS.CROP_TYPES.Find((Crop.CropVal m) => m.cropId == crop_id); Crop crop = template.AddOrGet <Crop>(); crop.Configure(cropval); Growing growing = template.AddOrGet <Growing>(); growing.growthTime = cropval.cropDuration; growing.shouldGrowOld = should_grow_old; growing.maxAge = max_age; template.AddOrGet <Harvestable>(); template.AddOrGet <HarvestDesignatable>(); } component.prefabInitFn += delegate(GameObject inst) { PressureVulnerable component2 = inst.GetComponent <PressureVulnerable>(); if (safe_elements != null) { SimHashes[] array = safe_elements; foreach (SimHashes hash in array) { component2.safe_atmospheres.Add(ElementLoader.FindElementByHash(hash)); } } }; if (can_tinker) { Tinkerable.MakeFarmTinkerable(template); } return(template); }