Beispiel #1
0
            private static void Postfix(ref GameObject inst)
            {
                ElementConsumer component = inst.GetComponent <ElementConsumer>();

                if (component != null)
                {
                    component.EnableConsumption(true);
                }
            }
    public void OnSpawn(GameObject inst)
    {
        ElementConsumer component = inst.GetComponent <ElementConsumer>();

        if ((Object)component != (Object)null)
        {
            component.EnableConsumption(true);
        }
    }
Beispiel #3
0
        protected override void OnPrefabInit()
        {
            var statusItems = Db.Get().BuildingStatusItems;

            base.OnPrefabInit();
            consumer.EnableConsumption(false);
            // These can be replaced by subclasses
            noGasAvailable    = statusItems.NoGasElementToPump;
            noLiquidAvailable = statusItems.NoLiquidElementToPump;
        }
Beispiel #4
0
        public void OnSpawn(GameObject inst)
        {
            ElementConsumer component = inst.GetComponent <ElementConsumer>();

            if (component == null)
            {
                return;
            }
            component.EnableConsumption(true);
        }
Beispiel #5
0
        protected override void OnPrefabInit()
        {
            var statusItems = Db.Get().BuildingStatusItems;

            base.OnPrefabInit();
            consumer.EnableConsumption(false);
            // Create delegates
            simRegister = typeof(SimComponent).CreateDelegate <System.Action>("SimRegister",
                                                                              consumer);
            simUnregister = typeof(SimComponent).CreateDelegate <System.Action>("SimUnregister",
                                                                                consumer);
            // These can be replaced by subclasses
            noGasAvailable    = statusItems.NoGasElementToPump;
            noLiquidAvailable = statusItems.NoLiquidElementToPump;
        }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        Storage storage  = go.AddComponent <Storage>();
        Storage storage2 = go.AddComponent <Storage>();

        storage2.capacityKg = 100f;
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        float           num             = 2426.72f;
        float           num2            = 0.01f;
        LiquidCooledFan liquidCooledFan = go.AddOrGet <LiquidCooledFan>();

        liquidCooledFan.gasStorage           = storage;
        liquidCooledFan.liquidStorage        = storage2;
        liquidCooledFan.waterKGConsumedPerKJ = 1f / (num * num2);
        liquidCooledFan.coolingKilowatts     = 80f;
        liquidCooledFan.minCooledTemperature = 290f;
        liquidCooledFan.minEnvironmentMass   = 0.25f;
        liquidCooledFan.minCoolingRange      = new Vector2I(-2, 0);
        liquidCooledFan.maxCoolingRange      = new Vector2I(2, 4);
        ManualDeliveryKG manualDeliveryKG = go.AddComponent <ManualDeliveryKG>();

        manualDeliveryKG.requestedItemTag = new Tag("Water");
        manualDeliveryKG.capacity         = 500f;
        manualDeliveryKG.refillMass       = 50f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        elementConsumer.storeOnConsume    = true;
        elementConsumer.storage           = storage;
        elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
        elementConsumer.consumptionRadius = 8;
        elementConsumer.EnableConsumption(true);
        elementConsumer.sampleCellOffset = new Vector3(0f, 0f);
        elementConsumer.showDescriptor   = false;
        LiquidCooledFanWorkable liquidCooledFanWorkable = go.AddOrGet <LiquidCooledFanWorkable>();

        liquidCooledFanWorkable.SetWorkTime(20f);
        liquidCooledFanWorkable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_liquidfan_kanim")
        };
    }
Beispiel #7
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     consumer.EnableConsumption(false);
 }
