- UIControls namespace renamed to UIWidgets - RealmExplorer Control renamed to RealmWidget - RealmWidget now handles scanning and populating the Widget with existing realms rather than the designer handling it. - Object saving re-wrote - Zone Creation implemented - Adding Zones to Realms implemented - Removal of Zones from within Realms implemented - Support for stand-alone Zones added. Unlike the previous version of the 'Mud Designer Realm Explorer & Zone Builder', Zones can be built without being placed within a Realm - Deleting a Zone removes it from the Realms collection - Custom UITypeEditor added for adding Zones to Realms. - Menu item Project->Game Management has been re-structured - Saved file extensions on objects changed from .XML back to .ObjectType (example .realm) - RefreshProjectExplorer method added for refreshing the project explorer's directory structure - All calls to btnRefreshObjects_Click has been replaced with RefreshProjectExplorer() - The Project Explorer can now delete any object (file or folder) underneath the Project Root node. - The Project Explorer now has the files it contains highlighted as blue to help readability. - Changed the Project Explorer's root object from "Game Objects" to "Project" - Began implementation of the Project Explorer's search feature. - SaveSelected method added to save the current object contained within the property grid. - Anytime an Objects Property is changed the designer now automatically saves the object. - Object Properties label now displays the Type of object being edited and the objects name (Example 'Zone Properties (Village of Tespa)') Mud Designer: - The New Test Designer has been set as the startup object, as the old designer toolkit is being phased out. Mud Engine: - Added UIRealmControl class, a custom control used by the designer to edit the Realm.Zones property. - UIRealmEditor class added, manages the UIRealmControl.
180 lines
4.9 KiB
C#
180 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using System.Xml.Serialization;
|
|
using MudDesigner.MudEngine.Interfaces;
|
|
using MudDesigner.MudEngine.UITypeEditors;
|
|
|
|
namespace MudDesigner.MudEngine.GameObjects
|
|
{
|
|
public class BaseObject : IGameObject
|
|
{
|
|
[Category("Object Setup")]
|
|
//Required to refresh Filename property in the editors propertygrid
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return this._Name;
|
|
}
|
|
set
|
|
{
|
|
this._Name = value;
|
|
this.Filename = value + "." + this.GetType().Name;
|
|
}
|
|
}
|
|
|
|
[Category("Object Setup")]
|
|
public string Description
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Object Setup")]
|
|
[EditorAttribute(typeof(UIScriptEditor), typeof(System.Drawing.Design.UITypeEditor))]
|
|
public string Script { get; set; }
|
|
|
|
[Category("Object Setup")]
|
|
public string Filename
|
|
{
|
|
//Returns the name of the object + the objects Type as it's extension.
|
|
//Filenames are generated by the class itself, users can not assign it.
|
|
get
|
|
{
|
|
return this._Filename;
|
|
}
|
|
set
|
|
{
|
|
string extension = "." + this.GetType().Name;
|
|
if (!value.EndsWith(extension))
|
|
value += extension;
|
|
|
|
this._Filename = value;
|
|
}
|
|
}
|
|
|
|
[Category("Senses")]
|
|
[DefaultValue("You don't smell anything unsual.")]
|
|
public string Smell
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Senses")]
|
|
[DefaultValue("You hear nothing of interest.")]
|
|
public string Listen
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Senses")]
|
|
[DefaultValue("You feel nothing.")]
|
|
public string Feel
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
private string _Filename = "";
|
|
private string _Name = "";
|
|
/// <summary>
|
|
/// Initializes the base object
|
|
/// </summary>
|
|
public BaseObject()
|
|
{
|
|
Script = "";
|
|
_Name = "New " + this.GetType().Name;
|
|
_Filename = _Name + "." + this.GetType().Name;
|
|
|
|
this.Feel = "You feel nothing.";
|
|
this.Listen = "You hear nothing of interest.";
|
|
this.Smell = "You don't smell anything unsual.";
|
|
this.Name = DefaultName();
|
|
SetupScript();
|
|
}
|
|
|
|
private bool ShouldSerializeName()
|
|
{
|
|
return this.Name != DefaultName();
|
|
}
|
|
|
|
private void ResetName()
|
|
{
|
|
this.Name = DefaultName();
|
|
}
|
|
|
|
private string DefaultName()
|
|
{
|
|
return "New " + this.GetType().Name;
|
|
}
|
|
|
|
private void SetupScript()
|
|
{
|
|
//Check if the realm script is empty. If so then generate a standard script for it.
|
|
if (Script == "")
|
|
{
|
|
//Instance a new method helper class
|
|
ManagedScripting.CodeBuilding.MethodSetup method = new ManagedScripting.CodeBuilding.MethodSetup();
|
|
string script = "";
|
|
//Setup our method. All objects inheriting from BaseObject will have the standard
|
|
//methods created for them.
|
|
string[] names = new string[] { "OnCreate", "OnDestroy", "OnEnter", "OnExit" };
|
|
foreach (string name in names)
|
|
{
|
|
method = new ManagedScripting.CodeBuilding.MethodSetup();
|
|
method.Name = name;
|
|
method.ReturnType = "void";
|
|
method.IsOverride = true;
|
|
method.Modifier = ManagedScripting.CodeBuilding.ClassGenerator.Modifiers.Public;
|
|
method.Code = new string[] { "base." + method.Name + "();" };
|
|
script = script.Insert(Script.Length, method.Create() + "\n");
|
|
}
|
|
Script = script;
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.Name;
|
|
}
|
|
|
|
public virtual void OnEnter()
|
|
{
|
|
}
|
|
|
|
public virtual void OnExit()
|
|
{
|
|
}
|
|
|
|
public virtual void OnCreate()
|
|
{
|
|
}
|
|
|
|
public virtual void OnDestroy()
|
|
{
|
|
}
|
|
|
|
public virtual void OnEquip()
|
|
{
|
|
}
|
|
|
|
public virtual void OnUnequip()
|
|
{
|
|
}
|
|
|
|
public virtual void OnMount()
|
|
{
|
|
}
|
|
|
|
public virtual void OnDismount()
|
|
{
|
|
}
|
|
}
|
|
}
|