XMLData class added. This will manage the saving and loading of all scripted objects during runtime. The saved files will be XML formatted.
Added rScript files to the engine. These have not been implemented and currently don't work with the engine. BaseScript has been modified to support the new XMLData class for saving data.
This commit is contained in:
parent
fc27d9fc22
commit
38bdf75bf1
16 changed files with 1174 additions and 25 deletions
|
@ -3,20 +3,76 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
|
||||
using MudEngine.Game;
|
||||
using MudEngine.DAL;
|
||||
|
||||
namespace MudEngine.GameScripts
|
||||
{
|
||||
public class BaseScript
|
||||
{
|
||||
[DefaultValue("Scripted Object")]
|
||||
public String Name { get; set; }
|
||||
|
||||
public String ID { get; set; }
|
||||
|
||||
public String Description { get; set; }
|
||||
|
||||
public BaseScript(String name, String description)
|
||||
public XMLData SaveData { get; protected set; }
|
||||
|
||||
public BaseScript(StandardGame game, String name, String description)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
|
||||
this.ID = Guid.NewGuid().ToString();
|
||||
|
||||
this.SaveData = new XMLData(this.GetType().Name);
|
||||
}
|
||||
|
||||
public virtual Boolean Save(String filename)
|
||||
{
|
||||
return this.Save(filename, false);
|
||||
}
|
||||
|
||||
public virtual Boolean Save(String filename, Boolean ignoreFileWrite)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
|
||||
try
|
||||
{
|
||||
this.SaveData.AddSaveData("Name", Name);
|
||||
this.SaveData.AddSaveData("ID", ID);
|
||||
this.SaveData.AddSaveData("Description", Description);
|
||||
|
||||
if (!ignoreFileWrite)
|
||||
this.SaveData.Save(filename);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual Boolean Load(String filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
return false;
|
||||
|
||||
XElement data = XElement.Load(filename);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue