示例#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;
                }
                }
            }
        }
        public JsonResult SaveFeatureSettings(FeatureSettings entity)
        {
            var result = new JsonResult()
            {
                Data = new
                {
                    success = false,
                    message = "There was an error processing your request."
                }
            };

            var success = 0;

                var featureSettings = Context.FeatureSettings.FirstOrDefault();
                if (featureSettings != null)
                {
                    featureSettings.EventsEnabled = entity.EventsEnabled;

                    success = Context.SaveChanges();

                    // Bust the site settings cache for events since we modified it's value
                    SettingsUtils.EventsEnabled(true);
                }

            if (success > 0)
            {
                result.Data = new
                {
                    success = true,
                    message = "Settings saved successfully."
                };
            }

            return result;
        }
示例#3
0
        private void HandleSprinkleOfElement(WorldGenSettings settings, Tag targetTag, Chunk world, SetValuesFunction SetValues, float temperatureMin, float temperatureRange, SeededRandom rnd)
        {
            FeatureSettings feature  = settings.GetFeature(targetTag.Name);
            string          element  = feature.GetOneWeightedSimHash("SprinkleOfElementChoices", rnd).element;
            Element         element2 = ElementLoader.FindElementByName(element);

            ProcGen.Room value = null;
            SettingsCache.rooms.TryGetValue(targetTag.Name, out value);
            SampleDescriber sampleDescriber = value;

            Sim.PhysicsData defaultValues = element2.defaultValues;
            Sim.DiseaseCell invalid       = Sim.DiseaseCell.Invalid;
            for (int i = 0; i < terrainPositions.Count; i++)
            {
                if (!(terrainPositions[i].Value != targetTag))
                {
                    float           radius       = rnd.RandomRange(sampleDescriber.blobSize.min, sampleDescriber.blobSize.max);
                    Vector2         center       = Grid.CellToPos2D(terrainPositions[i].Key);
                    List <Vector2I> filledCircle = ProcGen.Util.GetFilledCircle(center, radius);
                    for (int j = 0; j < filledCircle.Count; j++)
                    {
                        Vector2I vector2I  = filledCircle[j];
                        int      x         = vector2I.x;
                        Vector2I vector2I2 = filledCircle[j];
                        int      num       = Grid.XYToCell(x, vector2I2.y);
                        if (Grid.IsValidCell(num))
                        {
                            defaultValues.mass        = GetDensityMassForCell(world, num, element2.defaultValues.mass);
                            defaultValues.temperature = temperatureMin + world.heatOffset[num] * temperatureRange;
                            SetValues(num, element2, defaultValues, invalid);
                        }
                    }
                }
            }
        }
示例#4
0
 private void ApplyForeground(WorldGenSettings settings, Chunk world, SetValuesFunction SetValues, float temperatureMin, float temperatureRange, SeededRandom rnd)
 {
     LogInfo("Apply foregreound", (node.tags != null).ToString(), (float)((node.tags != null) ? node.tags.Count : 0));
     if (node.tags != null)
     {
         FeatureSettings featureSettings = settings.TryGetFeature(node.type);
         LogInfo("\tFeature?", (featureSettings != null).ToString(), 0f);
         if (featureSettings == null && node.tags != null)
         {
             List <Tag> list = new List <Tag>();
             foreach (Tag tag2 in node.tags)
             {
                 if (settings.HasFeature(tag2.Name))
                 {
                     list.Add(tag2);
                 }
             }
             LogInfo("\tNo feature, checking possible feature tags, found", string.Empty, (float)list.Count);
             if (list.Count > 0)
             {
                 Tag tag = list[rnd.RandomSource().Next(list.Count)];
                 featureSettings = settings.GetFeature(tag.Name);
                 LogInfo("\tPicked feature", tag.Name, 0f);
             }
         }
         if (featureSettings != null)
         {
             LogInfo("APPLY FOREGROUND", node.type, 0f);
             float num  = featureSettings.blobSize.GetRandomValueWithinRange(rnd);
             float num2 = poly.DistanceToClosestEdge(null);
             if (!node.tags.Contains(WorldGenTags.AllowExceedNodeBorders) && num2 < num)
             {
                 if (debugMode)
                 {
                     Debug.LogWarning(node.type + " " + featureSettings.shape + "  blob size too large to fit in node. Size reduced. " + num + "->" + (num2 - 6f).ToString());
                 }
                 num = num2 - 6f;
             }
             if (!(num <= 0f))
             {
                 featureSpawnPoints = DigFeature(featureSettings.shape, num, featureSettings.borders, rnd, out List <Vector2I> featureCenterPoints, out List <List <Vector2I> > featureBorders);
                 LogInfo("\t\t", "claimed points", (float)featureSpawnPoints.Count);
                 availableTerrainPoints.ExceptWith(featureSpawnPoints);
                 ApplyPlaceElementForRoom(featureSettings, "RoomCenterElements", featureCenterPoints, world, SetValues, temperatureMin, temperatureRange, rnd);
                 if (featureBorders != null)
                 {
                     for (int i = 0; i < featureBorders.Count; i++)
                     {
                         ApplyPlaceElementForRoom(featureSettings, "RoomBorderChoices" + i, featureBorders[i], world, SetValues, temperatureMin, temperatureRange, rnd);
                     }
                 }
                 if (featureSettings.tags.Contains(WorldGenTags.HighPriorityFeature.Name))
                 {
                     AddHighPriorityCells(featureSpawnPoints);
                 }
             }
         }
     }
 }
