public ActionResult Index(string SearchTerms = "", int CurrentPageNumber = 1, int ItemsPerPage = 20) { ManageRoomTemplateViewModel vModel = new ManageRoomTemplateViewModel(TemplateCache.GetAll <IRoomTemplate>()) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), CurrentPageNumber = CurrentPageNumber, ItemsPerPage = ItemsPerPage, SearchTerms = SearchTerms }; return(View("~/Views/GameAdmin/Room/Index.cshtml", vModel)); }
/// <summary> /// Grabs the next Id in the chain of all objects of this type. /// </summary> internal virtual void GetNextId() { IEnumerable <IKeyedData> allOfMe = TemplateCache.GetAll().Where(bdc => bdc.GetType() == GetType()); //Zero ordered list if (allOfMe.Count() > 0) { Id = allOfMe.Max(dp => dp.Id) + 1; } else { Id = 0; } }
public AddEditGaiaViewModel(long templateId) : base(templateId) { ValidCelestials = TemplateCache.GetAll <ICelestial>(true); DataObject = new GaiaTemplate(); //apply template if (DataTemplate != null) { DataObject.CelestialBodies = DataTemplate.CelestialBodies; DataObject.ChronologicalSystem = DataTemplate.ChronologicalSystem; DataObject.Qualities = DataTemplate.Qualities; DataObject.RotationalAngle = DataTemplate.RotationalAngle; } }
public ActionResult UIModules(string SearchTerms = "", int CurrentPageNumber = 1, int ItemsPerPage = 20) { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); ManageUIModulesViewModel vModel = new ManageUIModulesViewModel(TemplateCache.GetAll <IUIModule>().Where(uimod => uimod.CreatorHandle.Equals(user.GameAccount.GlobalIdentityHandle))) { AuthedUser = user, CurrentPageNumber = CurrentPageNumber, ItemsPerPage = ItemsPerPage, SearchTerms = SearchTerms }; return(View("UIModules", vModel)); }
private void CreateAccountPlayerAndConfig(IAccount account) { AccountConfig newAccountConfig = new AccountConfig(account); IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => uim.SystemDefault > 0); foreach (IUIModule module in uiModules) { newAccountConfig.UIModules = uiModules.Select(uim => new Tuple <IUIModule, int>(uim, uim.SystemDefault)); } //Save the new config newAccountConfig.Save(account, StaffRank.Player); }
public AddEditTemplateModel(string archivePath, T item) { TemplateData fileAccessor = new TemplateData(); DataTemplate = default; ValidTemplateBases = TemplateCache.GetAll <T>(true); Archives = GetArchiveNames(fileAccessor); ArchivePath = archivePath; if (!string.IsNullOrWhiteSpace(ArchivePath)) { GetArchivedTemplate(fileAccessor, item); } }
public ActionResult Add() { AddEditZoneTemplateViewModel vModel = new AddEditZoneTemplateViewModel() { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidWorlds = TemplateCache.GetAll <IGaiaTemplate>(true), DataObject = new ZoneTemplate() }; vModel.FloraNaturalResources = TemplateCache.GetAll <IFlora>(true); vModel.FaunaNaturalResources = TemplateCache.GetAll <IFauna>(true); vModel.MineralNaturalResources = TemplateCache.GetAll <IMineral>(true); return(View("~/Views/GameAdmin/Zone/Add.cshtml", vModel)); }
public JsonResult <string[]> GetUIModuleNames(string term) { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); Data.Players.Account account = user.GameAccount; if (account == null) { return(Json(new string[0])); } IEnumerable <IUIModule> modules = TemplateCache.GetAll <IUIModule>(true).Where(uim => uim.Name.Contains(term)); return(Json(modules.Select(mod => mod.Name).ToArray())); }
public ActionResult ManageCharacters(string message) { ViewBag.StatusMessage = message; string userId = User.Identity.GetUserId(); ManageCharactersViewModel model = new ManageCharactersViewModel { AuthedUser = UserManager.FindById(userId), NewCharacter = new PlayerTemplate(), ValidGenders = TemplateCache.GetAll <IGender>() }; model.ValidRaces = TemplateCache.GetAll <IRace>(); return(View(model)); }
public ActionResult EditCharacter(long id) { string userId = User.Identity.GetUserId(); ApplicationUser user = UserManager.FindById(userId); IPlayerTemplate obj = PlayerDataCache.Get(new PlayerDataCacheKey(typeof(IPlayerTemplate), user.GlobalIdentityHandle, id)); AddEditCharacterViewModel model = new AddEditCharacterViewModel { AuthedUser = user, DataObject = obj, ValidRaces = TemplateCache.GetAll <IRace>(), ValidGenders = TemplateCache.GetAll <IGender>() }; return(View(model)); }
public ActionResult Help(string SearchTerm = "", bool IncludeInGame = true) { List <IHelp> validEntries = TemplateCache.GetAll <IHelp>(true).ToList(); ApplicationUser user = null; string searcher = SearchTerm.Trim().ToLower(); if (User.Identity.IsAuthenticated) { user = UserManager.FindById(User.Identity.GetUserId()); StaffRank userRank = user.GetStaffRank(User); } if (IncludeInGame) { //All the entities with helps IEnumerable <ILookupData> entityHelps = TemplateCache.GetAll <ILookupData>(true).Where(data => !data.ImplementsType <IHelp>()); validEntries.AddRange(entityHelps.Select(helpful => new Data.Administrative.Help() { Name = helpful.Name, HelpText = helpful.HelpText })); //All the commands Assembly commandsAssembly = Assembly.GetAssembly(typeof(CommandParameterAttribute)); IEnumerable <Type> validTargetTypes = commandsAssembly.GetTypes().Where(t => !t.IsAbstract && t.ImplementsType <IHelpful>()); foreach (Type command in validTargetTypes) { IHelpful instance = (IHelpful)Activator.CreateInstance(command); MarkdownString body = instance.HelpText; string subject = command.Name; validEntries.Add(new Data.Administrative.Help() { Name = subject, HelpText = body }); } } HelpViewModel vModel = new HelpViewModel(validEntries.Where(help => help.HelpText.ToLower().Contains(searcher) || help.Name.ToLower().Contains(searcher))) { AuthedUser = user, SearchTerm = SearchTerm, IncludeInGame = IncludeInGame }; return(View(vModel)); }
public ActionResult ApproveAll() { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IOrderedEnumerable <IKeyedData> newList = TemplateCache.GetAll().Where(item => item.GetType().GetInterfaces().Contains(typeof(INeedApproval)) && item.GetType().GetInterfaces().Contains(typeof(IKeyedData)) && !item.SuitableForUse && item.CanIBeApprovedBy(authedUser.GetStaffRank(User), authedUser.GameAccount)).OrderBy(item => item.GetType().Name); foreach (IKeyedData thing in newList) { thing.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Approved); LoggingUtility.LogAdminCommandUsage("*WEB* - Approve (all) Content[" + thing.Id + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToAction("Index", new { Message = "All have been approved." })); }
public AddEditCelestialViewModel(long templateId) : base(templateId) { ValidMaterials = TemplateCache.GetAll <IMaterial>(true); ValidModels = TemplateCache.GetAll <IDimensionalModelData>(true); DataObject = new Celestial(); //apply template if (DataTemplate != null) { DataObject.Apogee = DataTemplate.Apogee; DataObject.Perigree = DataTemplate.Apogee; DataObject.Velocity = DataTemplate.Velocity; DataObject.Luminosity = DataTemplate.Luminosity; DataObject.Model = DataTemplate.Model; DataObject.OrientationType = DataTemplate.OrientationType; } }
public Economy(IGaiaTemplate world) { Bases = new HashSet <IEconomicBasis>(); Trends = new HashSet <IEconomicTrend>(); //We'll generate a new full set economy here IEnumerable <IInanimateTemplate> items = TemplateCache.GetAll <IInanimateTemplate>(); foreach (DataStructure.Architectural.EntityBase.IQuality quality in items.SelectMany(obj => obj.Qualities)) { MakeValuation(quality.Name); } foreach (IInanimateTemplate item in items) { MakeValuation(item); } }
public ActionResult AddEditLocalePath(long id, long localeId) { ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId); if (locale == null) { return(RedirectToAction("Edit", new { Message = "Locale is invalid.", id })); } IEnumerable <IRoomTemplate> validRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => rm.ParentLocation.Equals(locale)); if (validRooms.Count() == 0) { return(RedirectToAction("Edit", new { Message = "Locale has no rooms.", id })); } IZoneTemplate origin = TemplateCache.Get <IZoneTemplate>(id); IPathwayTemplate existingPathway = origin.GetLocalePathways().FirstOrDefault(path => ((IRoomTemplate)path.Destination).ParentLocation.Equals(locale)); AddEditZonePathwayTemplateViewModel vModel = new AddEditZonePathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = validRooms, }; if (existingPathway != null) { vModel.DataObject = existingPathway; vModel.DestinationRoom = (IRoomTemplate)existingPathway.Destination; } else { vModel.DataObject = new PathwayTemplate() { Origin = origin }; } return(View("~/Views/GameAdmin/Zone/AddEditLocalePath.cshtml", vModel)); }
public ActionResult Edit(long id, AddEditUIModuleViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IUIModule obj = TemplateCache.Get <IUIModule>(id); if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", new { Message = message })); } obj.Name = vModel.Name; obj.BodyHtml = vModel.BodyHtml; obj.Height = vModel.Height; obj.Width = vModel.Width; obj.HelpText = vModel.HelpText; obj.SystemDefault = vModel.SystemDefault; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => vModel.SystemDefault > 0 && uim.SystemDefault == vModel.SystemDefault && uim != obj); if (uiModules.Count() > 0) { IUIModule revertModule = uiModules.First(); revertModule.SystemDefault = 0; revertModule.Save(authedUser.GameAccount, StaffRank.Admin); } LoggingUtility.LogAdminCommandUsage("*WEB* - EditUIModule[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("Index", new { Message = message })); }
public AddEditInanimateTemplateViewModel(long templateId) : base(templateId) { ValidMaterials = TemplateCache.GetAll <IMaterial>(); ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat); ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>(); DataObject = new InanimateTemplate(); //apply template if (DataTemplate != null) { DataObject.AccumulationCap = DataTemplate.AccumulationCap; DataObject.Components = DataTemplate.Components; DataObject.MobileContainers = DataTemplate.MobileContainers; DataObject.InanimateContainers = DataTemplate.InanimateContainers; DataObject.Qualities = DataTemplate.Qualities; DataObject.Model = DataTemplate.Model; DataObject.Produces = DataTemplate.Produces; DataObject.SkillRequirements = DataTemplate.SkillRequirements; } }
public ActionResult FightingArts(string SearchTerm = "") { List <IFightingArt> validEntries = TemplateCache.GetAll <IFightingArt>(true).ToList(); ApplicationUser user = null; string searcher = SearchTerm.Trim().ToLower(); if (User.Identity.IsAuthenticated) { user = UserManager.FindById(User.Identity.GetUserId()); StaffRank userRank = user.GetStaffRank(User); } FightingArtsViewModel vModel = new FightingArtsViewModel(validEntries.Where(help => help.Name.ToLower().Contains(searcher))) { AuthedUser = user, SearchTerm = SearchTerm }; return(View(vModel)); }
public AddEditNPCDataViewModel(long templateId) : base(templateId) { ValidItems = TemplateCache.GetAll <IInanimateTemplate>(); ValidRaces = TemplateCache.GetAll <IRace>(); ValidGenders = TemplateCache.GetAll <IGender>(); DataObject = new NonPlayerCharacterTemplate(); //apply template if (DataTemplate != null) { DataObject.Gender = DataTemplate.Gender; DataObject.InventoryRestock = DataTemplate.InventoryRestock; DataObject.Personality = DataTemplate.Personality; DataObject.Qualities = DataTemplate.Qualities; DataObject.Race = DataTemplate.Race; DataObject.TeachableProficencies = DataTemplate.TeachableProficencies; DataObject.TotalHealth = DataTemplate.TotalHealth; DataObject.TotalStamina = DataTemplate.TotalStamina; DataObject.WillPurchase = DataTemplate.WillPurchase; DataObject.WillSell = DataTemplate.WillSell; } }
/// <summary> /// Gets the opposite room from the origin based on direction /// </summary> /// <param name="origin">The room we're looking to oppose</param> /// <param name="direction">The direction the room would be in (this method will reverse the direction itself)</param> /// <returns>The room that is in the direction from our room</returns> public static IRoomTemplate GetOpposingRoom(IRoomTemplate origin, MovementDirectionType direction) { //There is no opposite of none directionals if (origin == null || direction == MovementDirectionType.None) { return(null); } MovementDirectionType oppositeDirection = ReverseDirection(direction); System.Collections.Generic.IEnumerable <IPathwayTemplate> paths = TemplateCache.GetAll <IPathwayTemplate>(); IPathwayTemplate ourPath = paths.FirstOrDefault(pt => origin.Equals(pt.Destination) && pt.DirectionType == oppositeDirection); if (ourPath != null) { return((IRoomTemplate)ourPath.Destination); } return(null); }
public AddEditFaunaViewModel(long templateId) : base(templateId) { ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>(); ValidMaterials = TemplateCache.GetAll <IMaterial>(); ValidRaces = TemplateCache.GetAll <IRace>(); DataObject = new Fauna(); //apply template if (DataTemplate != null) { DataObject.AmountMultiplier = DataTemplate.AmountMultiplier; DataObject.CanSpawnInSystemAreas = DataTemplate.CanSpawnInSystemAreas; DataObject.ElevationRange = DataTemplate.ElevationRange; DataObject.FemaleRatio = DataTemplate.FemaleRatio; DataObject.HumidityRange = DataTemplate.HumidityRange; DataObject.OccursIn = DataTemplate.OccursIn; DataObject.PopulationHardCap = DataTemplate.PopulationHardCap; DataObject.PuissanceVariance = DataTemplate.PuissanceVariance; DataObject.Rarity = DataTemplate.Rarity; DataObject.Race = DataTemplate.Race; DataObject.TemperatureRange = DataTemplate.TemperatureRange; } }
public ActionResult Add(AddEditUIModuleViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); UIModule newObj = new UIModule { Name = vModel.Name, BodyHtml = vModel.BodyHtml, Height = vModel.Height, Width = vModel.Width, HelpText = vModel.HelpText, SystemDefault = vModel.SystemDefault }; IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => vModel.SystemDefault > 0 && uim.SystemDefault == vModel.SystemDefault); if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { if (uiModules.Count() > 0) { IUIModule revertModule = uiModules.First(); revertModule.SystemDefault = 0; revertModule.Save(authedUser.GameAccount, StaffRank.Admin); } LoggingUtility.LogAdminCommandUsage("*WEB* - AddUIModule[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } return(RedirectToAction("Index", new { Message = message })); }
public ActionResult Edit(long id, long originRoomId, long destinationRoomId) { string message = string.Empty; AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>() }; PathwayTemplate obj = TemplateCache.Get <PathwayTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", "Room", new { Message = message })); } vModel.DataObject = obj; return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel)); }
public ActionResult Edit(long id) { IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); if (obj == null) { return(RedirectToAction("Index", new { Message = "That does not exist" })); } IEnumerable <ILocaleTemplate> locales = TemplateCache.GetAll <ILocaleTemplate>().Where(locale => locale.ParentLocation.Equals(obj)); AddEditZoneTemplateViewModel vModel = new AddEditZoneTemplateViewModel(locales) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, ValidWorlds = TemplateCache.GetAll <IGaiaTemplate>(true) }; vModel.FloraNaturalResources = TemplateCache.GetAll <IFlora>(true); vModel.FaunaNaturalResources = TemplateCache.GetAll <IFauna>(true); vModel.MineralNaturalResources = TemplateCache.GetAll <IMineral>(true); return(View("~/Views/GameAdmin/Zone/Edit.cshtml", vModel)); }
public AddEditMaterialViewModel(long templateId) : base(templateId) { ValidMaterials = TemplateCache.GetAll <IMaterial>(); DataObject = new Material(); //apply template if (DataTemplate != null) { DataObject.AccumulationCap = DataTemplate.AccumulationCap; DataObject.Composition = DataTemplate.Composition; DataObject.Conductive = DataTemplate.Conductive; DataObject.Density = DataTemplate.Density; DataObject.Ductility = DataTemplate.Ductility; DataObject.Flammable = DataTemplate.Flammable; DataObject.GasPoint = DataTemplate.GasPoint; DataObject.Magnetic = DataTemplate.Magnetic; DataObject.Mallebility = DataTemplate.Mallebility; DataObject.Porosity = DataTemplate.Porosity; DataObject.Resistance = DataTemplate.Resistance; DataObject.SolidPoint = DataTemplate.SolidPoint; DataObject.TemperatureRetention = DataTemplate.TemperatureRetention; DataObject.Viscosity = DataTemplate.Viscosity; } }
public ActionResult Index() { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); Account account = user.GameAccount; ManageAccountViewModel model = new ManageAccountViewModel { AuthedUser = user, DataObject = account, GlobalIdentityHandle = account.GlobalIdentityHandle, UIModuleCount = TemplateCache.GetAll <IUIModule>(true).Count(uimod => uimod.CreatorHandle.Equals(account.GlobalIdentityHandle)), NotificationCount = ConfigDataCache.GetAll <IPlayerMessage>().Count(msg => msg.RecipientAccount == account), UITutorialMode = account.Config.UITutorialMode, GossipSubscriber = account.Config.GossipSubscriber, PermanentlyMuteMusic = account.Config.MusicMuted, PermanentlyMuteSound = account.Config.SoundMuted, UILanguage = account.Config.UILanguage, ChosenRole = user.GetStaffRank(User), ValidRoles = (StaffRank[])Enum.GetValues(typeof(StaffRank)), ValidLanguages = ConfigDataCache.GetAll <ILanguage>().Where(lang => lang.SuitableForUse && lang.UIOnly) }; return(View(model)); }
/// <summary> /// Something went wrong with restoring the live backup, this loads all persistence singeltons from the database (rooms, paths, spawns) /// </summary> /// <returns>success state</returns> public bool NewWorldFallback() { LiveData liveDataAccessor = new LiveData(); //This means we delete the entire Current livedata dir since we're falling back. string currentLiveDirectory = liveDataAccessor.BaseDirectory + liveDataAccessor.CurrentDirectoryName; //No backup directory? No live data. if (Directory.Exists(currentLiveDirectory)) { DirectoryInfo currentDir = new DirectoryInfo(currentLiveDirectory); LoggingUtility.Log("Current Live directory deleted during New World Fallback Procedures.", LogChannels.Backup, true); try { currentDir.Delete(true); } catch { //occasionally will be pissy in an async situation } } //Only load in stuff that is static and spawns as singleton //We need to pick up any places that aren't already live from the file system incase someone added them during the last session\ foreach (IGaiaTemplate thing in TemplateCache.GetAll <IGaiaTemplate>()) { IGaia entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IGaia; } foreach (IZoneTemplate thing in TemplateCache.GetAll <IZoneTemplate>()) { IZone entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IZone; } foreach (ILocaleTemplate thing in TemplateCache.GetAll <ILocaleTemplate>()) { ILocale entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as ILocale; entityThing.ParentLocation = entityThing.Template <ILocaleTemplate>().ParentLocation.GetLiveInstance(); entityThing.GetFromWorldOrSpawn(); } foreach (IRoomTemplate thing in TemplateCache.GetAll <IRoomTemplate>()) { IRoom entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IRoom; entityThing.ParentLocation = entityThing.Template <IRoomTemplate>().ParentLocation.GetLiveInstance(); entityThing.GetFromWorldOrSpawn(); } foreach (IPathwayTemplate thing in TemplateCache.GetAll <IPathwayTemplate>()) { IPathway entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IPathway; } ParseDimension(); LoggingUtility.Log("World restored from data fallback.", LogChannels.Backup, true); return(true); }
/// <summary> /// Restores live entity backup from Current /// </summary> /// <returns>Success state</returns> public bool RestoreLiveBackup() { LiveData liveDataAccessor = new LiveData(); string currentBackupDirectory = liveDataAccessor.BaseDirectory + liveDataAccessor.CurrentDirectoryName; //No backup directory? No live data. if (!Directory.Exists(currentBackupDirectory)) { return(false); } LoggingUtility.Log("World restored from current live INITIATED.", LogChannels.Backup, false); try { //dont load players here List <IEntity> entitiesToLoad = new List <IEntity>(); IEnumerable <Type> implimentedTypes = typeof(EntityPartial).Assembly.GetTypes().Where(ty => ty.GetInterfaces().Contains(typeof(IEntity)) && ty.IsClass && !ty.IsAbstract && !ty.GetCustomAttributes <IgnoreAutomatedBackupAttribute>().Any()); foreach (Type type in implimentedTypes.OrderByDescending(type => type == typeof(Gaia) ? 6 : type == typeof(Zone) ? 5 : type == typeof(Locale) ? 3 : type == typeof(Room) ? 3 : type == typeof(Pathway) ? 2 : 0)) { if (!Directory.Exists(currentBackupDirectory + type.Name)) { continue; } DirectoryInfo entityFilesDirectory = new DirectoryInfo(currentBackupDirectory + type.Name); foreach (FileInfo file in entityFilesDirectory.EnumerateFiles()) { entitiesToLoad.Add(liveDataAccessor.ReadEntity(file, type)); } } //Check we found actual data if (!entitiesToLoad.Any(ent => ent.GetType() == typeof(Gaia))) { throw new Exception("No Worlds found, failover."); } if (!entitiesToLoad.Any(ent => ent.GetType() == typeof(Zone))) { throw new Exception("No zones found, failover."); } //Shove them all into the live system first foreach (IEntity entity in entitiesToLoad.OrderBy(ent => ent.Birthdate)) { entity.UpsertToLiveWorldCache(); entity.KickoffProcesses(); } //We need to pick up any places that aren't already live from the file system incase someone added them during the last session\ foreach (IGaiaTemplate thing in TemplateCache.GetAll <IGaiaTemplate>().Where(dt => !entitiesToLoad.Any(ent => ent.TemplateId.Equals(dt.Id) && ent.Birthdate >= dt.LastRevised))) { IGaia entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IGaia; entityThing.SpawnNewInWorld(); } foreach (IZoneTemplate thing in TemplateCache.GetAll <IZoneTemplate>().Where(dt => !entitiesToLoad.Any(ent => ent.TemplateId.Equals(dt.Id) && ent.Birthdate >= dt.LastRevised))) { IZone entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IZone; entityThing.SpawnNewInWorld(); } foreach (ILocaleTemplate thing in TemplateCache.GetAll <ILocaleTemplate>().Where(dt => !entitiesToLoad.Any(ent => ent.TemplateId.Equals(dt.Id) && ent.Birthdate >= dt.LastRevised))) { ILocale entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as ILocale; entityThing.ParentLocation = entityThing.ParentLocation.GetLiveInstance(); entityThing.SpawnNewInWorld(); } foreach (IRoomTemplate thing in TemplateCache.GetAll <IRoomTemplate>().Where(dt => !entitiesToLoad.Any(ent => ent.TemplateId.Equals(dt.Id) && ent.Birthdate >= dt.LastRevised))) { IRoom entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IRoom; entityThing.ParentLocation = entityThing.Template <IRoomTemplate>().ParentLocation.GetLiveInstance(); entityThing.SpawnNewInWorld(); } foreach (IPathwayTemplate thing in TemplateCache.GetAll <IPathwayTemplate>().Where(dt => !entitiesToLoad.Any(ent => ent.TemplateId.Equals(dt.Id) && ent.Birthdate >= dt.LastRevised))) { IPathway entityThing = Activator.CreateInstance(thing.EntityClass, new object[] { thing }) as IPathway; entityThing.SpawnNewInWorld(); } //We have the containers contents and the birthmarks from the deserial //I don't know how we can even begin to do this type agnostically since the collections are held on type specific objects without some super ugly reflection foreach (Room entity in entitiesToLoad.Where(ent => ent.GetType() == typeof(Room))) { foreach (IInanimate obj in entity.Contents.EntitiesContained()) { IInanimate fullObj = LiveCache.Get <IInanimate>(new LiveCacheKey(obj)); entity.MoveFrom(obj); entity.MoveInto(fullObj); } foreach (INonPlayerCharacter obj in entity.MobilesInside.EntitiesContained()) { INonPlayerCharacter fullObj = LiveCache.Get <INonPlayerCharacter>(new LiveCacheKey(obj)); entity.MoveFrom(obj); entity.MoveInto(fullObj); } } foreach (NonPlayerCharacter entity in entitiesToLoad.Where(ent => ent.GetType() == typeof(NonPlayerCharacter))) { foreach (IInanimate obj in entity.Inventory.EntitiesContained()) { IInanimate fullObj = LiveCache.Get <IInanimate>(new LiveCacheKey(obj)); entity.MoveFrom(obj); entity.MoveInto(fullObj); } } foreach (Inanimate entity in entitiesToLoad.Where(ent => ent.GetType() == typeof(Inanimate))) { foreach (Tuple <string, IInanimate> obj in entity.Contents.EntitiesContainedByName()) { IInanimate fullObj = LiveCache.Get <IInanimate>(new LiveCacheKey(obj.Item2)); entity.MoveFrom(obj.Item2); entity.MoveInto(fullObj, obj.Item1); } foreach (Tuple <string, IInanimate> obj in entity.Contents.EntitiesContainedByName()) { INonPlayerCharacter fullObj = LiveCache.Get <INonPlayerCharacter>(new LiveCacheKey(obj.Item2)); entity.MoveFrom((INonPlayerCharacter)obj.Item2); entity.MoveInto(fullObj, obj.Item1); } } //We need to poll the WorldMaps here and give all the rooms their coordinates as well as the zones their sub-maps ParseDimension(); LoggingUtility.Log("World restored from current live.", LogChannels.Backup, false); return(true); } catch (Exception ex) { LoggingUtility.LogError(ex); } return(false); }
//Also called Dashboard in most of the html public ActionResult Index() { IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld)); IGossipConfig gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld)); DashboardViewModel dashboardModel = new DashboardViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), Inanimates = TemplateCache.GetAll <IInanimateTemplate>(), NPCs = TemplateCache.GetAll <INonPlayerCharacterTemplate>(), Zones = TemplateCache.GetAll <IZoneTemplate>(), Worlds = TemplateCache.GetAll <IGaiaTemplate>(), Locales = TemplateCache.GetAll <ILocaleTemplate>(), Rooms = TemplateCache.GetAll <IRoomTemplate>(), HelpFiles = TemplateCache.GetAll <IHelp>(), Races = TemplateCache.GetAll <IRace>(), Celestials = TemplateCache.GetAll <ICelestial>(), Journals = TemplateCache.GetAll <IJournalEntry>(), DimensionalModels = TemplateCache.GetAll <IDimensionalModelData>(), Flora = TemplateCache.GetAll <IFlora>(), Fauna = TemplateCache.GetAll <IFauna>(), Minerals = TemplateCache.GetAll <IMineral>(), Materials = TemplateCache.GetAll <IMaterial>(), DictionaryWords = ConfigDataCache.GetAll <ILexeme>(), Languages = ConfigDataCache.GetAll <ILanguage>(), Genders = TemplateCache.GetAll <IGender>(), UIModules = ConfigDataCache.GetAll <IUIModule>(), FightingArts = TemplateCache.GetAll <IFightingArt>(), LiveTaskTokens = Processor.GetAllLiveTaskStatusTokens(), LivePlayers = LiveCache.GetAll <IPlayer>().Count(), LiveInanimates = LiveCache.GetAll <IInanimate>().Count(), LiveNPCs = LiveCache.GetAll <INonPlayerCharacter>().Count(), LiveZones = LiveCache.GetAll <IZone>().Count(), LiveWorlds = LiveCache.GetAll <IGaia>().Count(), LiveLocales = LiveCache.GetAll <ILocale>().Count(), LiveRooms = LiveCache.GetAll <IRoom>().Count(), ConfigDataObject = globalConfig, WebsocketPortalActive = globalConfig.WebsocketPortalActive, AdminsOnly = globalConfig.AdminsOnly, UserCreationActive = globalConfig.UserCreationActive, BaseLanguage = globalConfig.BaseLanguage, AzureTranslationKey = globalConfig.AzureTranslationKey, TranslationActive = globalConfig.TranslationActive, DeepLexActive = globalConfig.DeepLexActive, MirriamDictionaryKey = globalConfig.MirriamDictionaryKey, MirriamThesaurusKey = globalConfig.MirriamThesaurusKey, QualityChange = new string[0], QualityChangeValue = new int[0], ValidZones = TemplateCache.GetAll <IZoneTemplate>(true), ValidLanguages = ConfigDataCache.GetAll <ILanguage>(), GossipConfigDataObject = gossipConfig, GossipActive = gossipConfig.GossipActive, ClientId = gossipConfig.ClientId, ClientSecret = gossipConfig.ClientSecret, ClientName = gossipConfig.ClientName, SuspendMultiplier = gossipConfig.SuspendMultiplier, SuspendMultiplierMaximum = gossipConfig.SuspendMultiplierMaximum, SupportedChannels = gossipConfig.SupportedChannels, SupportedFeatures = gossipConfig.SupportedFeatures }; return(View(dashboardModel)); }
/// <summary> /// Executes this command /// </summary> public override void Execute() { List <string> sb = new List <string>(); if (!(Actor is IContains actorContainer)) { RenderError("You can't craft if you don't have an inventory."); return; } //We're after a list, not the actual command here if (Subject != null) { IEnumerable <IInanimateTemplate> itemsToMake = TemplateCache.GetAll <IInanimateTemplate>().Where(item => item.Produces > 0 && item.Components.Count() > 0); //Just a full list of all the things we can make then if (Target == null) { foreach (IInanimateTemplate item in itemsToMake) { IEnumerable <IInanimate> myItems = actorContainer.GetContents <IInanimate>(); if (item.Components.Any(component => myItems.Any(myItem => myItem.TemplateId == component.Item.Id))) { sb.Add(item.RenderBlueprints(Actor)); } } } else { //A list of everything that matches keyword string keyword = Target.ToString(); foreach (IInanimateTemplate item in itemsToMake.Where(itm => itm.Name.Contains(keyword))) { sb.Add(item.RenderBlueprints(Actor)); } } ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); Message messagingObject = new Message(toActor); messagingObject.ExecuteMessaging(Actor, null, null, null, null); return; } IInanimateTemplate itemToMake = (IInanimateTemplate)Target; string errorCrafting = itemToMake.Craft(Actor); if (!string.IsNullOrWhiteSpace(errorCrafting)) { RenderError(errorCrafting); } else { sb.Add(string.Format("You craft {0} {1}{2}.", itemToMake.Produces, itemToMake.Name, itemToMake.Produces > 1 ? "s" : "")); ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph(string.Format("$A$ crafts {0} {1}{2}.", itemToMake.Produces, itemToMake.Name, itemToMake.Produces > 1 ? "s" : "")); Message messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin } }; messagingObject.ExecuteMessaging(Actor, null, null, OriginLocation.CurrentZone, null); Actor.Save(); } return; }