Exemplo n.º 1
0
 public static RenderInfoLayer GetRenderInfoLayer(bool isReplacement, SimHashes element)
 {
     return(isReplacement ? RenderInfoLayer.Replacement : ((element == SimHashes.Void) ? RenderInfoLayer.UnderConstruction : RenderInfoLayer.Built));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Return true if a SimHashes is discovered. Should not be called until game loaded.
 /// </summary>
 /// <param name="hash"> SimHash of the element </param>
 /// <returns></returns>
 public static bool IsSimHashesDiscovered(SimHashes hash)
 {
     return(DiscoveredResources.Instance.IsDiscovered(ElementLoader.FindElementByHash(hash).tag));
 }
Exemplo n.º 3
0
            private static ColorHSV ScaleColorToPressure(ColorHSV color, float fraction, SimHashes elementID)
            {
                if (elementID == SimHashes.CarbonDioxide)
                {
                    color.V *= (1 - fraction) * 2;
                }
                else
                {
                    color.S *= fraction * 1.25f;
                    color.V -= (1 - fraction) / 2;
                }

                return(color);
            }
    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);
    }
Exemplo n.º 5
0
 public GameObject PlaceBuilding(int x, int y, string prefab_id, SimHashes element = SimHashes.Cuprite)
 {
     return(PlaceBuilding(RootCell, x, y, prefab_id, element));
 }
Exemplo n.º 6
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)
                    };
                }
            }
        }
