muddesigner/Mud Designer/MudEngine/GameObjects/Environment/Realm.cs
Scionwest_cp afd74530cd Engine:
- Corrected SaveDataTypes.Currency being named incorrectly. Changed to Currencies
 - ProjectInformation now inherits from the new IFileIO interface.
 - ProjectInformation.Load can be used instead of the FileManager now (note: Saving of ProjectInformation must still be done using FileManager)
 - Organizing of BaseObject done
 - BaseObject now supports BaseObject.Load. Use this instead of FileManager.Load
 - Fixed UIRealmControl error, attempting to deserialize into a null Zone Field
 - Program.cs is now encapsulated into a try/catch
 - IFileIO interface added for providing a blueprint on file I/O operations

Designer:
 - Additional ObjectTypes added to the ObjectTypes enum
 - Additional commenting provided throughout the source.
 - Re-organized the source code.
 - Simplified the Constructor code. Roughly 50% less code now.
 - Re-wrote the Object Load code to make it easier to read and maintain.
 - Renamed several menu items to conform to the projects naming conventions
2010-01-17 18:58:26 -08:00

58 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ComponentModel;
using MudDesigner.MudEngine.FileSystem;
using MudDesigner.MudEngine.GameObjects;
using MudDesigner.MudEngine.UITypeEditors;
namespace MudDesigner.MudEngine.GameObjects.Environment
{
public class Realm : BaseObject
{
[Category("Environment Information")]
[Description("A collection of Zones that are contained within this Realm. Players can traverse the world be traveling through Rooms that are contained within Zones. Note that it is not required to place a Zone into a Realm.")]
[EditorAttribute(typeof(UIRealmEditor), typeof(System.Drawing.Design.UITypeEditor))]
public List<string> Zones { get; set; }
public Realm()
{
Zones = new List<string>();
}
/// <summary>
/// Returns the requested Zone if the Zone exists within this Realm.
/// </summary>
/// <param name="zoneName"></param>
/// <returns></returns>
public Zone GetZone(string zoneName)
{
string zoneFilename = "";
//correct the zonename if needed
if (!zoneName.EndsWith(".zone"))
zoneFilename = zoneName + ".zone";
else
{
zoneName = Path.GetFileNameWithoutExtension(zoneName);
zoneFilename = zoneName;
}
string zonePath = FileManager.GetDataPath(this.Name, zoneFilename);
zonePath = Path.Combine(zonePath, zoneName);
zoneFilename = Path.Combine(zonePath, zoneFilename);
if (File.Exists(zoneFilename))
{
Zone z = new Zone();
z = (Zone)FileManager.Load(zoneFilename, z);
return z;
}
return null;
}
}
}