示例#5
0
 public IndexModel(ILogger <IndexModel> logger, IOptions <DefaultPagingOptions> defaultPagingOptions,
                   IOptionsSnapshot <FeatureSettings> featureSettings, IOptions <ValidateSettings> validateSettings,
                   MonitorService monitorService)
 {
     _logger               = logger;
     _monitorService       = monitorService;
     _validateSettings     = validateSettings.Value;
     _featureSettings      = featureSettings.Value;
     _defaultPagingOptions = defaultPagingOptions.Value;
 }
        public void AddBotRuntimeTranscriptLogger_ErrorCases(string connectionString, string containerNAme)
        {
            IServiceCollection services      = new ServiceCollection();
            IConfiguration     configuration = new ConfigurationBuilder().Build();
            var featureSettings = new FeatureSettings()
            {
                BlobTranscript = new BlobsStorageSettings()
                {
                    ConnectionString = connectionString, ContainerName = containerNAme
                }
            };

            Assert.Throws <ArgumentNullException>(() => services.AddBotRuntimeTranscriptLogging(configuration, featureSettings));
        }
        public FeatureSettingsViewModel()
        {
            BookmarkTitle = "Enable Features";
            Settings = Context.FeatureSettings.FirstOrDefault();

            // Set some initial values if none are found.
            if (Settings == null)
            {
                Settings = new FeatureSettings()
                {
                    EventsEnabled = false
                };

                Context.FeatureSettings.Add(Settings);

                Context.SaveChanges();
            }
        }
示例#8
0
        public FeatureSettingsViewModel()
        {
            BookmarkTitle = "Enable Features";
            Settings      = Context.FeatureSettings.FirstOrDefault();

            // Set some initial values if none are found.
            if (Settings == null)
            {
                Settings = new FeatureSettings()
                {
                    EventsEnabled = false
                };

                Context.FeatureSettings.Add(Settings);

                Context.SaveChanges();
            }
        }
 protected override DeviceDetailPeriodsBase CreateNewPeriods(FeatureSettings featureSettings)
 {
     return new DeviceDetailPeriods_EnergyMeter(this, featureSettings, PeriodType.Day, TimeSpan.FromTicks(0));
 }
        public static FeatureSettings AutoSubscribe(this FeatureSettings settings, Action <AutoSubscribeSettings> customSettings)
        {
            customSettings(new AutoSubscribeSettings());

            return(settings);
        }
示例#11
0
 public WardenService(IMongoDatabase database, IStatsCalculator statsCalculator, FeatureSettings featureSettings)
 {
     _database = database;
     _statsCalculator = statsCalculator;
     _featureSettings = featureSettings;
 }
示例#12
0
 public ApiKeyService(IMongoDatabase database, IEncrypter encrypter, FeatureSettings featureSettings)
 {
     _database = database;
     _encrypter = encrypter;
     _featureSettings = featureSettings;
 }