Beispiel #8
0
        };                                                                                                                                                                                     //wilt1, grow_seed

        public static void ProcessPlant(GameObject plant)
        {
            PlantData setting = CustomizePlantsState.StateManager.State.PlantSettings?.FirstOrDefault(t => t.id == plant.name);

            if (setting == null)
            {
                return;
            }

            #region decor plant fixes
            if (setting.fruitId != null)    //decor plant fixes
            {
                PrickleGrass grass = plant.GetComponent <PrickleGrass>();
                if (grass != null || plant.name == ColdBreatherConfig.ID || plant.name == EvilFlowerConfig.ID)
                {
                    UnityEngine.Object.DestroyImmediate(grass); //what happens if this is null?
                    plant.AddOrGet <StandardCropPlant>();

                    KPrefabID prefab = plant.GetComponent <KPrefabID>();
                    prefab.prefabInitFn += (inst =>
                    {
                        StandardCropPlant stdcrop2 = inst.GetComponent <StandardCropPlant>();
                        stdcrop2.anims = PlantHelper.DecorAnim;
                    });

                    //KBatchedAnimController kbatchedAnimController = plant.AddOrGet<KBatchedAnimController>();
                    //kbatchedAnimController.AnimFiles = new KAnimFile[1]
                    //{
                    //  Assets.GetAnim("bristleblossom_kanim")
                    //};
                    //kbatchedAnimController.initialAnim = "idle_empty";
                }

                SeedProducer seed = plant.GetComponent <SeedProducer>();
                if (seed != null)
                {
                    seed.seedInfo.productionType   = SeedProducer.ProductionType.Harvest;
                    seed.seedInfo.newSeedsProduced = 1;
                }
            }
            #endregion
            #region fruitId
            if (setting.fruitId != null || setting.fruit_grow_time != null || setting.fruit_amount != null)    //actual setting fruit
            {
                Crop         crop    = plant.AddOrGet <Crop>();
                Crop.CropVal cropval = crop.cropVal;   //this is a copy
                if (setting.fruitId != null)
                {
                    cropval.cropId = setting.fruitId;
                }
                if (cropval.cropId == "")
                {
                    cropval.cropId = "WoodLog";
                }
                if (setting.fruit_grow_time != null)
                {
                    cropval.cropDuration = (float)setting.fruit_grow_time;
                }
                if (cropval.cropDuration < 1f)
                {
                    cropval.cropDuration = 1f;
                }
                if (setting.fruit_amount != null)
                {
                    cropval.numProduced = (int)setting.fruit_amount;
                }
                if (cropval.numProduced < 1)
                {
                    cropval.numProduced = 1;
                }
                crop.Configure(cropval);

                KPrefabID prefab = plant.GetComponent <KPrefabID>();
                GeneratedBuildings.RegisterWithOverlay(OverlayScreen.HarvestableIDs, prefab.PrefabID().ToString());
                Growing growing = plant.AddOrGet <Growing>();
                growing.growthTime = cropval.cropDuration;
                if (setting.id != ForestTreeConfig.ID)  // don't harvest arbor trees directly
                {
                    plant.AddOrGet <Harvestable>();
                }
                plant.AddOrGet <HarvestDesignatable>();
                plant.AddOrGet <StandardCropPlant>();
            }
            #endregion
            #region irrigation
            if (setting.irrigation != null)
            {
                RemoveIrrigation(plant);

                List <PlantElementAbsorber.ConsumeInfo> irrigation    = new List <PlantElementAbsorber.ConsumeInfo>(3);
                List <PlantElementAbsorber.ConsumeInfo> fertilization = new List <PlantElementAbsorber.ConsumeInfo>(3);
                foreach (KeyValuePair <string, float> entry in setting.irrigation)
                {
                    if (GameTags.LiquidElements.Contains(entry.Key))
                    {
                        irrigation.Add(new PlantElementAbsorber.ConsumeInfo(entry.Key, entry.Value / 600f));
                    }
                    else if (GameTags.SolidElements.Contains(entry.Key))
                    {
                        fertilization.Add(new PlantElementAbsorber.ConsumeInfo(entry.Key, entry.Value / 600f));
                    }
                    else
                    {
                        Debug.Log(ToDialog("Irrigation for " + setting.id + " defines bad element: " + entry.Key));
                    }
                }
                if (irrigation.Count > 0)
                {
                    EntityTemplates.ExtendPlantToIrrigated(plant, irrigation.ToArray());
                }
                if (fertilization.Count > 0)
                {
                    EntityTemplates.ExtendPlantToFertilizable(plant, fertilization.ToArray());
                }
            }
            #endregion
            #region illumination
            if (setting.illumination != null)
            {
                IlluminationVulnerable  illumination = plant.GetComponent <IlluminationVulnerable>();
                CropSleepingMonitor.Def cropSleep    = plant.GetDef <CropSleepingMonitor.Def>();

                if (setting.illumination == 0f)
                {
                    if (illumination != null)
                    {
                        UnityEngine.Object.DestroyImmediate(illumination);
                    }
                    if (cropSleep != null)
                    {
                        FumLib.FumTools.RemoveDef(plant, cropSleep);
                    }
                }
                else if (setting.illumination < 0f)
                {
                    if (illumination == null)
                    {
                        illumination = plant.AddOrGet <IlluminationVulnerable>();
                    }
                    if (cropSleep != null)
                    {
                        FumLib.FumTools.RemoveDef(plant, cropSleep);
                    }

                    illumination.SetPrefersDarkness(true);
                }
                else if (setting.illumination == 1f)
                {
                    if (illumination == null)
                    {
                        illumination = plant.AddOrGet <IlluminationVulnerable>();
                    }
                    if (cropSleep != null)
                    {
                        FumLib.FumTools.RemoveDef(plant, cropSleep);
                    }

                    illumination.SetPrefersDarkness(false);
                }
                else
                {
                    if (illumination != null)
                    {
                        UnityEngine.Object.DestroyImmediate(illumination);
                    }
                    if (cropSleep == null)
                    {
                        cropSleep = plant.AddOrGetDef <CropSleepingMonitor.Def>();
                    }

                    cropSleep.lightIntensityThreshold = (float)setting.illumination;
                    cropSleep.prefersDarkness         = false;
                }
            }
            #endregion
            #region safe_elements
            if (setting.safe_elements != null)
            {
                plant.GetComponent <KPrefabID>().prefabInitFn += (inst =>
                {
                    PressureVulnerable pressure = inst.GetComponent <PressureVulnerable>();
                    pressure.safe_atmospheres.Clear();

                    foreach (string safe_element in setting.safe_elements)
                    {
                        pressure.safe_atmospheres.Add(ElementLoader.FindElementByName(safe_element));
                    }
                });
            }
            #endregion
            #region pressure
            if (setting.pressures != null)
            {
                PressureVulnerable pressure = plant.AddOrGet <PressureVulnerable>();
                pressure.pressureLethal_Low   = 0f;
                pressure.pressureWarning_Low  = 0f;
                pressure.pressureWarning_High = float.MaxValue;
                pressure.pressureLethal_High  = float.MaxValue;
                pressure.pressure_sensitive   = false;

                for (int i = 0; i < setting.pressures.Length; i++)
                {
                    switch (i)
                    {
                    case 0: pressure.pressureLethal_Low = setting.pressures[i]; pressure.pressure_sensitive = true; break;

                    case 1: pressure.pressureWarning_Low = setting.pressures[i]; break;

                    case 2: pressure.pressureWarning_High = setting.pressures[i]; break;

                    case 3: pressure.pressureLethal_High = setting.pressures[i]; break;
                    }
                }
            }
            #endregion
            #region decor
            try {
                if (setting.decor_value != null)
                {
                    plant.GetComponent <DecorProvider>().baseDecor = (float)setting.decor_value;
                }

                if (setting.decor_radius != null)
                {
                    plant.GetComponent <DecorProvider>().baseRadius = (float)setting.decor_radius;
                }
            } catch (Exception) {
                Debug.LogWarning("[CustomizePlants] For some weird reason " + plant.name + " has no DecorProvider.");
            }
            #endregion
            #region temperatures
            if (setting.temperatures != null)
            {
                TemperatureVulnerable temperature = plant.AddOrGet <TemperatureVulnerable>();

                for (int i = 0; i < setting.temperatures.Length; i++)
                {
                    switch (i)
                    {
                    case 0: temperature.internalTemperatureLethal_Low = setting.temperatures[i]; break;

                    case 1: temperature.internalTemperatureWarning_Low = setting.temperatures[i]; break;

                    case 2: temperature.internalTemperatureWarning_High = setting.temperatures[i]; break;

                    case 3: temperature.internalTemperatureLethal_High = setting.temperatures[i]; break;
                    }
                }
            }
            #endregion
            #region submerged_threshold
            if (setting.submerged_threshold != null)
            {
                DrowningMonitor drowning = plant.AddOrGet <DrowningMonitor>();

                if (setting.submerged_threshold == 0f)   //doesn't care about water
                {
                    UnityEngine.Object.DestroyImmediate(drowning);
                }
                else if (setting.submerged_threshold < 0f)   //needs water
                {
                    drowning.livesUnderWater = true;
                    drowning.canDrownToDeath = false;
                }
                else    //if(setting.submerged_threshold > 0f)  //hates water
                {
                    drowning.livesUnderWater = false;
                    drowning.canDrownToDeath = false;
                }
            }
            #endregion
            #region can_tinker
            if (setting.can_tinker != null)
            {
                if (setting.can_tinker == true)
                {
                    Tinkerable.MakeFarmTinkerable(plant);
                }
            }
            #endregion
            #region require_solid_tile
            if (setting.require_solid_tile != null)
            {
                UprootedMonitor uproot = plant.AddOrGet <UprootedMonitor>();
                if (setting.require_solid_tile == false)
                {
                    UnityEngine.Object.DestroyImmediate(uproot);
                }
            }
            #endregion
            #region max_age
            if (setting.max_age != null && plant.GetComponent <StandardCropPlant>() != null) //only if plant has fruit
            {
                Growing growing = plant.AddOrGet <Growing>();
                if (setting.max_age <= 0)
                {
                    growing.shouldGrowOld = false;
                }
                else
                {
                    growing.shouldGrowOld = true;
                    growing.maxAge        = (float)setting.max_age;
                }
            }
            #endregion
            #region disease
            if (setting.disease != null || setting.disease_amount != null)
            {
                DiseaseDropper.Def def = plant.AddOrGetDef <DiseaseDropper.Def>();
                if (setting.disease != null)
                {
                    def.diseaseIdx = Db.Get().Diseases.GetIndex(setting.disease);
                }
                if (setting.disease_amount != null)
                {
                    def.singleEmitQuantity = (int)setting.disease_amount;
                }

                if (def.diseaseIdx == byte.MaxValue || def.singleEmitQuantity == 0)
                {
                    FumLib.FumTools.RemoveDef(plant, def);
                }
            }
            #endregion
            #region input_element
            if (setting.input_element != null)
            {
                ElementConsumer consumer = plant.AddOrGet <ElementConsumer>();
                Element         element  = ElementLoader.FindElementByName(setting.input_element);

                if (element == null || element.IsSolid)                //invalid element
                {
                    Debug.Log(ToDialog("input_element is bad element: " + setting.input_element));
                    UnityEngine.Object.DestroyImmediate(consumer);
                }
                else if (setting.input_rate <= 0f)   //delete consumer
                {
                    UnityEngine.Object.DestroyImmediate(consumer);
                }
                else
                {
                    consumer.configuration     = ElementConsumer.Configuration.Element;
                    consumer.consumptionRadius = 2;
                    consumer.sampleCellOffset  = new Vector3(0f, 0f);
                    consumer.EnableConsumption(true);
                    consumer.showInStatusPanel = true;
                    consumer.storeOnConsume    = false; //consumer deletes elements; output_element might overrides this
                    consumer.consumptionRate   = (float)setting.input_rate;
                    consumer.elementToConsume  = element.id;
                    consumer.capacityKG        = (float)setting.input_rate * 10;

                    plant.AddOrGet <Storage>().capacityKg = consumer.capacityKG;
                    plant.AddOrGet <SaltPlant>();
                }
            }
            #endregion
            #region output_element
            if (setting.output_element != null)
            {
                ElementConsumer  consumer  = plant.GetComponent <ElementConsumer>();
                ElementConverter converter = plant.AddOrGet <ElementConverter>();
                Element          element   = ElementLoader.FindElementByName(setting.output_element);

                if (element == null)                //invalid element
                {
                    Debug.Log(ToDialog("output_element is bad element: " + setting.output_element));
                    UnityEngine.Object.DestroyImmediate(converter);
                }
                else if (setting.output_rate <= 0f)  //delete converter
                {
                    UnityEngine.Object.DestroyImmediate(converter);
                    if (consumer != null)
                    {
                        consumer.storeOnConsume = false;
                    }
                }
                else
                {
                    if (consumer != null)   //transform elements
                    {
                        consumer.storeOnConsume    = true;
                        converter.consumedElements = new ElementConverter.ConsumedElement[1] {
                            new ElementConverter.ConsumedElement(consumer.elementToConsume.CreateTag(), consumer.consumptionRate)
                        };
                        converter.OutputMultiplier = (float)setting.output_rate / consumer.consumptionRate;
                        //Debug.Log("TAG is: " + consumer.elementToConsume.CreateTag().Name + " SimHash is: " + consumer.elementToConsume.ToString());
                    }
                    else    //create from nothing
                    {
                        converter.consumedElements = new ElementConverter.ConsumedElement[0];
                        converter.OutputMultiplier = 1f;
                    }
                    converter.outputElements = new ElementConverter.OutputElement[1] {
                        new ElementConverter.OutputElement((float)setting.output_rate, element.id, 0f, true, false, 0f, 1f)
                    };

                    plant.AddOrGet <Storage>();
                    plant.AddOrGet <SaltPlant>();
                }
            }
            #endregion
        }