Exemplo n.º 7
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
            go.AddOrGet <PipedRustDeoxidizer>().maxMass = 1.8f;

            Storage storage = go.AddOrGet <Storage>();

            storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
            storage.showInUI = true;

            MultiOutput multiOut = go.AddOrGet <MultiOutput>();

            SimHashes[] filter = new SimHashes[1] {
                SimHashes.Oxygen
            };
            multiOut.AddOutputPort(ConduitType.Gas, new CellOffset(1, 1), PortIconColors.Oxygen, false, filter, false);
            filter = new SimHashes[1] {
                SimHashes.ChlorineGas
            };
            multiOut.AddOutputPort(ConduitType.Gas, new CellOffset(0, 1), PortIconColors.ChlorineGas, false, filter, false);

            //MultiInput multiIn = go.AddOrGet<MultiInput>();
            //InputPort in1 = multiIn.AddInputPort(ConduitType.Gas, new CellOffset(1, 0), PortIconColors.NaturalGas, 1f, 2f, new Tag("Methane"), true);
            //InputPort in2 = multiIn.AddInputPort(ConduitType.Gas, new CellOffset(0, 0), PortIconColors.Hydrogen, 1f, 3f, new Tag("Hydrogen"), true);
            //in1.RequiresConnection = false;

            ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag = new Tag("Rust");
            manualDeliveryKG.capacity         = 585f;
            manualDeliveryKG.refillMass       = 193.05f;
            manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;
            ManualDeliveryKG manualDeliveryKG2 = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKG2.SetStorage(storage);
            manualDeliveryKG2.requestedItemTag = new Tag("Salt");
            manualDeliveryKG2.capacity         = 195f;
            manualDeliveryKG2.refillMass       = 64.3500061f;
            manualDeliveryKG2.allowPause       = true;
            manualDeliveryKG2.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;

            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            //elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
            //{
            //    new ElementConverter.ConsumedElement(new Tag("Methane"), 0.1f),
            //    new ElementConverter.ConsumedElement(new Tag("Hydrogen"), 0.1f)
            //};
            elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
            {
                new ElementConverter.ConsumedElement(new Tag("Rust"), RUST_KG_CONSUMPTION_RATE),
                new ElementConverter.ConsumedElement(new Tag("Salt"), SALT_KG_CONSUMPTION_RATE)
            };

            elementConverter.outputElements = new ElementConverter.OutputElement[3]
            {
                new ElementConverter.OutputElement(1.8f, SimHashes.Oxygen, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(1f, SimHashes.ChlorineGas, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(IRON_CONVERSION_RATIO, SimHashes.IronOre, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0)
            };
            //elementConverter.outputElements = new ElementConverter.OutputElement[3]
            //{
            //    new ElementConverter.OutputElement(OXYGEN_CONVERSION_RATIO, SimHashes.Oxygen, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0),
            //    new ElementConverter.OutputElement(CHLORINE_CONVERSION_RATIO, SimHashes.ChlorineGas, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0),
            //    new ElementConverter.OutputElement(IRON_CONVERSION_RATIO, SimHashes.IronOre, OXYGEN_TEMPERATURE, false, true, 0.0f, 1f, 1f, byte.MaxValue, 0)
            //};
            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 24f;
            elementDropper.emitTag    = SimHashes.IronOre.CreateTag();
            elementDropper.emitOffset = new Vector3(0.0f, 1f, 0.0f);
            Prioritizable.AddRef(go);
        }
Exemplo n.º 8
0
 public static void ModifyMass(int gameCell, float mass, byte disease_idx, int disease_count, CellModifyMassEvent ev, float temperature = -1f, SimHashes element = SimHashes.Vacuum)
 {
     if (element != SimHashes.Vacuum)
     {
         int elementIndex = GetElementIndex(element);
         if (elementIndex != -1)
         {
             if (temperature == -1f)
             {
                 temperature = ElementLoader.elements[elementIndex].defaultValues.temperature;
             }
             ModifyCell(gameCell, elementIndex, temperature, mass, disease_idx, disease_count, ReplaceType.None, false, -1);
         }
     }
     else
     {
         ModifyCell(gameCell, 0, temperature, mass, disease_idx, disease_count, ReplaceType.None, false, -1);
     }
 }
Exemplo n.º 9
0
 public unsafe static void AddElementConsumer(int gameCell, ElementConsumer.Configuration configuration, SimHashes element, byte radius, int cb_handle)
 {
     Debug.Assert(Grid.IsValidCell(gameCell));
     if (Grid.IsValidCell(gameCell))
     {
         int elementIndex = ElementLoader.GetElementIndex(element);
         AddElementConsumerMessage *ptr = stackalloc AddElementConsumerMessage[1];
         ptr->cellIdx       = gameCell;
         ptr->configuration = (byte)configuration;
         ptr->elementIdx    = (byte)elementIndex;
         ptr->radius        = radius;
         ptr->callbackIdx   = cb_handle;
         Sim.SIM_HandleMessage(2024405073, sizeof(AddElementConsumerMessage), (byte *)ptr);
     }
 }
Exemplo n.º 10
0
 protected override void PopulateElemGrowthInfo()
 {
     InitializeElemGrowthArray(ref elemGrowthInfo, Disease.DEFAULT_GROWTH_INFO);
     AddGrowthRule(new GrowthRule
     {
         underPopulationDeathRate         = new float?(2.66666675f),
         minCountPerKG                    = new float?(0.4f),
         populationHalfLife               = new float?(12000f),
         maxCountPerKG                    = new float?(500f),
         overPopulationHalfLife           = new float?(1200f),
         minDiffusionCount                = new int?(1000),
         diffusionScale                   = new float?(0.001f),
         minDiffusionInfestationTickCount = new byte?(1)
     });
     AddGrowthRule(new StateGrowthRule(Element.State.Solid)
     {
         minCountPerKG          = new float?(0.4f),
         populationHalfLife     = new float?(3000f),
         overPopulationHalfLife = new float?(1200f),
         diffusionScale         = new float?(1E-06f),
         minDiffusionCount      = new int?(1000000)
     });
     SimHashes[] array = new SimHashes[2]
     {
         SimHashes.Carbon,
         SimHashes.Diamond
     };
     foreach (SimHashes element in array)
     {
         AddGrowthRule(new ElementGrowthRule(element)
         {
             underPopulationDeathRate = new float?(0f),
             populationHalfLife       = new float?(float.PositiveInfinity),
             overPopulationHalfLife   = new float?(3000f),
             maxCountPerKG            = new float?(1000f),
             diffusionScale           = new float?(0.005f)
         });
     }
     AddGrowthRule(new ElementGrowthRule(SimHashes.BleachStone)
     {
         populationHalfLife     = new float?(10f),
         overPopulationHalfLife = new float?(10f),
         minDiffusionCount      = new int?(100000),
         diffusionScale         = new float?(0.001f)
     });
     AddGrowthRule(new StateGrowthRule(Element.State.Gas)
     {
         minCountPerKG          = new float?(250f),
         populationHalfLife     = new float?(12000f),
         overPopulationHalfLife = new float?(1200f),
         maxCountPerKG          = new float?(10000f),
         minDiffusionCount      = new int?(5100),
         diffusionScale         = new float?(0.005f)
     });
     SimHashes[] array2 = new SimHashes[3]
     {
         SimHashes.CarbonDioxide,
         SimHashes.Methane,
         SimHashes.SourGas
     };
     foreach (SimHashes element2 in array2)
     {
         AddGrowthRule(new ElementGrowthRule(element2)
         {
             underPopulationDeathRate = new float?(0f),
             populationHalfLife       = new float?(float.PositiveInfinity),
             overPopulationHalfLife   = new float?(6000f)
         });
     }
     AddGrowthRule(new ElementGrowthRule(SimHashes.ChlorineGas)
     {
         populationHalfLife     = new float?(10f),
         overPopulationHalfLife = new float?(10f),
         minDiffusionCount      = new int?(100000),
         diffusionScale         = new float?(0.001f)
     });
     AddGrowthRule(new StateGrowthRule(Element.State.Liquid)
     {
         minCountPerKG          = new float?(0.4f),
         populationHalfLife     = new float?(1200f),
         overPopulationHalfLife = new float?(300f),
         maxCountPerKG          = new float?(100f),
         diffusionScale         = new float?(0.01f)
     });
     SimHashes[] array3 = new SimHashes[4]
     {
         SimHashes.CrudeOil,
         SimHashes.Petroleum,
         SimHashes.Naphtha,
         SimHashes.LiquidMethane
     };
     foreach (SimHashes element3 in array3)
     {
         AddGrowthRule(new ElementGrowthRule(element3)
         {
             populationHalfLife     = new float?(float.PositiveInfinity),
             overPopulationHalfLife = new float?(6000f),
             maxCountPerKG          = new float?(1000f),
             diffusionScale         = new float?(0.005f)
         });
     }
     AddGrowthRule(new ElementGrowthRule(SimHashes.Chlorine)
     {
         populationHalfLife     = new float?(10f),
         overPopulationHalfLife = new float?(10f),
         minDiffusionCount      = new int?(100000),
         diffusionScale         = new float?(0.001f)
     });
     InitializeElemExposureArray(ref elemExposureInfo, Disease.DEFAULT_EXPOSURE_INFO);
     AddExposureRule(new ExposureRule
     {
         populationHalfLife = new float?(float.PositiveInfinity)
     });
     AddExposureRule(new ElementExposureRule(SimHashes.Chlorine)
     {
         populationHalfLife = new float?(10f)
     });
     AddExposureRule(new ElementExposureRule(SimHashes.ChlorineGas)
     {
         populationHalfLife = new float?(10f)
     });
 }
Exemplo n.º 11
0
    public static void AddRemoveSubstance(int gameCell, SimHashes new_element, CellAddRemoveSubstanceEvent ev, float mass, float temperature, byte disease_idx, int disease_count, bool do_vertical_solid_displacement = true, int callbackIdx = -1)
    {
        int elementIndex = GetElementIndex(new_element);

        AddRemoveSubstance(gameCell, elementIndex, ev, mass, temperature, disease_idx, disease_count, do_vertical_solid_displacement, callbackIdx);
    }
Exemplo n.º 12
0
 public OutputItem(SimHashes element, float creation_rate, bool store, float min_temperature = 0f)
 {
     this = new OutputItem(element, creation_rate, store, CellOffset.none, min_temperature);
 }
Exemplo n.º 13
0
    public static Formula CreateSimpleFormula(Tag input_element, float input_mass_rate, float max_stored_input_mass, SimHashes output_element = SimHashes.Void, float output_mass_rate = 0f, bool store_output_mass = true, CellOffset output_offset = default(CellOffset), float min_output_temperature = 0f)
    {
        Formula result = default(Formula);

        result.inputs = new InputItem[1]
        {
            new InputItem(input_element, input_mass_rate, max_stored_input_mass)
        };
        if (output_element != SimHashes.Void)
        {
            result.outputs = new OutputItem[1]
            {
                new OutputItem(output_element, output_mass_rate, store_output_mass, output_offset, min_output_temperature)
            };
        }
        else
        {
            result.outputs = null;
        }
        return(result);
    }
Exemplo n.º 14
0
            public RenderInfo(BlockTileRenderer renderer, int queryLayer, int renderLayer, BuildingDef def, SimHashes element)
            {
                this.queryLayer  = queryLayer;
                this.renderLayer = renderLayer;
                rootPosition     = new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer));
                this.element     = element;
                material         = new Material(def.BlockTileMaterial);
                if (def.BlockTileIsTransparent)
                {
                    material.renderQueue = RenderQueues.Liquid;
                    decorZOffset         = Grid.GetLayerZ(Grid.SceneLayer.TileFront) - Grid.GetLayerZ(Grid.SceneLayer.Liquid) - 1f;
                }
                else if (def.SceneLayer == Grid.SceneLayer.TileMain)
                {
                    material.renderQueue = RenderQueues.BlockTiles;
                }
                material.DisableKeyword("ENABLE_SHINE");
                if (element != SimHashes.Void)
                {
                    material.SetTexture("_MainTex", def.BlockTileAtlas.texture);
                    material.name = def.BlockTileAtlas.name + "Mat";
                    if ((UnityEngine.Object)def.BlockTileShineAtlas != (UnityEngine.Object)null)
                    {
                        material.SetTexture("_SpecularTex", def.BlockTileShineAtlas.texture);
                        material.EnableKeyword("ENABLE_SHINE");
                    }
                }
                else
                {
                    material.SetTexture("_MainTex", def.BlockTilePlaceAtlas.texture);
                    material.name = def.BlockTilePlaceAtlas.name + "Mat";
                }
                int num  = Grid.WidthInCells / 16;
                int num2 = Grid.HeightInCells / 16;

                meshChunks  = new Mesh[num, num2];
                dirtyChunks = new bool[num, num2];
                for (int i = 0; i < num2; i++)
                {
                    for (int j = 0; j < num; j++)
                    {
                        dirtyChunks[j, i] = true;
                    }
                }
                BlockTileDecorInfo blockTileDecorInfo = (element != SimHashes.Void) ? def.DecorBlockTileInfo : def.DecorPlaceBlockTileInfo;

                if ((bool)blockTileDecorInfo)
                {
                    decorRenderInfo = new DecorRenderInfo(num, num2, queryLayer, def, blockTileDecorInfo);
                }
                string name       = def.BlockTileAtlas.items[0].name;
                int    length     = name.Length;
                int    num3       = length -= 4;
                int    num4       = num3 - 8;
                int    num5       = num4 - 1;
                int    startIndex = num5 - 8;

                atlasInfo = new AtlasInfo[def.BlockTileAtlas.items.Length];
                for (int k = 0; k < atlasInfo.Length; k++)
                {
                    TextureAtlas.Item item   = def.BlockTileAtlas.items[k];
                    string            value  = item.name.Substring(startIndex, 8);
                    string            value2 = item.name.Substring(num4, 8);
                    int requiredConnections  = Convert.ToInt32(value, 2);
                    int forbiddenConnections = Convert.ToInt32(value2, 2);
                    atlasInfo[k].requiredConnections  = (Bits)requiredConnections;
                    atlasInfo[k].forbiddenConnections = (Bits)forbiddenConnections;
                    atlasInfo[k].uvBox = item.uvBox;
                    atlasInfo[k].name  = item.name;
                }
                trimUVSize = new Vector2(0.03125f, 0.03125f);
            }
