muddesigner/MudEngine/Scripting/GameObject.cs
Scionwest_cp a52ccf8da9 MudEngine:
- Converted all Types from C# types to .NET Types (such as bool changed to Boolean, and int changed to Int32).
 - Zone no longer gets saved from within GameWorld.Save, but rather in Realm.Save()
 - Room no longer gets saved from within GameWorld.Save(), but rather in Zone.Save();
 - Added new SaveWorld command that admins only can execute to force save the world. It's not fully implemented at this time.

MudGame:
 - began work on command execution from within the server while it's running.
2010-08-14 00:20:43 -07:00

87 lines
2.3 KiB
C#

using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Scripting;
namespace MudEngine.Scripting
{
public class GameObject
{
/// <summary>
/// The script instance for this game object
/// </summary>
public object Instance { get; set; }
/// <summary>
/// The Type name for this object
/// </summary>
public String Name { get; set; }
/// <summary>
/// Determins if this object will recieve Update/Draw calls from the ScriptEngine
/// </summary>
public Boolean IsActive { get; set; }
public GameObject(object instance, String name)
{
Instance = instance;
Name = name;
}
public object CreateObject()
{
return Instance;
}
public Boolean DeleteObject()
{
return true;
}
public void SetProperty(String propertyName, object propertyValue)
{
PropertyInfo propertyInfo = Instance.GetType().GetProperty(propertyName);
if (propertyValue is String)
{
if (propertyInfo.PropertyType.Name is String)
{
propertyInfo.SetValue(Instance, propertyValue, null);
}
}
}
public object GetProperty(String propertyName)
{
String[] tokens = propertyName.Split('.');
PropertyInfo previousProperty = Instance.GetType().GetProperty(tokens[0]);
return previousProperty.GetValue(Instance, null);
}
public dynamic GetProperty()
{
return Instance;
}
public object InvokeMethod(String methodName, params object[] parameters)
{
MethodInfo method = Instance.GetType().GetMethod(methodName);
try
{
if (parameters == null || parameters.Length == 0)
return method.Invoke(Instance, null);
else
return method.Invoke(Instance, parameters);
}
catch
{
throw;
}
}
}
}