// Allow params to be a comma-delimited list of various incentives, such as item name, buff, or cvar. // <property name="AITask-5" value="ApproachAndAttackTarget" data="class=EntityNPC,0,EntityEnemyAnimal,0,EntityPlayer,0"/> <!-- class,maxChaseTime (return home) --> public override void SetData(DictionarySave <string, string> data) { base.SetData(data); string text; if (data.TryGetValue("incentives", out text)) { DisplayLog("Text: " + text); string[] array = text.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { DisplayLog("\tIncentive: " + array[i].ToString()); if (this.lstIncentives.Contains(array[i].ToString())) { continue; } this.lstIncentives.Add(array[i].ToString()); } } if (data.TryGetValue("Death", out text)) { if (text.ToLower() == "true") { DeathOnLeaderLoss = true; } } }
/// <summary> /// Saves a dictionary item /// </summary> /// <param name="dictionary"> /// The dictionary. /// </param> /// <returns> /// The <see cref="DictionaryDisplay" />. /// </returns> public ActionResult <DictionaryDisplay?> PostSave(DictionarySave dictionary) { IDictionaryItem?dictionaryItem = dictionary.Id is null ? null : _localizationService.GetDictionaryItemById(int.Parse(dictionary.Id.ToString() !, CultureInfo.InvariantCulture)); if (dictionaryItem == null) { return(ValidationProblem("Dictionary item does not exist")); } CultureInfo?userCulture = _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.GetUserCulture(_localizedTextService, _globalSettings); if (dictionary.NameIsDirty) { // if the name (key) has changed, we need to check if the new key does not exist IDictionaryItem?dictionaryByKey = _localizationService.GetDictionaryItemByKey(dictionary.Name !); if (dictionaryByKey != null && dictionaryItem.Id != dictionaryByKey.Id) { var message = _localizedTextService.Localize( "dictionaryItem", "changeKeyError", userCulture, new Dictionary <string, string?> { { "0", dictionary.Name } }); ModelState.AddModelError("Name", message); return(ValidationProblem(ModelState)); } dictionaryItem.ItemKey = dictionary.Name !; } foreach (DictionaryTranslationSave translation in dictionary.Translations) { _localizationService.AddOrUpdateDictionaryValue(dictionaryItem, _localizationService.GetLanguageById(translation.LanguageId), translation.Translation); } try { _localizationService.Save(dictionaryItem); DictionaryDisplay?model = _umbracoMapper.Map <IDictionaryItem, DictionaryDisplay>(dictionaryItem); model?.Notifications.Add(new BackOfficeNotification( _localizedTextService.Localize("speechBubbles", "dictionaryItemSaved", userCulture), string.Empty, NotificationStyle.Success)); return(model); } catch (Exception ex) { _logger.LogError(ex, "Error saving dictionary with {Name} under {ParentId}", dictionary.Name, dictionary.ParentId); return(ValidationProblem("Something went wrong saving dictionary")); } }
/// <summary> /// Saves a dictionary item /// </summary> /// <param name="dictionary"> /// The dictionary. /// </param> /// <returns> /// The <see cref="DictionaryDisplay"/>. /// </returns> public DictionaryDisplay PostSave(DictionarySave dictionary) { var dictionaryItem = Services.LocalizationService.GetDictionaryItemById(int.Parse(dictionary.Id.ToString())); if (dictionaryItem == null) { throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Dictionary item does not exist")); } var userCulture = Security.CurrentUser.GetUserCulture(Services.TextService, GlobalSettings); if (dictionary.NameIsDirty) { // if the name (key) has changed, we need to check if the new key does not exist var dictionaryByKey = Services.LocalizationService.GetDictionaryItemByKey(dictionary.Name); if (dictionaryByKey != null && dictionaryItem.Id != dictionaryByKey.Id) { var message = Services.TextService.Localize( "dictionaryItem/changeKeyError", userCulture, new Dictionary <string, string> { { "0", dictionary.Name } }); ModelState.AddModelError("Name", message); throw new HttpResponseException(Request.CreateValidationErrorResponse(ModelState)); } dictionaryItem.ItemKey = dictionary.Name; } foreach (var translation in dictionary.Translations) { Services.LocalizationService.AddOrUpdateDictionaryValue(dictionaryItem, Services.LocalizationService.GetLanguageById(translation.LanguageId), translation.Translation); } try { Services.LocalizationService.Save(dictionaryItem); var model = Mapper.Map <IDictionaryItem, DictionaryDisplay>(dictionaryItem); model.Notifications.Add(new Notification( Services.TextService.Localize("speechBubbles/dictionaryItemSaved", userCulture), string.Empty, NotificationStyle.Success)); return(model); } catch (Exception ex) { Logger.Error(GetType(), ex, "Error saving dictionary with {Name} under {ParentId}", dictionary.Name, dictionary.ParentId); throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Something went wrong saving dictionary")); } }
public override void CalcChunkColorsDone(Chunk _chunk) { DictionarySave <Vector3i, TileEntity> tileEntitiesInChunk = _chunk.GetTileEntities(); foreach (TileEntity tileEntity in tileEntitiesInChunk.Values) { RegisterTEHandlers(tileEntity); } API.Events.NotifyChunkColorsDoneHandlers(_chunk); }
public override void Process() { string output = ""; DictionarySave <string, BiomeSpawnEntityGroupList> bsc = BiomeSpawningClass.list; foreach (string biomename in bsc.Keys) { BiomeSpawnEntityGroupList bsegl = bsc[biomename]; string groupdata = ""; foreach (BiomeSpawnEntityGroupData bsegd in bsegl.list) { groupdata += "[" + "group=" + bsegd.entityGroupRefName + ",time=" + bsegd.daytime + ",max=" + bsegd.maxCount + ",delay=" + (bsegd.respawnDelayInWorldTime / 1000 / 60).ToString() + ",dead=" + bsegd.spawnDeadChance + "]" + _sep; } output += biomename + ":(" + bsegl.list.Count + ")" + groupdata + _sep; } SendOutput(output); }
public override void Process() { string output = ""; //GameManager.Instance.World.GetDynamiceSpawnManager(); DictionarySave <string, EntitySpawnerClassForDay> esc = EntitySpawnerClass.list; foreach (string name in esc.Keys) { EntitySpawnerClassForDay escfd = esc[name]; output += name + ":(" + escfd.Count() + ") [clamp=" + escfd.bClampDays + ",dynamic=" + escfd.bDynamicSpawner + ",wrap=" + escfd.bWrapDays + "]" + _sep; for (int i = 1; i < escfd.Count(); i++) { EntitySpawnerClass escday = escfd.Day(i); // todo: show groups on days } } SendOutput(output); }
// Allow params to be a comma-delimited list of various incentives, such as item name, buff, or cvar. // <property name="AITask-5" value="ApproachAndAttackTarget" data="class=EntityNPC,0,EntityEnemyAnimal,0,EntityPlayer,0"/> <!-- class,maxChaseTime (return home) --> public override void SetData(DictionarySave <string, string> data) { base.SetData(data); string text; if (data.TryGetValue("incentives", out text)) { string[] array = text.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { if (this.lstIncentives.Contains(array[i].ToString())) { continue; } this.lstIncentives.Add(array[i].ToString()); } } }