public void report_samurai_secret_status() { var dataAccess = new DataAccess(); var hasse = new Samurai { Name = "Hasse", SecretIdentity = new SecretIdentity { RealName = "Hans" } }; dataAccess.Add(hasse); var ishida = new Samurai { Name = "Ishida", }; dataAccess.Add(ishida); dataAccess.ClearContext(); Assert.AreEqual("Hasse's real name is Hans", dataAccess.ReportSecretIdentityStatus("Hasse")); Assert.AreEqual("Ishida don't have a secret identity", dataAccess.ReportSecretIdentityStatus("Ishida")); Assert.AreEqual("Samurai Sven doesn't exist", dataAccess.ReportSecretIdentityStatus("Sven")); }
public void report_samurais_names_with_their_haircut() { var dataAccess = new DataAccess(); dataAccess.Add(new Samurai { Name = "Enomoto", HairStyle = HairStyle.Oicho }); dataAccess.Add(new Samurai { Name = "Hattori", HairStyle = HairStyle.Western }); dataAccess.Add(new Samurai { Name = "Ishida", HairStyle = HairStyle.Chonmage }); string[] result = dataAccess.ReportNamesWithHaircuts(); CollectionAssert.AreEqual(new[] { "Enomoto has haircut oicho", "Hattori has haircut western", "Ishida has haircut chonmage", }, result); }
private async void MapPinElementMapPinTapped(object sender, MapPinTappedEventArgs e) { MapPin mapPinElement = (MapPin)sender; if (mapPinElement.Focused) { if (e.Marked) { await _mapLocationAccess.Add( DataSourceType.Sqlite, new MapLocationModel { ID = Guid.NewGuid(), Name = mapPinElement.Name, Description = mapPinElement.Description, Latitude = mapPinElement.Latitude.ToString(), Longitude = mapPinElement.Longitude.ToString(), MapId = _map.ID }); MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location => location.Latitude == mapPinElement.Latitude.ToString() && location.Longitude == location.Longitude); if (addedLocation != null) { mapPinElement.ID = addedLocation.ID; } _mapPins.Add(mapPinElement); } else { MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location => location.ID.Equals(mapPinElement.ID)); if (deleteLocation != null) { await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation); } _mapPins.Remove(mapPinElement); } } _lastFocusedMapPin = _focusedMapPin; _focusedMapPin = mapPinElement; if (_lastFocusedMapPin != null) { _lastFocusedMapPin.UnFocus(); } if (!_focusedMapPin.Focused) { _focusedMapPin.Focus(); } }
public void report_quotes_of_certain_type() { var dataAccess = new DataAccess(); dataAccess.Add(new Samurai { Name = "Enomoto", Quotes = new List <Quote> { new Quote { Style = QuoteStyle.Lame, Text = "Life is what happens to you while you're busy making other plans." }, new Quote { Style = QuoteStyle.Lame, Text = "Live, laugh, love." } } }); dataAccess.Add(new Samurai { Name = "Hattori", Quotes = new List <Quote> { new Quote { Style = QuoteStyle.Lame, Text = "Everything happens for a reason." }, new Quote { Style = QuoteStyle.Awesome, Text = "Even if you fall on your face, you’re still moving forward." } } }); string[] result = dataAccess.ReportQuotesOfType(QuoteStyle.Lame); CollectionAssert.AreEqual(new[] { "Enomoto has 2 lame quotes", "Hattori has 1 lame quote" }, result); string[] result2 = dataAccess.ReportQuotesOfType(QuoteStyle.Awesome); CollectionAssert.AreEqual(new[] { "Enomoto has no awesome quotes", "Hattori has 1 awesome quote" }, result2); }
/// <summary> /// Creates a new area and adds it to the Prototype cache /// </summary> /// <param name="parentID">The parent ID of the world to add this area to.</param> /// <returns>The new prototype room</returns> public static Area NewPrototype(uint parentID) { var newArea = new Area(); newArea.Rooms.CacheType = CacheType.Prototype; newArea.AutogeneratedPrototypeItems.CacheType = CacheType.Prototype; newArea.AutogeneratedPrototypeMobs.CacheType = CacheType.Prototype; var world = DataAccess.Get <World>(parentID, CacheType.Prototype); if (world == null) { throw new LocaleException($"Failed to locate parent ID ({parentID}) when generating new area protoype."); } DataAccess.Add <Area>(newArea, CacheType.Prototype); newArea.Rooms.PrototypeParents.Add((uint)newArea.Prototype); newArea.AutogeneratedPrototypeItems.PrototypeParents.Add((uint)newArea.Prototype); newArea.AutogeneratedPrototypeMobs.PrototypeParents.Add((uint)newArea.Prototype); DataAccess.Add <EntityContainer>(newArea.Rooms, CacheType.Prototype); DataAccess.Add <EntityContainer>(newArea.AutogeneratedPrototypeItems, CacheType.Prototype); DataAccess.Add <EntityContainer>(newArea.AutogeneratedPrototypeMobs, CacheType.Prototype); world.Areas.AddEntity(newArea.Prototype, newArea, true); DataPersistence.SaveObject(newArea); return(newArea); }
public void investigate_difference_between_find_and_where() { /* * Just add a samurai and remember his id */ var dataAccess = new DataAccess(); var ashimoto = new Samurai { Name = "Ashimoto" }; dataAccess.Add(ashimoto); int ashimotoId = ashimoto.Id; /* * If find is called multiple times with the same id => no extra call is made to the database (good for performace!) */ dataAccess = new DataAccess(); var context = dataAccess.GetContextForUnitTests; dataAccess.ClearContext(); context = dataAccess.GetContextForUnitTests; // Find var samurai = context.Samurais.Find(ashimotoId); // Find once more var samuraiAgain = context.Samurais.Find(ashimotoId); // Where var samuraisWhere = context.Samurais.Where(s => s.Id == ashimotoId).FirstOrDefault(); // Where once more var samuraisWhereAgain = context.Samurais.Where(s => s.Id == ashimotoId).FirstOrDefault(); }
/// <summary> /// Handles death for the entity. Does not remove from cache. /// </summary> protected virtual void HandleDeath(object source, CacheObjectEventArgs args) { if (args.ID == Instance) { // TODO: Handle soulbound items for players var newCorpse = new Storage { Name = "corpse " + Name, ShortDescription = $"{ShortDescription}'s corpse.", LongDescription = $"{ShortDescription}'s corpse.", }; newCorpse.Tier.Level = Tier.Level; DataAccess.Add <Storage>(newCorpse, CacheType.Instance); foreach (var invItem in GetInventoryItems().Concat(GetEquippedItems())) { newCorpse.AddEntity(invItem.Instance, invItem); } _inventory.RemoveAllEntities(); _equipment.RemoveAllEntities(); GetInstanceParentRoom()?.StorageItems.AddEntity(newCorpse.Instance, newCorpse, false); } else { // TODO: Does HandleDeath need to allow for situations where the entity itself isn't the one dying? } }
/// <summary> /// Creates a new room and adds it to the Prototype cache /// </summary> /// <param name="parentID">The parent ID of the area to add this room to.</param> /// <returns>The new prototype room</returns> public static Room NewPrototype(uint parentID) { var newRoom = new Room(); newRoom.Animates.CacheType = CacheType.Prototype; newRoom.Items.CacheType = CacheType.Prototype; newRoom.ShopItems.CacheType = CacheType.Prototype; newRoom.StorageItems.CacheType = CacheType.Prototype; var area = DataAccess.Get <Area>(parentID, CacheType.Prototype); if (area == null) { throw new LocaleException($"Failed to locate parent ID ({parentID}) when generating new room protoype."); } DataAccess.Add <Room>(newRoom, CacheType.Prototype); newRoom.Animates.PrototypeParents.Add((uint)newRoom.Prototype); newRoom.Items.PrototypeParents.Add((uint)newRoom.Prototype); newRoom.ShopItems.PrototypeParents.Add((uint)newRoom.Prototype); newRoom.StorageItems.PrototypeParents.Add((uint)newRoom.Prototype); DataAccess.Add <EntityContainer>(newRoom.Animates, CacheType.Prototype); DataAccess.Add <EntityContainer>(newRoom.Items, CacheType.Prototype); DataAccess.Add <EntityContainer>(newRoom.ShopItems, CacheType.Prototype); DataAccess.Add <EntityContainer>(newRoom.StorageItems, CacheType.Prototype); area.Rooms.AddEntity(newRoom.Prototype, newRoom, true); DataPersistence.SaveObject(newRoom); return(newRoom); }
public static void AddEntityToDb <T>(T entity) { var db = new DataAccess(); db.Add(entity); db.SaveChanges(); }
/// <summary> /// Creates a new static item and adds it to the Prototype cache /// </summary> /// <returns>The new prototype item</returns> public static ItemStatic NewPrototype() { var newItem = new ItemStatic(); DataAccess.Add <ItemStatic>(newItem, CacheType.Prototype); return(newItem); }
/// <summary> /// Spawns an instance of the object from prototype and adds it to the cache. /// </summary> /// <param name="withEntities">Whether to also spawn contained entities.</param> /// <param name="parent">The Instance ID of the parent.</param> /// <returns>The instance ID of the spawned inventory. Will return null if the method is called from an instanced object.</returns> /// <remarks>Parent is ignored because it cannot be determined which parent property needs to be set. Inventory must therefore be manually set /// after spawning.</remarks> public override uint?Spawn(bool withEntities, uint parent) { if (CacheType != CacheType.Prototype) { return(null); } Logger.Info(nameof(EntityContainer), nameof(Spawn), "Spawning container: " + ": ProtoID=" + Prototype.ToString()); var newContainer = new EntityContainer { Prototype = Prototype }; newContainer.InstanceParent = parent; DataAccess.Add <EntityContainer>(newContainer, CacheType.Instance); if (withEntities) { var entitiesToLoad = DataAccess.GetMany <ISpawnableObject>(_entityList, CacheType); foreach (var entity in entitiesToLoad) { entity.Spawn(withEntities, (uint)newContainer.Instance); } } Logger.Info(nameof(EntityContainer), nameof(Spawn), "Finished spawning container."); return(newContainer.Instance); }
/// <summary> /// Creates a new potion and adds it to the Prototype cache /// </summary> /// <returns>The new prototype item</returns> public static ItemPotion NewPrototype() { var newItem = new ItemPotion(); DataAccess.Add <ItemPotion>(newItem, CacheType.Prototype); return(newItem); }
public void add_one_samurai_with_a_lot_of_data() { var dataAccess = new DataAccess(); var samurai = new Samurai { Name = "Kalle", Quotes = new List <Quote> { new Quote { Text = "Some awesome quote by Kalle", Style = QuoteStyle.Awesome }, new Quote { Text = "Some cheesy quote by Kalle", Style = QuoteStyle.Cheesy }, new Quote { Text = "Another cheesy quote by Kalle", Style = QuoteStyle.Cheesy } }, SecretIdentity = new SecretIdentity { RealName = "Karl" }, SamuraiBattles = new List <SamuraiBattle> { new SamuraiBattle { Battle = A.Battle1 }, new SamuraiBattle { Battle = A.Battle2 } }, HairStyle = HairStyle.Chonmage }; dataAccess.Add(samurai); dataAccess.ClearContext(); var sam = dataAccess.FindByName("Kalle"); Assert.AreEqual("Kalle", sam.Name); Assert.AreEqual(3, sam.Quotes.Count); Assert.AreEqual(2, sam.Quotes.Count(x => x.Style == QuoteStyle.Cheesy)); Assert.AreEqual("Karl", sam.SecretIdentity.RealName); Assert.AreEqual(HairStyle.Chonmage, sam.HairStyle); Assert.AreEqual(2, sam.SamuraiBattles.Count); Assert.AreEqual(3, sam.SamuraiBattles .Select(x => x.Battle) .Single(x => x.Name == "Battle1") .BattleLog .BattleEvents .Count); Assert.AreEqual(2, sam.SamuraiBattles .Select(x => x.Battle) .Single(x => x.Name == "Battle2") .BattleLog .BattleEvents .Count); }
public void raw_sql_combined_with_linq() { var dataAccess = new DataAccess(); dataAccess.Add( new Samurai { Name = "Enomoto", Quotes = new List <Quote> { new Quote(), new Quote(), new Quote() }, }, new Samurai { Name = "Hattori", Quotes = new List <Quote> { new Quote(), new Quote(), new Quote(), new Quote() }, }, new Samurai { Name = "Ishida", Quotes = new List <Quote> { new Quote() }, }, new Samurai { Name = "Pi", Quotes = new List <Quote> { new Quote(), new Quote(), new Quote() }, } ); // This sql will just filter out samurai "Pi" string sql = "select * from Samurais where Len(Name)>2"; { int minNrOfQuotes = 3; var result = dataAccess.FindSamuraisWithManyQuotes(sql, minNrOfQuotes); CollectionAssert.AreEqual(new[] { "Enomoto", "Hattori" }, A.GetSamuraiNames(result)); } { int minNrOfQuotes = 4; var result = dataAccess.FindSamuraisWithManyQuotes(sql, minNrOfQuotes); CollectionAssert.AreEqual(new[] { "Hattori", }, A.GetSamuraiNames(result)); } }
public async Task <IActionResult> Create(User user, IFormCollection form) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("UserId,UserFName,UserLName,UserEmail")] Enduser enduser) { if (ModelState.IsValid) { _context.Add(enduser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(enduser)); }
public void raw_sql() { var dataAccess = new DataAccess(); { dataAccess.Add(new Samurai { Name = "Ashimoto", }, new Samurai { Name = "Ishida", }); // Update names where the second char is a "s" int affectedRows = dataAccess.UpdateSamuraiNameToHattoriFilterByParameter("_s%"); Assert.AreEqual(2, affectedRows); string[] result = dataAccess.FindAllNames(); CollectionAssert.AreEqual(new[] { "HATTORI", "HATTORI" }, result); } dataAccess.ClearDatabase(); dataAccess.ClearContext(); { dataAccess.Add(new Samurai { Name = "Ashimoto", }, new Samurai { Name = "Ishida", }); // Update names which ends with "ida" int affectedRows = dataAccess.UpdateSamuraiNameToHattoriFilterByParameter("%ida"); Assert.AreEqual(1, affectedRows); string[] result = dataAccess.FindAllNames(); CollectionAssert.AreEqual(new[] { "Ashimoto", "HATTORI" }, result); } }
public async Task <IActionResult> Create([Bind("PasswordId,UserId,PasswordOld,PasswordNew,PasswordDateChanged")] Userpassword userpassword) { if (ModelState.IsValid) { _context.Add(userpassword); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.Endusers, "UserId", "UserEmail", userpassword.UserId); return(View(userpassword)); }
public async Task <IActionResult> Create([Bind("SessionId,UserId,SessionDate,SessionStatus,SessionToken")] Usersession usersession) { if (ModelState.IsValid) { _context.Add(usersession); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.Endusers, "UserId", "UserEmail", usersession.UserId); return(View(usersession)); }
/// <summary> /// Creates a new world and adds it to the Prototype cache /// </summary> /// <returns>The new prototype world</returns> public static World NewPrototype() { var newWorld = new World(); newWorld.Areas.CacheType = CacheType.Prototype; DataAccess.Add <World>(newWorld, CacheType.Prototype); newWorld.Areas.PrototypeParents.Add((uint)newWorld.Prototype); DataAccess.Add <EntityContainer>(newWorld.Areas, CacheType.Prototype); DataPersistence.SaveObject(newWorld); return(newWorld); }
private async void UpdateMapFolderList(Guid mapLocationId) { _mapLocationFolderAccess.MapLocationId = mapLocationId; _mapLocationFolders = await _mapLocationFolderAccess.GetSources(DataSourceType.Sqlite); DefaultViewModel["MapLocationFolders"] = _mapLocationFolders; List <MapLocationFolderModel> removedFoders = new List <MapLocationFolderModel>(); foreach (MapLocationFolderModel removedFolder in _mapLocationFolders) { StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(removedFolder.Token, AccessCacheOptions.FastLocationsOnly); if (folder == null || !DataSource.SelectedStorageFolders.Any(storageFolder => storageFolder.EqualTo(folder))) { removedFoders.Add(removedFolder); } } await _mapLocationFolderAccess.RemoveMany(DataSourceType.Sqlite, removedFoders); foreach (StorageFolder folder in DataSource.SelectedStorageFolders) { string token = StorageApplicationPermissions.FutureAccessList.Add(folder, "link"); if (!_mapLocationFolders.Any(locationFolder => locationFolder.Token.Equals(token))) { MapLocationFolderModel locationFolder = new MapLocationFolderModel { ID = Guid.NewGuid(), Name = folder.Name, Description = folder.DateCreated.ToString(), MapLocationId = mapLocationId, Token = token }; await _mapLocationFolderAccess.Add(DataSourceType.Sqlite, locationFolder); } } }
public void report_battles_for_samurai() { var dataAccess = new DataAccess(); dataAccess.Add( new Samurai { Name = "Hattori", SamuraiBattles = new List <SamuraiBattle> { new SamuraiBattle { Battle = A.Battle1 }, new SamuraiBattle { Battle = A.Battle2 } }, }, new Samurai { Name = "Ishida", SamuraiBattles = new List <SamuraiBattle> { new SamuraiBattle { Battle = A.Battle2 } }, }); { string[] result = dataAccess.ReportBattlesForSamurai("Hattori"); CollectionAssert.AreEqual(new[] { "Battle 1 with startdate 1710-02-03", "Battle 2 with startdate 1805-05-06", }, result); } { string[] result = dataAccess.ReportBattlesForSamurai("Ishida"); CollectionAssert.AreEqual(new[] { "Battle 2 with startdate 1805-05-06", }, result); } { string[] result = dataAccess.ReportBattlesForSamurai("Sverker"); CollectionAssert.AreEqual(new string[] { }, result); } }
/// <summary> /// Creates a new potion and adds it to the Instance cache /// </summary> /// <param name="withPrototype">Whether to also create a backing prototype.</param> /// <returns>The new instanced item</returns> public static ItemPotion NewInstance(bool withPrototype) { ItemPotion newItem = new ItemPotion(); if (withPrototype) { var newProto = NewPrototype(); newItem.Prototype = newProto.Prototype; } DataAccess.Add <ItemPotion>(newItem, CacheType.Instance); return(newItem); }
public int AddNewTask(TaskRequest request) { var task = new TaskEntity() { ParentTask = request.ParentTaskId == null ? "" : request.ParentTaskId, TaskName = request.TaskName, Priority = request.Priority, StartDate = request.StartDate == DateTime.MinValue ? DateTime.Now : request.StartDate, EndDate = request.EndDate == DateTime.MinValue ? DateTime.Now : request.EndDate, Status = "Open" }; return(dbAccess.Add(task)); }
public void report_real_name_of_samurai() { var dataAccess = new DataAccess(); dataAccess.Add(new Samurai { Name = "Ishida", SecretIdentity = new SecretIdentity { RealName = "Igor" } }); dataAccess.Add(new Samurai { Name = "Enomoto", SecretIdentity = new SecretIdentity { RealName = "Emelie" } }); dataAccess.Add(new Samurai { Name = "Hattori", SecretIdentity = new SecretIdentity { RealName = "Hans" } }); string[] result = new DataAccess().ReportRealNameOfSamurai(); CollectionAssert.AreEqual(new[] { "Ishida's real name is IGOR", "Enomoto's real name is EMELIE", "Hattori's real name is HANS", }, result); }
/// <summary> /// Creates a new world and adds it to the Instance cache /// </summary> /// <param name="withPrototype">Whether to also create a backing prototype</param> /// <returns>The new instanced world</returns> public static World NewInstance(bool withPrototype) { World newWorld; if (withPrototype) { newWorld = DataAccess.Get <World>(NewPrototype().Spawn(false, 0), CacheType.Instance); } else { newWorld = DataAccess.Get <World>(DataAccess.Add <World>(new World(), CacheType.Instance), CacheType.Instance); DataAccess.Add <EntityContainer>(newWorld.Areas, CacheType.Instance); } newWorld.Areas.InstanceParent = newWorld.Instance; return(newWorld); }
public void report_samurai_info() { var dataAccess = new DataAccess(); dataAccess.Add(new Samurai { Name = "Ishida", SecretIdentity = new SecretIdentity { RealName = "Igor" }, SamuraiBattles = new List <SamuraiBattle> { new SamuraiBattle { Battle = A.Battle1 }, new SamuraiBattle { Battle = A.Battle2 }, } }, new Samurai { Name = "Enomoto", SecretIdentity = new SecretIdentity { RealName = "Emelie" }, SamuraiBattles = new List <SamuraiBattle> { new SamuraiBattle { Battle = A.Battle2 }, } }); SamuraiInfo[] result = new DataAccess().ReportSamuraiInfo(); Assert.AreEqual(2, result.Length); Assert.AreEqual("Ishida", result[0].Name); Assert.AreEqual("Igor", result[0].RealName); Assert.AreEqual("Battle 1,Battle 2", result[0].BattleNames); Assert.AreEqual("Enomoto", result[1].Name); Assert.AreEqual("Emelie", result[1].RealName); Assert.AreEqual("Battle 2", result[1].BattleNames); }
public void update_name_of_samurai() { var sven = new Samurai { Name = "Sven", }; var dataAccess = new DataAccess(); dataAccess.Add(sven); dataAccess.ClearContext(); dataAccess.UpdateSamuraiName("Sven", "Minamoto"); dataAccess.ClearContext(); var result = dataAccess.FindByName("Minamoto"); Assert.AreEqual("Minamoto", result.Name); }
/// <summary> /// Spawns an instance of the area from prototype and adds it to the cache. /// </summary> /// <param name="withEntities">Whether to also spawn contained rooms.</param> /// <param name="parent">The parent instance ID</param> /// <returns>The instance ID of the spawned area. Will return null if the method is called from an instanced object.</returns> /// <remarks>Does not fix spawned instance rooms' exits.</remarks> public override uint?Spawn(bool withEntities, uint parent) { if (CacheType != CacheType.Prototype) { return(null); } var parentContainer = DataAccess.Get <EntityContainer>(parent, CacheType.Instance); var parentWorld = DataAccess.Get <World>(parentContainer.InstanceParent, CacheType.Instance); if (parentContainer == null || parentWorld == null) { throw new LocaleException("Parent cannot be null when spawning an area."); } // Create new instance area and add to parent container var newArea = DataAccess.Get <Area>(DataAccess.Add <Area>(new Area(), CacheType.Instance), CacheType.Instance); parentWorld.Areas.AddEntity(newArea.Instance, newArea, false); Logger.Info(nameof(Area), nameof(Spawn), "Spawning area: " + Name + ": ProtoID=" + Prototype.ToString()); // Set remaining properties newArea.Prototype = Prototype; CopyTo(newArea); // Spawn contained entities if (withEntities) { newArea.Rooms = Rooms.SpawnAsObject <EntityContainer>(!withEntities, (uint)newArea.Instance); foreach (var room in Rooms.GetAllEntitiesAsObjects <Room>()) { room.Spawn(withEntities, (uint)newArea.Rooms.Instance); } } else { newArea.Rooms = Rooms.SpawnAsObject <EntityContainer>(!withEntities, (uint)newArea.Instance); } Logger.Info(nameof(Area), nameof(Spawn), "Finished spawning area."); return(newArea.Instance); }
/// <summary> /// Creates a new room and adds it to the Instance cache /// </summary> /// <param name="withPrototype">Whether to also create a backing prototype. If so, the Prototype Area will also have the /// prototype room added.</param> /// <param name="parentID">The parent area Instance ID.</param> /// <returns>The new instanced room</returns> public static Room NewInstance(bool withPrototype, uint parentID) { Room newRoom; if (withPrototype) { var instanceArea = DataAccess.Get <Area>(parentID, CacheType.Instance); if (instanceArea == null) { throw new LocaleException($"{nameof(Room)}.{nameof(NewInstance)}: parentID retrieved null instance area."); } var protoArea = DataAccess.Get <Area>(instanceArea.Prototype, CacheType.Prototype); if (protoArea == null) { throw new LocaleException($"{nameof(Room)}.{nameof(NewInstance)}: parentID retrieved null prototype area."); } newRoom = DataAccess.Get <Room>(NewPrototype((uint)protoArea.Prototype).Spawn(false, parentID), CacheType.Instance); } else { var area = DataAccess.Get <Area>(parentID, CacheType.Instance); if (area == null) { throw new LocaleException($"{nameof(Room)}.{nameof(NewInstance)}: parentID retrieved null instance area."); } newRoom = DataAccess.Get <Room>(DataAccess.Add <Room>(new Room(), CacheType.Instance), CacheType.Instance); DataAccess.Add <EntityContainer>(newRoom.Animates, CacheType.Instance); DataAccess.Add <EntityContainer>(newRoom.Items, CacheType.Instance); DataAccess.Add <EntityContainer>(newRoom.ShopItems, CacheType.Instance); DataAccess.Add <EntityContainer>(newRoom.StorageItems, CacheType.Instance); area.Rooms.AddEntity(newRoom.Instance, newRoom, false); } newRoom.Animates.InstanceParent = newRoom.Instance; newRoom.Items.InstanceParent = newRoom.Instance; newRoom.ShopItems.InstanceParent = newRoom.Instance; newRoom.StorageItems.InstanceParent = newRoom.Instance; return(newRoom); }