Exemplo n.º 15
0
        public static void UpdateBuildingColor(BuildingComplete building)
        {
            string    buildingName = building.name.Replace("Complete", string.Empty);
            SimHashes material     = MaterialHelper.ExtractMaterial(building);

            Color32 color;

            if (State.ConfiguratorState.Enabled)
            {
                switch (State.ConfiguratorState.ColorMode)
                {
                case ColorMode.Json:
                    color = material.GetMaterialColorForType(buildingName);
                    break;

                case ColorMode.DebugColor:
                    color = material.ToDebugColor();
                    break;

                default:
                    color = ColorHelper.DefaultColor;
                    break;
                }
            }
            else
            {
                color = ColorHelper.DefaultColor;
            }

            if (State.TileNames.Contains(buildingName))
            {
                try
                {
                    if (ColorHelper.TileColors == null)
                    {
                        ColorHelper.TileColors = new Color?[Grid.CellCount];
                    }

                    ColorHelper.TileColors[Grid.PosToCell(building.gameObject)] = color;

                    return;
                }
                catch (Exception e)
                {
                    State.Logger.Log("Error while aquiring cell color");
                    State.Logger.Log(e);
                }
            }

            Color32 dimmedColor = color.SetBrightness(color.GetBrightness() / 2);

            // storagelocker
            StorageLocker storageLocker = building.GetComponent <StorageLocker>();

            if (storageLocker != null)
            {
                //SetFilteredStorageColors(storageLocker.filteredStorage, color, dimmedColor);
                SetFilteredStorageColors(storageLocker, (Color)color, (Color)dimmedColor);
            }
            else
            {
                // ownable
                Ownable ownable = building.GetComponent <Ownable>();

                if (ownable != null)
                {
                    //ownable.ownedTint   = color;
                    SetField(ownable, "ownedTint", (Color)color);
                    //ownable.unownedTint = dimmedColor;
                    SetField(ownable, "unownedTint", (Color)dimmedColor);
                    //ownable.UpdateTint();
                    Invoke(ownable, "UpdateTint");
                }
                else
                {
                    // rationbox
                    RationBox rationBox = building.GetComponent <RationBox>();

                    if (rationBox != null)
                    {
                        //SetFilteredStorageColors(rationBox.filteredStorage, color, dimmedColor);
                        SetFilteredStorageColors(rationBox, (Color)color, (Color)dimmedColor);
                    }
                    else
                    {
                        // refrigerator
                        Refrigerator fridge = building.GetComponent <Refrigerator>();

                        if (fridge != null)
                        {
                            //SetFilteredStorageColors(fridge.filteredStorage, color, dimmedColor);
                            SetFilteredStorageColors(fridge, (Color)color, (Color)dimmedColor);
                        }
                        else
                        {
                            // anything else
                            KAnimControllerBase kAnimControllerBase = building.GetComponent <KAnimControllerBase>();

                            if (kAnimControllerBase != null)
                            {
                                kAnimControllerBase.TintColour = color;
                            }
                            else
                            {
                                Debug.LogError(
                                    $"Can't find KAnimControllerBase component in <{buildingName}> and its not a registered tile.");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
 public unsafe static void ModifyElementEmitter(int sim_handle, int game_cell, int max_depth, SimHashes element, float emit_interval, float emit_mass, float emit_temperature, float max_pressure, byte disease_idx, int disease_count)
 {
     Debug.Assert(Grid.IsValidCell(game_cell));
     if (Grid.IsValidCell(game_cell))
     {
         int elementIndex = ElementLoader.GetElementIndex(element);
         ModifyElementEmitterMessage *ptr = stackalloc ModifyElementEmitterMessage[1];
         ptr->handle          = sim_handle;
         ptr->cellIdx         = game_cell;
         ptr->emitInterval    = emit_interval;
         ptr->emitMass        = emit_mass;
         ptr->emitTemperature = emit_temperature;
         ptr->maxPressure     = max_pressure;
         ptr->elementIdx      = (byte)elementIndex;
         ptr->maxDepth        = (byte)max_depth;
         ptr->diseaseIdx      = disease_idx;
         ptr->diseaseCount    = disease_count;
         Sim.SIM_HandleMessage(403589164, sizeof(ModifyElementEmitterMessage), (byte *)ptr);
     }
 }
Exemplo n.º 17
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);
    }
Exemplo n.º 18
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            go.AddOrGet <LoopingSounds>();
            Light2D light2D = go.AddOrGet <Light2D>();

            light2D.overlayColour = LIGHT2D.FLOORLAMP_OVERLAYCOLOR;
            light2D.Color         = KELVIN1500;
            light2D.Range         = RANGE;
            light2D.Offset        = new Vector2(0f, 0.5f);
            light2D.shape         = LightShape.Circle;
            light2D.drawOverlay   = true;
            light2D.Lux           = LUX;
            light2D.overlayColour = Color.red;

            go.AddOrGet <Lantern>();
            SimHashes element    = SimHashes.CrudeOil; //Config.SettingsManager.Settings.LanternPowerSource == "Oil" ? SimHashes.CrudeOil : SimHashes.Petroleum;
            Tag       elementTag = element.CreateTag();

            Storage storage = go.AddOrGet <Storage>();

            storage.capacityKg       = CAPACITY;
            storage.showInUI         = true;
            storage.allowItemRemoval = false;
            storage.storageFilters   = new List <Tag> {
                elementTag
            };

            ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag       = elementTag;
            manualDeliveryKG.capacity               = CAPACITY;
            manualDeliveryKG.refillMass             = 1.5f;
            manualDeliveryKG.choreTypeIDHash        = Db.Get().ChoreTypes.FetchCritical.IdHash;
            manualDeliveryKG.operationalRequirement = FetchOrder2.OperationalRequirement.Functional;
            manualDeliveryKG.allowPause             = true;

            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType          = ConduitType.Liquid;
            conduitConsumer.consumptionRate      = CONSUMPTION_RATE;
            conduitConsumer.capacityTag          = GameTagExtensions.Create(element);
            conduitConsumer.capacityKG           = CAPACITY;
            conduitConsumer.forceAlwaysSatisfied = true;
            conduitConsumer.ignoreMinMassCheck   = true;
            conduitConsumer.alwaysConsume        = true;
            conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;

            ElementConverter elementConverter = go.AddComponent <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
            {
                new ElementConverter.ConsumedElement(ElementLoader.FindElementByHash(element).tag, CONSUMPTION_RATE)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(0.01f, SimHashes.CarbonDioxide, 303.15f, false, false, 0f, 1f, 1f, byte.MaxValue, 0)
            };
            go.AddOrGetDef <LightController.Def>();

            go.GetComponent <RequireInputs>().SetRequirements(false, false);
            Prioritizable.AddRef(go);
        }
Exemplo n.º 19
0
        public static float Resources(SimHashes hash)
        {
            Tag tag = ElementLoader.FindElementByHash(hash).tag;

            return(Resources(tag));
        }
Exemplo n.º 20
0
 public static void RegisterSimHash(SimHashes hash, string name)
 {
     SimHashNameLookup.Add(hash, name);
     ReverseSimHashNameLookup.Add(name, hash);
 }
 public SubstanceChunk CreateChunk(SimHashes element_id, float mass, float temperature, byte diseaseIdx, int diseaseCount, Vector3 position)
 {
     return(CreateChunk(ElementLoader.FindElementByHash(element_id), mass, temperature, diseaseIdx, diseaseCount, position));
 }
Exemplo n.º 22
0
        public ElementModifier(float melting, float boiling, float specificHeatCapacity, SimHashes solidName, SimHashes liquidName, SimHashes gasName)
        {
            names = new Names();
            temps = new Temperatures();

            names.Solid  = solidName;
            names.Liquid = liquidName;
            names.Gas    = gasName;

            temps.Melting = melting;
            temps.Boiling = boiling;
            temps.SpecificHeatCapacity = specificHeatCapacity;

            ApplyChanges();
        }
Exemplo n.º 23
0
 private void Fill(int x, int y, SimHashes id = SimHashes.Ice)
 {
     SimMessages.ReplaceElement(Grid.OffsetCell(RootCell, x, y), id, CellEventLogger.Instance.Scenario, 10000f, -1f, byte.MaxValue, 0, -1);
 }
Exemplo n.º 24
0
 private static void AddHashToTable(SimHashes hash, string id)
 {
     SimHashTable.Add(hash, id);
     SimHashReverseTable.Add(id, hash);
 }
Exemplo n.º 25
0
    public static GameObject PlaceBuilding(int root_cell, int x, int y, string prefab_id, SimHashes element = SimHashes.Cuprite)
    {
        int         cell        = Grid.OffsetCell(root_cell, x, y);
        BuildingDef buildingDef = Assets.GetBuildingDef(prefab_id);

        if ((UnityEngine.Object)buildingDef == (UnityEngine.Object)null || buildingDef.PlacementOffsets == null)
        {
            DebugUtil.LogErrorArgs("Missing def for", prefab_id);
        }
        Element element2 = ElementLoader.FindElementByHash(element);

        Debug.Assert(element2 != null, "Missing primary element.");
        GameObject gameObject = buildingDef.Build(buildingDef.GetBuildingCell(cell), Orientation.Neutral, null, new Tag[2]
        {
            element2.tag,
            ElementLoader.FindElementByHash(SimHashes.SedimentaryRock).tag
        }, 293.15f, false, -1f);
        PrimaryElement component = gameObject.GetComponent <PrimaryElement>();

        component.InternalTemperature = 300f;
        component.Temperature         = 300f;
        return(gameObject);
    }
Exemplo n.º 26
0
 /// <summary>
 /// Applied before RemoveBlock runs.
 /// </summary>
 private static bool RemoveBlock_Prefix(BuildingDef def, bool isReplacement,
                                        SimHashes element, int cell)
 {
     TileMeshRenderer.Instance?.RemoveBlock(def, isReplacement, element, cell);
     return(false);
 }
Exemplo n.º 27
0
            /// <summary>
            /// Add flat value to color hue when pressure reaches EarPopFloat
            /// </summary>
            private static ColorHSV MarkEarDrumPopPressure(ColorHSV color, float mass, SimHashes elementID)
            {
                if (mass > EarPopFloat)
                {
                    if (elementID == SimHashes.CarbonDioxide)
                    {
                        color.V += 0.3f;
                        color.S += 0.4f;
                    }
                    else
                    {
                        // TODO: make hue change customizable in config
                        color.H += 0.1f;
                    }
                }

                return(color);
            }
Exemplo n.º 28
0
            public static bool Prefix(int cell, SimHashes element, BlockTileRenderer __instance, ref Color __result)
            {
                try
                {
                    Color tileColor;

                    if (State.ConfiguratorState.Enabled)
                    {
                        if (State.ConfiguratorState.LegacyTileColorHandling)
                        {
                            switch (State.ConfiguratorState.ColorMode)
                            {
                            case ColorMode.Json:
                                tileColor = ColorHelper.GetCellColorJson(cell);
                                break;

                            case ColorMode.DebugColor:
                                tileColor = ColorHelper.GetCellColorDebug(cell);
                                break;

                            default:
                                tileColor = ColorHelper.DefaultCellColor;
                                break;
                            }
                        }
                        else
                        {
                            if (ColorHelper.TileColors.Length > cell && ColorHelper.TileColors[cell].HasValue)
                            {
                                tileColor = ColorHelper.TileColors[cell].Value;
                            }
                            else
                            {
                                //if (cell == __instance.invalidPlaceCell)
                                if (cell == (int)GetField(__instance, "invalidPlaceCell"))
                                {
                                    __result = ColorHelper.InvalidCellColor;
                                    return(false);
                                }

                                tileColor = ColorHelper.DefaultCellColor;
                            }
                        }
                    }
                    else
                    {
                        tileColor = ColorHelper.DefaultCellColor;
                    }

                    //if (cell == __instance.selectedCell)
                    if (cell == (int)GetField(__instance, "selectedCell"))
                    {
                        __result = tileColor * 1.5f;
                        return(false);
                    }

                    //if (cell == __instance.highlightCell)
                    if (cell == (int)GetField(__instance, "highlightCell"))
                    {
                        __result = tileColor * 1.25f;
                        return(false);
                    }

                    __result = tileColor;
                    return(false);
                }
                catch (Exception e)
                {
                    State.Logger.Log("EnterCell failed.");
                    State.Logger.Log(e);
                }

                return(true);
            }
Exemplo n.º 29
0
    protected override void OnDragTool(int cell, int distFromOrigin)
    {
        if (Grid.IsValidCell(cell))
        {
            switch (type)
            {
            case Type.PaintPlant:
                break;

            case Type.Dig:
                SimMessages.Dig(cell, -1);
                break;

            case Type.Heat:
                SimMessages.ModifyEnergy(cell, 10000f, 10000f, SimMessages.EnergySourceID.DebugHeat);
                break;

            case Type.Cool:
                SimMessages.ModifyEnergy(cell, -10000f, 10000f, SimMessages.EnergySourceID.DebugCool);
                break;

            case Type.AddPressure:
                SimMessages.ModifyMass(cell, 10000f, byte.MaxValue, 0, CellEventLogger.Instance.DebugToolModifyMass, 293f, SimHashes.Oxygen);
                break;

            case Type.RemovePressure:
                SimMessages.ModifyMass(cell, -10000f, byte.MaxValue, 0, CellEventLogger.Instance.DebugToolModifyMass, 0f, SimHashes.Oxygen);
                break;

            case Type.ReplaceSubstance:
                DoReplaceSubstance(cell);
                break;

            case Type.FillReplaceSubstance:
            {
                GameUtil.FloodFillNext.Clear();
                GameUtil.FloodFillVisited.Clear();
                SimHashes elem_hash = Grid.Element[cell].id;
                GameUtil.FloodFillConditional(cell, delegate(int check_cell)
                    {
                        bool result = false;
                        if (Grid.Element[check_cell].id == elem_hash)
                        {
                            result = true;
                            DoReplaceSubstance(check_cell);
                        }
                        return(result);
                    }, GameUtil.FloodFillVisited, null);
                break;
            }

            case Type.Clear:
                ClearCell(cell);
                break;

            case Type.AddSelection:
                DebugBaseTemplateButton.Instance.AddToSelection(cell);
                break;

            case Type.RemoveSelection:
                DebugBaseTemplateButton.Instance.RemoveFromSelection(cell);
                break;

            case Type.Destroy:
                DestroyCell(cell);
                break;

            case Type.Deconstruct:
                DeconstructCell(cell);
                break;

            case Type.Sample:
                DebugPaintElementScreen.Instance.SampleCell(cell);
                break;
            }
        }
    }
Exemplo n.º 30
0
 public void Rebuild(BlockTileRenderer renderer, Dictionary <int, int> occupiedCells, int chunk_x, int chunk_y, float z_offset, int chunkEdgeSize, List <Vector3> vertices, List <Vector2> uvs, List <Color> colours, List <int> indices, SimHashes element)
 {
     vertices.Clear();
     uvs.Clear();
     triangles.Clear();
     colours.Clear();
     indices.Clear();
     for (int i = chunk_y * chunkEdgeSize; i < chunk_y * chunkEdgeSize + chunkEdgeSize; i++)
     {
         for (int j = chunk_x * chunkEdgeSize; j < chunk_x * chunkEdgeSize + chunkEdgeSize; j++)
         {
             int num = i * Grid.WidthInCells + j;
             if (occupiedCells.ContainsKey(num))
             {
                 Color cellColour          = renderer.GetCellColour(num, element);
                 Bits  decorConnectionBits = renderer.GetDecorConnectionBits(j, i, queryLayer);
                 AddDecor(j, i, z_offset, decorConnectionBits, cellColour, vertices, uvs, triangles, colours);
             }
         }
     }
     if (vertices.Count > 0)
     {
         Mesh mesh = meshChunks[chunk_x, chunk_y];
         if ((UnityEngine.Object)mesh == (UnityEngine.Object)null)
         {
             mesh      = new Mesh();
             mesh.name = "DecorRender";
             meshChunks[chunk_x, chunk_y] = mesh;
         }
         triangles.Sort((TriangleInfo a, TriangleInfo b) => a.sortOrder.CompareTo(b.sortOrder));
         for (int k = 0; k < triangles.Count; k++)
         {
             TriangleInfo triangleInfo = triangles[k];
             indices.Add(triangleInfo.i0);
             TriangleInfo triangleInfo2 = triangles[k];
             indices.Add(triangleInfo2.i1);
             TriangleInfo triangleInfo3 = triangles[k];
             indices.Add(triangleInfo3.i2);
         }
         mesh.Clear();
         mesh.SetVertices(vertices);
         mesh.SetUVs(0, uvs);
         mesh.SetColors(colours);
         mesh.SetTriangles(indices, 0);
     }
     else
     {
         meshChunks[chunk_x, chunk_y] = null;
     }
 }