Added C# -> Trenchbrom entity definition with reflection system

This commit is contained in:
Antoine Pilote
2024-08-30 21:44:08 -04:00
parent d46f74aa24
commit 85b41e9ea0
18 changed files with 439 additions and 107 deletions

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Nuake.Net
{
[BrushScript]
public class Brush : Entity
{
}
}

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -27,6 +28,8 @@ namespace Nuake.Net
internal static unsafe delegate*<int, NativeString> EntityGetNameIcall;
internal static unsafe delegate*<int, NativeString, void> EntitySetNameIcall;
internal static unsafe delegate*<int, bool> EntityIsValidIcall;
internal static unsafe delegate*<NativeString, NativeArray<int>> EntityGetTargetsIcall;
internal static unsafe delegate*<int, NativeString> EntityGetTargetIcall;
public enum ComponentTypes
{
@@ -55,6 +58,37 @@ namespace Nuake.Net
NAVMESH
}
public List<Entity> Targets
{
get
{
unsafe
{
var targetIds = EntityGetTargetsIcall(Target);
List<Entity> targets = new List<Entity>();
foreach(var target in targetIds)
{
bool hasInstance = EntityHasManagedInstanceIcall(target);
Entity entityInstance;
if (hasInstance)
{
entityInstance = Scene.GetEntity<Entity>(target);
}
else
{
entityInstance = new Entity(ECSHandle);
}
targets.Add(entityInstance);
}
return targets;
}
}
}
public string Target { get { unsafe { return EntityGetTargetIcall(ECSHandle); } }}
public int ID { get; set; }
public int ECSHandle { get; set; } = -1;
@@ -99,6 +133,11 @@ namespace Nuake.Net
{
}
public virtual void Activate(Entity triggeredFrom)
{
}
// Physics
public void OnCollisionInternal(int entity)
{

View File

@@ -5,6 +5,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Nuake.Net
@@ -35,6 +36,19 @@ namespace Nuake.Net
{
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class BrushScript : Attribute
{
public string Description = "";
public bool IsTrigger = false;
public BrushScript(string description = "", bool isTrigger = false)
{
Description = description;
IsTrigger = isTrigger;
}
}
public class Debug
{
internal static unsafe delegate*</* start */ float, float, float,