mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added C# -> Trenchbrom entity definition with reflection system
This commit is contained in:
14
NuakeNet/src/BrushScript.cs
Normal file
14
NuakeNet/src/BrushScript.cs
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user