muddesigner/MudEngine/WinPC_Engine/GameScripts/BaseScript.cs
Scionwest_cp ec5a674062 * StandardCharacter now automatically invokes the Login command upon connection to the server. Login command not implemented completely yet.
* Telnet client header information is now successfully (finally) stripped out of the first stream received.
* Command System underwent some optimizations along with now always returning a Boolean value once execution of a command is completed.
* ICommand interface now forces all ICommand.Execute methods to return a Boolean value.
* DataPaths class re-wrote and is now simi in-use by StandardGame and the Login command
* Minor adjustments to how characters are initialized upon connection in various classes.
2012-03-03 20:57:47 -08:00

86 lines
2.1 KiB
C#

using System;
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 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 void Load(String filename)
{
try
{
if (!File.Exists(filename))
return;
//XElement data = XElement.Load(filename);
}
catch
{
return;
}
return;
}
public override string ToString()
{
if (String.IsNullOrEmpty(this.Name))
return this.GetType().Name + " without Name";
else
return this.Name;
}
}
}