示例#13
0
 public ApiKeyService(IMongoDatabase database, IEncrypter encrypter, FeatureSettings featureSettings)
 {
     _database        = database;
     _encrypter       = encrypter;
     _featureSettings = featureSettings;
 }
示例#14
0
        public static string GetFeatureSetting(this Affiliate affiliate, Features featureType, FeatureSettings settingType)
        {
            if (affiliate == null || affiliate.Features == null || !affiliate.Features.Any())
            {
                return(null);
            }

            var feature = affiliate.Features.FirstOrDefault(f => f.FeatureID == (int)featureType);

            if (feature == null)
            {
                return(null);
            }

            var setting = feature.Settings.FirstOrDefault(s => s.FeatureSettingID == (int)settingType);

            return(setting != null ? setting.Value : null);
        }
示例#15
0
 public OrganizationService(IMongoDatabase database, FeatureSettings featureSettings)
 {
     _database        = database;
     _featureSettings = featureSettings;
 }
示例#16
0
        public static Dictionary <int, string> PlaceFeatureAmbientMobs(WorldGenSettings settings, TerrainCell tc, SeededRandom rnd, Sim.Cell[] cells, float[] bgTemp, Sim.DiseaseCell[] dc, HashSet <int> avoidCells, bool isDebug)
        {
            Dictionary <int, string> spawnedMobs = new Dictionary <int, string>();
            Node            node = tc.node;
            HashSet <int>   alreadyOccupiedCells = new HashSet <int>();
            FeatureSettings featureSettings      = null;

            foreach (Tag featureSpecificTag in node.featureSpecificTags)
            {
                if (settings.HasFeature(featureSpecificTag.Name))
                {
                    featureSettings = settings.GetFeature(featureSpecificTag.Name);
                    break;
                }
            }
            if (featureSettings == null)
            {
                return(spawnedMobs);
            }
            if (featureSettings.internalMobs == null || featureSettings.internalMobs.Count == 0)
            {
                return(spawnedMobs);
            }
            List <int> availableSpawnCellsFeature = tc.GetAvailableSpawnCellsFeature();

            tc.LogInfo("PlaceFeatureAmbientMobs", "possibleSpawnPoints", (float)availableSpawnCellsFeature.Count);
            for (int num = availableSpawnCellsFeature.Count - 1; num > 0; num--)
            {
                int num2 = availableSpawnCellsFeature[num];
                if (ElementLoader.elements[cells[num2].elementIdx].id == SimHashes.Katairite || ElementLoader.elements[cells[num2].elementIdx].id == SimHashes.Unobtanium || avoidCells.Contains(num2))
                {
                    availableSpawnCellsFeature.RemoveAt(num);
                }
            }
            tc.LogInfo("mob spawns", "Id:" + node.node.Id + " possible cells", (float)availableSpawnCellsFeature.Count);
            if (availableSpawnCellsFeature.Count == 0)
            {
                if (isDebug)
                {
                    Debug.LogWarning("No where to put mobs possibleSpawnPoints [" + tc.node.node.Id + "]");
                }
                return(null);
            }
            foreach (MobReference internalMob in featureSettings.internalMobs)
            {
                Mob mob = settings.GetMob(internalMob.type);
                if (mob == null)
                {
                    Debug.LogError("Missing mob description for internal mob [" + internalMob.type + "]");
                }
                else
                {
                    List <int> mobPossibleSpawnPoints = GetMobPossibleSpawnPoints(mob, availableSpawnCellsFeature, cells, alreadyOccupiedCells, rnd);
                    if (mobPossibleSpawnPoints.Count == 0)
                    {
                        if (!isDebug)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        tc.LogInfo("\t\tpossible", internalMob.type + " mps: " + mobPossibleSpawnPoints.Count + " ps:", (float)availableSpawnCellsFeature.Count);
                        int num3 = Mathf.RoundToInt(internalMob.count.GetRandomValueWithinRange(rnd));
                        tc.LogInfo("\t\tcount", internalMob.type, (float)num3);
                        Tag mobPrefab = (mob.prefabName != null) ? new Tag(mob.prefabName) : new Tag(internalMob.type);
                        SpawnCountMobs(mob, mobPrefab, num3, mobPossibleSpawnPoints, tc, ref spawnedMobs, ref alreadyOccupiedCells);
                    }
                }
            }
            return(spawnedMobs);
        }