public void RemoveEnterFromRoom(string targetRoom, string exitToPath) { if (targetRoom == "" || exitToPath == "") { return; } string targetFunction = "SetEnters"; RoomModel room = RoomNameMap[targetRoom]; //first order of business is to see if we even have any exits defined if (room.FunctionCalls.CallList.ContainsKey(targetFunction)) { //function is defined. now, is the exit present? string mapping = room.FunctionCalls.CallList[targetFunction]; if (mapping.Contains(exitToPath)) { //ok, we know the exit is here. Now we just need to find and remove it //Note, there can be more than one. try { Dictionary <string, string> map = ParserTools.StringIntoMap(mapping, targetFunction); Dictionary <string, string> rebuild = new Dictionary <string, string>(); foreach (string key in map.Keys) { if (map[key] != exitToPath) { //only add entries that aren't to be removed rebuild.Add(key, map[key]); } } room.EditorState.EntersList = rebuild; room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(rebuild); } catch (ParserException e) { System.Windows.Forms.MessageBox.Show(e.Message, ParserErrorTitle); return; } } } }
private bool LoadRoom(string roomName) { if (roomName.Length == 0 || RoomNameMap.ContainsKey(this.DomainFileReferences[THIS_DOMAIN].ConvertRoomNameToFullPath(roomName))) { return(false); } RoomModel room; try{ room = new RoomModel(roomName, this); } catch (DomainModelException exc) { throw new DomainModelException(exc.Message); } Rooms.AddLast(room); RoomNameMap.Add(this.DomainFileReferences[THIS_DOMAIN].ConvertRoomNameToFullPath(roomName), Rooms.Last.Value); //we have to get the raw roomname from linked list this.DomainFileReferences[THIS_DOMAIN].Rooms.Add(Include.GetPathDefinitionIdentifier(ItemSaveType.Room, this.Name) + " \"/" + Rooms.Last.Value.RawFileName + "\"", new FileReferenceModel(roomName, ItemSaveType.Room, Include, this.Name)); return(true); }
public RoomModel(FunctionCallsCollection functionCalls, string fileName, DomainModel model, RoomType type) { FunctionCalls = functionCalls; FileName = fileName; RawFileName = RoomModel.ConvertFullPathToRoomName(fileName); //try loading pre-exiting file first. If you can't, //then create one from the default text file asset string roomPath = model.DomainRootDir + System.IO.Path.DirectorySeparatorChar.ToString() + model.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Room); string fullFilePath = roomPath + System.IO.Path.DirectorySeparatorChar.ToString() + RawFileName; if (System.IO.File.Exists(fullFilePath)) { Code.LoadLPC(fullFilePath); } else { switch (type) { case RoomType.Normal: { Code.CreateLPCFromScratch(DeadSoulsObjectType.Room); break; } case RoomType.Shop: { Code.CreateLPCFromScratch(DeadSoulsObjectType.Shop); break; } case RoomType.Instance: { Code.CreateLPCFromScratch(DeadSoulsObjectType.InstanceRoom); break; } case RoomType.PoliceStation: { Code.CreateLPCFromScratch(DeadSoulsObjectType.PoliceOffice); break; } case RoomType.JailCell: { Code.CreateLPCFromScratch(DeadSoulsObjectType.JailCell); break; } default: { Code.CreateLPCFromScratch(DeadSoulsObjectType.Room); break; } } //Code.CreateLPCFromScratch(DeadSoulsObjectType.Room); } //PushDataToCode(); }
protected RoomModel InnerClone() { RoomModel s = this.MemberwiseClone() as RoomModel; return(s); }
public void AddEnterToRoom(string targetRoom, string exitToPath, string direction) { if (targetRoom == "" || exitToPath == "" || direction == "") { return; } if (targetRoom == exitToPath) { System.Windows.Forms.MessageBox.Show("You cannot have " + targetRoom + " enter into itself."); return; } string targetFunction = "SetEnters"; RoomModel room = RoomNameMap[targetRoom]; //first order of business is to make sure we even have the //function call for an exit, otherwise we need to create it if (room.FunctionCalls.CallList.ContainsKey(targetFunction)) { //function call exists. Do we already have an entry for this direction? try { Dictionary <string, string> map = ParserTools.StringIntoMap(room.FunctionCalls.CallList[targetFunction], targetFunction); if (map.ContainsKey(direction)) { //we have to edit a pre-existing entry foreach (string key in map.Keys) { if (key == direction) { map[key] = exitToPath; room.EditorState.EntersList = map; room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(map); return; } } } else { //entry does not exist, create it now map.Add(direction, exitToPath); room.EditorState.EntersList = map; room.FunctionCalls.CallList[targetFunction] = ParserTools.MapIntoString(map); return; } } catch (ParserException e) { System.Windows.Forms.MessageBox.Show(e.Message, ParserErrorTitle); } } else { //we are storing this function call for the first time //TODO: Implement this //throw new Exception("Function doesn not exist in this control. TODO: Implement Model.AddExitToRoom()"); Dictionary <string, string> map = new Dictionary <string, string>(); map.Add(direction, exitToPath); room.EditorState.EntersList = map; room.FunctionCalls.CallList.Add(targetFunction, ParserTools.MapIntoString(map)); } }