Beispiel #9
0
        protected override void ApplyTrait(GameObject go)
        {
            var reduction_factor  = 4;
            var consumptionRate   = 0.2f / reduction_factor;
            var outputKgPerSecond = 0.2f / reduction_factor;

            if (//go.GetComponent<GeneticTraitComponent>().IsBaby() ||
                go.GetComponent <GeneticTraitComponent>().IsAdult()
                //||go.GetComponent<GeneticTraitComponent>().IsEgg()
                )
            {
                Util.Shuffle(Possible_Inputs);
                element_input = Possible_Inputs.First();
                Util.Shuffle(Possible_Outputs);
                List <SimHashes> complete_list = Possible_Outputs.Where(x => x != element_input).ToList();
                element_output = complete_list.First();
                element_input  = SimHashes.ContaminatedOxygen;
                element_output = SimHashes.Hydrogen;
                var element1      = ElementLoader.FindElementByHash(element_input);
                var element2      = ElementLoader.FindElementByHash(element_output);
                var string_holder = go.AddComponent <StringHolderComponent>();
                string_holder.text = "This critter skin absorbs small quantities of " + element1.name + " and drops " + element2.name;
                string_holder.id   = ID;
                go.AddOrGet <Storage>().capacityKg = 10f;
                ElementConsumer elementConsumer = (ElementConsumer)go.AddOrGet <PassiveElementConsumer>();
                elementConsumer.elementToConsume  = element_input;
                elementConsumer.consumptionRate   = consumptionRate;
                elementConsumer.capacityKG        = 10f;
                elementConsumer.consumptionRadius = (byte)3;
                elementConsumer.showInStatusPanel = true;
                elementConsumer.sampleCellOffset  = new Vector3(0.0f, 0.0f, 0.0f);
                elementConsumer.isRequired        = false;
                elementConsumer.storeOnConsume    = true;
                elementConsumer.showDescriptor    = false;
                elementConsumer.EnableConsumption(true);

                if (element2.IsGas)
                {
                    DebugHelper.Log("element2.IsGas");
                    go.AddOrGet <UpdateElementConsumerPosition>();
                    ElementConverter elementConverter = go.AddOrGet <ElementConverter>();
                    elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                    {
                        new ElementConverter.ConsumedElement(element_input.CreateTag(), consumptionRate)
                    };
                    elementConverter.outputElements = new ElementConverter.OutputElement[1]
                    {
                        new ElementConverter.OutputElement(outputKgPerSecond, element_output, 0.0f, true, false, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
                    };
                }
                if (element2.IsLiquid)
                {
                    DebugHelper.Log("element2.IsLiquid");
                    go.AddOrGet <UpdateElementConsumerPosition>();
                    BubbleSpawner bubbleSpawner = go.AddComponent <BubbleSpawner>();
                    bubbleSpawner.element         = element_output;
                    bubbleSpawner.emitMass        = 2f;
                    bubbleSpawner.emitVariance    = 0.5f;
                    bubbleSpawner.initialVelocity = (Vector2) new Vector2f(0, 1);
                    ElementConverter elementConverter = go.AddOrGet <ElementConverter>();
                    elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                    {
                        new ElementConverter.ConsumedElement(element_input.CreateTag(), consumptionRate)
                    };
                    elementConverter.outputElements = new ElementConverter.OutputElement[1]
                    {
                        new ElementConverter.OutputElement(outputKgPerSecond, element_output, 0.0f, true, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
                    };
                }
                if (element2.IsSolid)
                {
                    DebugHelper.Log("element2.IsSolid");
                    go.AddOrGet <UpdateElementConsumerPosition>();
                    ElementDropper elementDropper = go.AddComponent <ElementDropper>();
                    elementDropper.emitMass   = 2f;
                    elementDropper.emitTag    = element_output.CreateTag();
                    elementDropper.emitOffset = new Vector3(0.0f, 0.0f, 0.0f);
                    ElementConverter elementConverter = go.AddOrGet <ElementConverter>();
                    elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                    {
                        new ElementConverter.ConsumedElement(element_input.CreateTag(), consumptionRate)
                    };
                    elementConverter.outputElements = new ElementConverter.OutputElement[1]
                    {
                        new ElementConverter.OutputElement(outputKgPerSecond, element_output, 0.0f, true, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
                    };
                }
            }
        }
Beispiel #10
0
    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);
    }
Beispiel #11
0
 protected override void OnSpawn()
 {
     myCell    = building.GetCell();
     cellBelow = Grid.GetCellInDirection(myCell, Direction.Down);
     consumer.EnableConsumption(true);
 }
Beispiel #12
0
 protected override void OnPrefabInit()
 {
     elementConsumer.EnableConsumption(false);
     Subscribe(1309017699, OnReplantedDelegate);
     base.OnPrefabInit();
 }