Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public string GetID()
return _ID;
}

internal virtual void SetUpObject(uint simobjectid)
public virtual void SetUpObject(uint simobjectid)
{
_ID = simobjectid.AsString();
_iID = simobjectid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using WinterLeaf.Engine.Classes.Extensions;

namespace WinterLeaf.Engine.Classes.View.Creators
{
/// <summary>
///
/// </summary>
public abstract class AbstractDynamicInstance
{
private readonly IDictionary<string, object> mExpandoObject =
new ExpandoObject();
protected IDictionary<string, string> mFieldsDictionary =
new Dictionary<string, string>();

/// <summary>
///
/// </summary>
public dynamic Dynamics
{
get { return mExpandoObject; }
}

protected IDictionary<string, string> Fields
{
get { return mFieldsDictionary; }
}

/// <summary>
/// This will return the TorqueScript code that will be executed when Create is called.
/// </summary>
/// <returns> </returns>
public override string ToString()
{
StringBuilder result = new StringBuilder();
result.Append(")\r\n{\r\n");
foreach (KeyValuePair<string, string> ele in mFieldsDictionary)
{
result.Append(ele.Key);
result.Append(" = ");
result.Append(ele.Value.ToString().Trim() != string.Empty ? ele.Value : "\"\"");
result.Append(";\r\n");
}
foreach (KeyValuePair<string, object> ele in mExpandoObject)
{
result.Append(ele.Key);
result.Append(" = ");
result.Append(ele.Value.ToString().Trim() != string.Empty ? ele.Value : "\"\"");
result.Append(";\r\n");
}
result.Append("};\r\n");
return (result.ToString());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace WinterLeaf.Engine.Classes.View.Creators
{
public class FieldWrapper<T> : IEnumerable
{
private IDictionary<string, string> mParentDictionary;
private string mName;

public void Set(ref IDictionary<string, string> pDictionary, string pName)
{
mParentDictionary = pDictionary;
mName = pName;
}

public void Add(int arg1, T arg2)
{
mParentDictionary[mName + "[" + arg1 + "]"] = arg2.ToString();
}

public IEnumerator GetEnumerator()
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace WinterLeaf.Engine.Classes.View.Creators
{
public enum ObjectType
{
Instance,
Datablock,
Singleton
}
/// <summary>
///
/// </summary>
public class ObjectInstance : AbstractDynamicInstance
{
private string mInstanceName;
private string mClassName;
private ObjectType mObjectType;

public ObjectInstance(string pInstanceName, string pClassName, ObjectType pObjectType)
{
mClassName = pClassName;
mInstanceName = pInstanceName;
mObjectType = pObjectType;
}

/// <summary>
/// This will return the TorqueScript code that will be executed when Create is called.
/// </summary>
/// <returns> </returns>
public override string ToString()
{
StringBuilder result = new StringBuilder();
switch (mObjectType)
{
case ObjectType.Instance:
result.Append(" new ");
break;
case ObjectType.Datablock:
result.Append(" datablock ");
break;
case ObjectType.Singleton:
result.Append(" singleton ");
break;
}
result.Append(mClassName);
result.Append("(");
result.Append(mInstanceName);
result.Append(base.ToString());
return (result.ToString());
}

/// <summary>
///
/// </summary>
/// <param name="inst"></param>
/// <returns></returns>
public static implicit operator ModelBase(ObjectInstance inst)
{
UInt32 r;
string id = Omni.self.Evaluate("return " + inst.ToString() + ";", true);
return UInt32.TryParse(id, out r) ? r : 0;
}

/// <summary>
///
/// </summary>
/// <param name="inst"></param>
/// <returns></returns>
public static implicit operator string(ObjectInstance inst)
{
return Omni.self.Evaluate("return " + inst.ToString() + ";", true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public string GetID()
return _ID;
}

internal virtual void SetUpObject(uint simobjectid)
public virtual void SetUpObject(uint simobjectid)
{
_ID = simobjectid.AsString();
_iID = simobjectid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using WinterLeaf.Engine.Classes.Extensions;

namespace WinterLeaf.Engine.Classes.View.Creators
{
/// <summary>
///
/// </summary>
public abstract class AbstractDynamicInstance
{
private readonly IDictionary<string, object> mExpandoObject =
new ExpandoObject();
protected IDictionary<string, string> mFieldsDictionary =
new Dictionary<string, string>();

/// <summary>
///
/// </summary>
public dynamic Dynamics
{
get { return mExpandoObject; }
}

protected IDictionary<string, string> Fields
{
get { return mFieldsDictionary; }
}

/// <summary>
/// This will return the TorqueScript code that will be executed when Create is called.
/// </summary>
/// <returns> </returns>
public override string ToString()
{
StringBuilder result = new StringBuilder();
result.Append(")\r\n{\r\n");
foreach (KeyValuePair<string, string> ele in mFieldsDictionary)
{
result.Append(ele.Key);
result.Append(" = ");
result.Append(ele.Value.ToString().Trim() != string.Empty ? ele.Value : "\"\"");
result.Append(";\r\n");
}
foreach (KeyValuePair<string, object> ele in mExpandoObject)
{
result.Append(ele.Key);
result.Append(" = ");
result.Append(ele.Value.ToString().Trim() != string.Empty ? ele.Value : "\"\"");
result.Append(";\r\n");
}
result.Append("};\r\n");
return (result.ToString());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace WinterLeaf.Engine.Classes.View.Creators
{
public class FieldWrapper<T> : IEnumerable
{
private IDictionary<string, string> mParentDictionary;
private string mName;

public void Set(ref IDictionary<string, string> pDictionary, string pName)
{
mParentDictionary = pDictionary;
mName = pName;
}

public void Add(int arg1, T arg2)
{
mParentDictionary[mName + "[" + arg1 + "]"] = arg2.ToString();
}

public IEnumerator GetEnumerator()
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace WinterLeaf.Engine.Classes.View.Creators
{
public enum ObjectType
{
Instance,
Datablock,
Singleton
}
/// <summary>
///
/// </summary>
public class ObjectInstance : AbstractDynamicInstance
{
private string mInstanceName;
private string mClassName;
private ObjectType mObjectType;

public ObjectInstance(string pInstanceName, string pClassName, ObjectType pObjectType)
{
mClassName = pClassName;
mInstanceName = pInstanceName;
mObjectType = pObjectType;
}

/// <summary>
/// This will return the TorqueScript code that will be executed when Create is called.
/// </summary>
/// <returns> </returns>
public override string ToString()
{
StringBuilder result = new StringBuilder();
switch (mObjectType)
{
case ObjectType.Instance:
result.Append(" new ");
break;
case ObjectType.Datablock:
result.Append(" datablock ");
break;
case ObjectType.Singleton:
result.Append(" singleton ");
break;
}
result.Append(mClassName);
result.Append("(");
result.Append(mInstanceName);
result.Append(base.ToString());
return (result.ToString());
}

/// <summary>
///
/// </summary>
/// <param name="inst"></param>
/// <returns></returns>
public static implicit operator ModelBase(ObjectInstance inst)
{
UInt32 r;
string id = Omni.self.Evaluate("return " + inst.ToString() + ";", true);
return UInt32.TryParse(id, out r) ? r : 0;
}

/// <summary>
///
/// </summary>
/// <param name="inst"></param>
/// <returns></returns>
public static implicit operator string(ObjectInstance inst)
{
return Omni.self.Evaluate("return " + inst.ToString() + ";", true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public string GetID()
return _ID;
}

internal virtual void SetUpObject(uint simobjectid)
public virtual void SetUpObject(uint simobjectid)
{
_ID = simobjectid.AsString();
_iID = simobjectid;
Expand Down
Loading