MudEngine:
- Added FileManager.GetDataSpan() method. This allows developers to start at a line and collect the next 'x' number of lines after that starting line. Example: GetDataSpan("MyFile.txt", 5, "DoorwayArrivalRoom", true); This seeks MyFile.txt until it finds "DoorwayArrivalRoom" and then it stores that line and the next 4 lines for a total of 5 lines and returns the collection. The last argument 'true' means that the method will scan the rest of the file after the initial 5 lines and add any other lines that match the "DoorwayArrivalRoom" string as well. - Deleted CommandResults class as it's no longer used by the script engine. - Singleplayer and Multiplayer save data paths are now the same paths by default. - Game.Update() method now checks for auto-saving (instead of MudGame performing this check) - Saving and restoring of Realms, Zones, Rooms and Doorways now fully implemented. - GameTime now supports auto-saving - GameWorld.Update() now calls BaseCharacter.Update() and is ready for future update code. - GameWorld.AddObject and GameWorld.RemoveObject() have been removed. - GameWorld.AddRealm() re-added for adding Realms pre-populated with zones/rooms. Note that Zones and Rooms can be added to a Realm even after it has been added to the GameWorld.RealmCollection - BaseObject now contains a OnStart() event method. - BaseObject.Save() now saves BaseObject.DetailedDescription collection content. - Updated BaseCharacter to retrieve Environments by Filename rather than Object name. - BaseStats.Experience property added. - Door.RoomTravelType enum added for determining if the room is Arrival or Departure - Door.SetRoom() method added for restoring a Rooms Doorway link during world restoration. - Renamed Room.InstallPath to Room.RoomLocation. Contains a MyRealm.Realm>MyZone.Zone>MyRoom.Room path - Added Room.RoomLocationWithoutExtension property for returning the Rooms location without file extensions. Ex: MyRealm>MyZone>MyRoom - Room now saves Doorways. - The GameWorld now restores the link between Rooms once all Environment objects have been instanced and restored from their saved state. MudGame: - Minor clean-up with MudGame loop and shutdown. - Updated scripts to reflect changes made to the engine.
This commit is contained in:
parent
35a0c65b99
commit
de82476525
16 changed files with 372 additions and 185 deletions
|
@ -84,6 +84,79 @@ namespace MudEngine.FileSystem
|
|||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of data from a file spanning
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="startingLine"></param>
|
||||
/// <param name="endingLine"></param>
|
||||
/// <returns></returns>
|
||||
public static List<String> GetDataSpan(String filename, Int32 linesToSpan)
|
||||
{
|
||||
List<String> items = new List<String>();
|
||||
Int32 currentLine = 1;
|
||||
|
||||
foreach (String line in File.ReadAllLines(filename))
|
||||
{
|
||||
if (line.StartsWith(";"))
|
||||
continue;
|
||||
|
||||
items.Add(line);
|
||||
|
||||
if (currentLine == linesToSpan)
|
||||
break;
|
||||
else
|
||||
currentLine++;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static List<String> GetDataSpan(String filename, Int32 linesToSpan, String startingValue, Boolean spanAllSimilar)
|
||||
{
|
||||
List<String> items = new List<String>();
|
||||
String[] fileData = File.ReadAllLines(filename);
|
||||
Int32 line = 0;
|
||||
|
||||
while (line <= fileData.Length)
|
||||
{
|
||||
if (fileData[line].StartsWith(";"))
|
||||
continue;
|
||||
else if (fileData[line].ToLower().StartsWith(startingValue.ToLower()))
|
||||
{
|
||||
Boolean isComplete = false;
|
||||
|
||||
while (!isComplete)
|
||||
{
|
||||
Int32 startingLine = line;
|
||||
|
||||
//Exception prevention first.
|
||||
if (line >= fileData.Length)
|
||||
{
|
||||
isComplete = true;
|
||||
continue;
|
||||
}
|
||||
if (fileData[line].ToLower().StartsWith(startingValue.ToLower()))
|
||||
{
|
||||
for (Int32 i = startingLine; i != (startingLine + linesToSpan); i++)
|
||||
{
|
||||
String[] content = fileData[i].Split('=');
|
||||
items.Add(content[1]);
|
||||
line++;
|
||||
}
|
||||
|
||||
if (!spanAllSimilar)
|
||||
isComplete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the complete path to the specified data's save folder.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue