/// <summary>Loads this instance.</summary> public void Load() { var areaRepository = new RelationalRepository <AreaRecord>(); // @@@ TODO: Fix hack: http://www.wheelmud.net/tabid/59/aft/1622/Default.aspx string areaNumber = this.Parent.Id.Replace("area/", string.Empty); long persistedAreaID = long.Parse(areaNumber); ICollection <RoomRecord> rooms = areaRepository.GetRoomsForArea(persistedAreaID); foreach (var roomRecord in rooms) { // @@@ TODO: Fix hack: http://www.wheelmud.net/tabid/59/aft/1622/Default.aspx var roomBehavior = new RoomBehavior() { ID = roomRecord.ID, }; var currRoom = new Thing(roomBehavior) { Name = roomRecord.Name, Description = roomRecord.Description, Id = "room/" + roomRecord.ID, }; // Load this room and it's children. roomBehavior.Load(); this.Parent.Add(currRoom); } }
/// <summary>Save the typo to the database.</summary> public void Save() { var typoRepository = new RelationalRepository <TypoRecord>(); var typoRecord = new TypoRecord { ID = this.Id, Note = this.Note, Resolved = this.Resolved, ResolvedByPlayerID = (long)this.ResolvedByPlayerId, RoomID = Convert.ToInt64(this.PlaceID), SubmittedByPlayerID = Convert.ToInt64(this.SubmittedByPlayerID), }; if (this.ResolvedDateTime != null) { typoRecord.ResolvedDateTime = this.ResolvedDateTime.ToString(); } else { typoRecord.ResolvedDateTime = null; } typoRecord.SubmittedDateTime = this.SubmittedDateTime.ToString(CultureInfo.InvariantCulture); if (typoRecord.ID == 0) { typoRepository.Add(typoRecord); this.Id = typoRecord.ID; } else { typoRepository.Update(typoRecord); } }
/// <summary>Loads this instance.</summary> public void Load() { var areaRepository = new RelationalRepository <AreaRecord>(); string areaNumber = this.Parent.Id.Replace("area/", string.Empty); long persistedAreaID = long.Parse(areaNumber); ICollection <RoomRecord> rooms = areaRepository.GetRoomsForArea(persistedAreaID); foreach (var roomRecord in rooms) { var roomBehavior = new RoomBehavior() { ID = roomRecord.ID, }; var currRoom = new Thing(roomBehavior) { Name = roomRecord.Name, Description = roomRecord.Description, Id = "room/" + roomRecord.ID, }; // Load this room and it's children. roomBehavior.Load(); this.Parent.Add(currRoom); } }
/// <summary>Loads areas into the world.</summary> public void Load() { var areaRepository = new RelationalRepository <AreaRecord>(); ICollection <AreaRecord> areas = areaRepository.GetAll(); foreach (var areaRecord in areas) { var areaBehavior = new AreaBehavior() { ID = areaRecord.ID, }; var area = new Thing(areaBehavior) { Name = areaRecord.Name, Id = "area/" + areaRecord.ID, }; // Load this area and it's children. areaBehavior.Load(); this.Parent.Add(area); } }
/// <summary>Loads the exits for this room behavior.</summary> public void Load() { var roomRepository = new RelationalRepository <RoomRecord>(); // Standard exits are simple DB records, so we need to load them specifically for this room; // non-standard exits should be loaded just like any other generic Thing. // TODO: These should come as part of the world areas with the document repository, so that // exit Things could get customized with brand new Behaviors without difficulty, etc. string roomNumber = this.Parent.Id.Replace("room/", string.Empty); long persistedRoomID = long.Parse(roomNumber); ICollection <ExitRecord> exits = roomRepository.LoadExitsForRoom(persistedRoomID); foreach (var exitRecord in exits) { // Create a Thing to represent this exit, which can live in multiple places (IE rooms) // as a child of each parent - thus sharing substate (like for doors) will be automatic. var exitBehavior = new ExitBehavior() { ID = exitRecord.ID, }; var exit = new Thing(exitBehavior, new MultipleParentsBehavior()) { Name = "[StandardExit]", Id = "exit/" + exitRecord.ID, }; // Add the exit destinations. string exitRoomA = "room/" + exitRecord.ExitRoomAID.ToString(CultureInfo.InvariantCulture); string exitRoomB = "room/" + exitRecord.ExitRoomBID.ToString(CultureInfo.InvariantCulture); exitBehavior.AddDestination(exitRecord.DirectionA, exitRoomB); exitBehavior.AddDestination(exitRecord.DirectionB, exitRoomA); // Add this Exit Thing as a child of the Room Thing. this.Parent.Add(exit); // Look for the other room; if it exists, add this exit to that room too, else // set up an event reaction to add the exit to the room when it gets loaded. var otherRoom = ThingManager.Instance.FindThing(exitRoomB); if (otherRoom != null) { otherRoom.Add(exit); } else { lock (pendingExitRiggings) { pendingExitRiggings.Add(new PendingExitRigging() { RoomID = exitRoomB, ExitThing = exit, }); } } } // If this room is the secondary parent for a pending exit rigging, rig it up. lock (pendingExitRiggings) { var matchedExitRiggings = this.FindMatchedPendingExitRiggings(this.Parent.Id); foreach (var matchedExitRigging in matchedExitRiggings) { this.Parent.Add(matchedExitRigging.ExitThing); pendingExitRiggings.Remove(matchedExitRigging); } } }
/// <summary>Loads the specified player by their id.</summary> /// <param name="playerId">The player's id.</param> public void Load(int playerId) { var repository = new RelationalRepository <PlayerRecord>(); this.PlayerData = repository.GetById(playerId); }