add FindEntityByName function
This commit is contained in:
@ -5,6 +5,12 @@ namespace Hazel
|
||||
{
|
||||
public static class InternalCalls
|
||||
{
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal extern static ulong Entity_FindEntityByName(String name);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal extern static object GetScriptInstance(ulong entityID);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool Entity_HasComponent(ulong entityID, Type componentType);
|
||||
|
||||
|
||||
@ -32,11 +32,26 @@ namespace Hazel{
|
||||
|
||||
public T GetComponent<T>() where T : Component, new()
|
||||
{
|
||||
if(!HasComponent<T>())
|
||||
if (!HasComponent<T>())
|
||||
return null;
|
||||
T component = new T() { Entity = this };
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
public Entity FindEntityByName(string name)
|
||||
{
|
||||
ulong entityID = InternalCalls.Entity_FindEntityByName(name);
|
||||
if (entityID == 0)
|
||||
return null;
|
||||
|
||||
return new Entity(entityID);
|
||||
}
|
||||
|
||||
public T As<T>() where T : Entity, new()
|
||||
{
|
||||
object instance = InternalCalls.GetScriptInstance(ID);
|
||||
return instance as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,13 @@ namespace Hazel
|
||||
Z = scale;
|
||||
}
|
||||
|
||||
public Vector3(Vector2 xy, float z)
|
||||
{
|
||||
X = xy.X;
|
||||
Y = xy.Y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public Vector3(float x, float y, float z) {
|
||||
X = x;
|
||||
Y = y;
|
||||
|
||||
Reference in New Issue
Block a user