예제 #1
0
        private void ApplyPlaceElementForRoom(FeatureSettings feature, string group, List <Vector2I> cells, Chunk world, SetValuesFunction SetValues, float temperatureMin, float temperatureRange, SeededRandom rnd)
        {
            if (cells != null && cells.Count != 0 && feature.HasGroup(group))
            {
                switch (feature.ElementChoiceGroups[group].selectionMethod)
                {
                case ProcGen.Room.Selection.Weighted:
                case ProcGen.Room.Selection.WeightedResample:
                    for (int j = 0; j < cells.Count; j++)
                    {
                        Vector2I vector2I3 = cells[j];
                        int      x2        = vector2I3.x;
                        Vector2I vector2I4 = cells[j];
                        int      num2      = Grid.XYToCell(x2, vector2I4.y);
                        if (Grid.IsValidCell(num2) && !highPriorityClaims.Contains(num2))
                        {
                            WeightedSimHash oneWeightedSimHash2 = feature.GetOneWeightedSimHash(group, rnd);
                            ElementOverride elementOverride2    = GetElementOverride(oneWeightedSimHash2.element, oneWeightedSimHash2.overrides);
                            if (!elementOverride2.overrideTemperature)
                            {
                                elementOverride2.pdelement.temperature = temperatureMin + world.heatOffset[num2] * temperatureRange;
                            }
                            if (!elementOverride2.overrideMass)
                            {
                                elementOverride2.pdelement.mass = GetDensityMassForCell(world, num2, elementOverride2.mass);
                            }
                            SetValues(num2, elementOverride2.element, elementOverride2.pdelement, elementOverride2.dc);
                        }
                    }
                    break;

                default:
                {
                    WeightedSimHash oneWeightedSimHash = feature.GetOneWeightedSimHash(group, rnd);
                    DebugUtil.LogArgs("Picked one: ", oneWeightedSimHash.element);
                    for (int i = 0; i < cells.Count; i++)
                    {
                        Vector2I vector2I  = cells[i];
                        int      x         = vector2I.x;
                        Vector2I vector2I2 = cells[i];
                        int      num       = Grid.XYToCell(x, vector2I2.y);
                        if (Grid.IsValidCell(num) && !highPriorityClaims.Contains(num))
                        {
                            ElementOverride elementOverride = GetElementOverride(oneWeightedSimHash.element, oneWeightedSimHash.overrides);
                            if (!elementOverride.overrideTemperature)
                            {
                                elementOverride.pdelement.temperature = temperatureMin + world.heatOffset[num] * temperatureRange;
                            }
                            if (!elementOverride.overrideMass)
                            {
                                elementOverride.pdelement.mass = GetDensityMassForCell(world, num, elementOverride.mass);
                            }
                            SetValues(num, elementOverride.element, elementOverride.pdelement, elementOverride.dc);
                        }
                    }
                    break;
                }
                }
            }
        }
예제 #2
0
        public void ElementOverride()
        {
            var element_override = new ElementOverride <string> (new Element <string> {
                Foo = "foo"
            });

            AssertAreEqual("<element><foo>bat</foo></element>", element_override);
        }
예제 #3
0
        public static ElementOverride GetElementOverride(string element, SampleDescriber.Override overrides)
        {
            Debug.Assert(element != null && element.Length > 0);
            ElementOverride result = default(ElementOverride);

            result.element = ElementLoader.FindElementByName(element);
            Debug.Assert(result.element != null, "Couldn't find an element called " + element);
            result.pdelement   = result.element.defaultValues;
            result.dc          = Sim.DiseaseCell.Invalid;
            result.mass        = result.element.defaultValues.mass;
            result.temperature = result.element.defaultValues.temperature;
            if (overrides == null)
            {
                return(result);
            }
            result.overrideMass          = false;
            result.overrideTemperature   = false;
            result.overrideDiseaseIdx    = false;
            result.overrideDiseaseAmount = false;
            if (overrides.massOverride.HasValue)
            {
                result.mass         = overrides.massOverride.Value;
                result.overrideMass = true;
            }
            if (overrides.massMultiplier.HasValue)
            {
                result.mass        *= overrides.massMultiplier.Value;
                result.overrideMass = true;
            }
            if (overrides.temperatureOverride.HasValue)
            {
                result.temperature         = overrides.temperatureOverride.Value;
                result.overrideTemperature = true;
            }
            if (overrides.temperatureMultiplier.HasValue)
            {
                result.temperature        *= overrides.temperatureMultiplier.Value;
                result.overrideTemperature = true;
            }
            if (overrides.diseaseOverride != null)
            {
                result.diseaseIdx         = (byte)WorldGen.GetDiseaseIdx(overrides.diseaseOverride);
                result.overrideDiseaseIdx = true;
            }
            if (overrides.diseaseAmountOverride.HasValue)
            {
                result.diseaseAmount         = overrides.diseaseAmountOverride.Value;
                result.overrideDiseaseAmount = true;
            }
            if (result.overrideTemperature)
            {
                result.pdelement.temperature = result.temperature;
            }
            if (result.overrideMass)
            {
                result.pdelement.mass = result.mass;
            }
            if (result.overrideDiseaseIdx)
            {
                result.dc.diseaseIdx = result.diseaseIdx;
            }
            if (result.overrideDiseaseAmount)
            {
                result.dc.elementCount = result.diseaseAmount;
            }
            return(result);
        }