From 691acff7292f15d5dbd6e84985a5f7140b9bb5fc Mon Sep 17 00:00:00 2001 From: 0x Date: Sun, 19 Jan 2025 10:35:06 +1300 Subject: [PATCH] ICall delegates -> unmanged delegates into unmanaged code are now marked with unmanaged keyword --- EditorNet/src/Editor.cs | 4 +- .../src/Scripting/NetModules/SceneNetAPI.cpp | 7 +--- NuakeNet/src/Components.cs | 40 +++++++++---------- NuakeNet/src/EngineSubsystem.cs | 4 +- NuakeNet/src/Entity.cs | 20 +++++----- NuakeNet/src/Environment.cs | 4 +- NuakeNet/src/Input.cs | 18 ++++----- NuakeNet/src/Physic.cs | 10 ++--- NuakeNet/src/Scene.cs | 8 ++-- NuakeNet/src/UI/UIComponent.cs | 22 +++++----- NuakeNet/src/main.cs | 16 ++++---- 11 files changed, 75 insertions(+), 78 deletions(-) diff --git a/EditorNet/src/Editor.cs b/EditorNet/src/Editor.cs index a4cce58f..5b759c2f 100644 --- a/EditorNet/src/Editor.cs +++ b/EditorNet/src/Editor.cs @@ -8,8 +8,8 @@ namespace Nuake { class Editor { - internal static unsafe delegate* SetSelectedEntityIcall; - internal static unsafe delegate* GetSelectedEntityIcall; + internal static unsafe delegate* unmanaged SetSelectedEntityIcall; + internal static unsafe delegate* unmanaged GetSelectedEntityIcall; static int STACK_CAPACITY = 32; private static Stack CommandStack = new(STACK_CAPACITY); diff --git a/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp b/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp index 7820b108..4a673c65 100644 --- a/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp +++ b/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp @@ -54,11 +54,8 @@ namespace Nuake { Entity entity = scene->GetEntity(entityName); auto& scriptingEngine = ScriptingEngineNet::Get(); - if (scriptingEngine.HasEntityScriptInstance(entity)) - { - auto instance = scriptingEngine.GetEntityScript(entity); - outInstance->m_Handle = instance->m_Handle; - outInstance->m_Type = instance->m_Type; + if (auto instance = scriptingEngine.GetEntityScript(entity); instance) { + *outInstance = *instance; } } diff --git a/NuakeNet/src/Components.cs b/NuakeNet/src/Components.cs index ed485e9e..52331406 100644 --- a/NuakeNet/src/Components.cs +++ b/NuakeNet/src/Components.cs @@ -22,7 +22,7 @@ public ParentComponent(UInt32 entityId) { } } public class NameComponent : IComponent { - internal static unsafe delegate* GetNameIcall; + internal static unsafe delegate* unmanaged GetNameIcall; public NameComponent(int entityId) { @@ -51,11 +51,11 @@ public PrefabComponent(UInt32 entityId) { } public class TransformComponent : IComponent { - internal static unsafe delegate*> GetGlobalPositionIcall; - internal static unsafe delegate*> GetPositionIcall; - internal static unsafe delegate* SetPositionIcall; - internal static unsafe delegate* LookAtIcall; - internal static unsafe delegate* RotateIcall; + internal static unsafe delegate* unmanaged> GetGlobalPositionIcall; + internal static unsafe delegate* unmanaged> GetPositionIcall; + internal static unsafe delegate* unmanaged SetPositionIcall; + internal static unsafe delegate* unmanaged LookAtIcall; + internal static unsafe delegate* unmanaged RotateIcall; public TransformComponent(int entityId) { @@ -124,9 +124,9 @@ public void LookAt(Vector3 targetPosition, Vector3 up) public class LightComponent : IComponent { - internal static unsafe delegate* GetLightIntensityIcall; - internal static unsafe delegate* SetLightIntensityIcall; - internal static unsafe delegate* SetLightColorIcall; + internal static unsafe delegate* unmanaged GetLightIntensityIcall; + internal static unsafe delegate* unmanaged SetLightIntensityIcall; + internal static unsafe delegate* unmanaged SetLightColorIcall; public enum LightType { Directional, @@ -175,9 +175,9 @@ public Color Color public class CameraComponent : IComponent { - internal static unsafe delegate*> GetDirectionIcall; - internal static unsafe delegate* SetCameraFOVIcall; - internal static unsafe delegate* GetCameraFOVIcall; + internal static unsafe delegate* unmanaged> GetDirectionIcall; + internal static unsafe delegate* unmanaged SetCameraFOVIcall; + internal static unsafe delegate* unmanaged GetCameraFOVIcall; public CameraComponent(int entityId) { @@ -212,8 +212,8 @@ public Vector3 Direction public class AudioEmitterComponent : IComponent { - internal static unsafe delegate* GetIsPlayingIcall; - internal static unsafe delegate* SetIsPlayingIcall; + internal static unsafe delegate* unmanaged GetIsPlayingIcall; + internal static unsafe delegate* unmanaged SetIsPlayingIcall; public AudioEmitterComponent(int entityId) { @@ -243,7 +243,7 @@ public ModelComponent(int entityId) public class SkinnedModelComponent : IComponent { - internal static unsafe delegate* PlayIcall; + internal static unsafe delegate* unmanaged PlayIcall; public SkinnedModelComponent(int entityId) { @@ -328,10 +328,10 @@ public MeshColliderComponent(int entityId) public class CharacterControllerComponent : IComponent { - internal static unsafe delegate* MoveAndSlideIcall; - internal static unsafe delegate* IsOnGroundIcall; - internal static unsafe delegate*> GetGroundVelocityIcall; - internal static unsafe delegate*> GetGroundNormalIcall; + internal static unsafe delegate* unmanaged MoveAndSlideIcall; + internal static unsafe delegate* unmanaged IsOnGroundIcall; + internal static unsafe delegate* unmanaged> GetGroundVelocityIcall; + internal static unsafe delegate* unmanaged> GetGroundNormalIcall; public CharacterControllerComponent(int entityId) { @@ -401,7 +401,7 @@ public SpriteComponent(int entityId) { } public class NavMeshVolumeComponent : IComponent { - internal static unsafe delegate*> FindPathIcall; + internal static unsafe delegate* unmanaged> FindPathIcall; public NavMeshVolumeComponent(int entityId) { EntityID = entityId; } diff --git a/NuakeNet/src/EngineSubsystem.cs b/NuakeNet/src/EngineSubsystem.cs index a4fddc71..5e19923b 100644 --- a/NuakeNet/src/EngineSubsystem.cs +++ b/NuakeNet/src/EngineSubsystem.cs @@ -2,8 +2,8 @@ { public class EngineSubsystem { - internal static unsafe delegate* SetCanTickIcall; - internal static unsafe delegate* GetCanTickIcall; + internal static unsafe delegate* unmanaged SetCanTickIcall; + internal static unsafe delegate* unmanaged GetCanTickIcall; public int EngineSubsystemID { get; protected set; } diff --git a/NuakeNet/src/Entity.cs b/NuakeNet/src/Entity.cs index af45ca92..c6a5b680 100644 --- a/NuakeNet/src/Entity.cs +++ b/NuakeNet/src/Entity.cs @@ -22,15 +22,15 @@ public struct CollisionData [StructLayout(LayoutKind.Sequential)] public class Entity { - internal static unsafe delegate* EntityHasComponentIcall; - internal static unsafe delegate* EntityAddComponentIcall; - internal static unsafe delegate* EntityHasManagedInstanceIcall; - internal static unsafe delegate* EntityGetEntityIcall; - internal static unsafe delegate* EntityGetNameIcall; - internal static unsafe delegate* EntitySetNameIcall; - internal static unsafe delegate* EntityIsValidIcall; - internal static unsafe delegate*> EntityGetTargetsIcall; - internal static unsafe delegate* EntityGetTargetIcall; + internal static unsafe delegate* unmanaged EntityHasComponentIcall; + internal static unsafe delegate* unmanaged EntityAddComponentIcall; + internal static unsafe delegate* unmanaged EntityHasManagedInstanceIcall; + internal static unsafe delegate* unmanaged EntityGetEntityIcall; + internal static unsafe delegate* unmanaged EntityGetNameIcall; + internal static unsafe delegate* unmanaged EntitySetNameIcall; + internal static unsafe delegate* unmanaged EntityIsValidIcall; + internal static unsafe delegate* unmanaged> EntityGetTargetsIcall; + internal static unsafe delegate* unmanaged EntityGetTargetIcall; public enum ComponentTypes { @@ -272,7 +272,7 @@ public static implicit operator bool(Entity entity) public class Prefab { - internal static unsafe delegate* PrefabInstanceIcall; + internal static unsafe delegate* unmanaged PrefabInstanceIcall; string Path { get; set; } diff --git a/NuakeNet/src/Environment.cs b/NuakeNet/src/Environment.cs index 88199579..ceca3f0f 100644 --- a/NuakeNet/src/Environment.cs +++ b/NuakeNet/src/Environment.cs @@ -9,8 +9,8 @@ namespace Nuake.Net { public class Environment { - internal static unsafe delegate* SetFocusDistanceIcall; - internal static unsafe delegate* GetFocusDistanceIcall; + internal static unsafe delegate* unmanaged SetFocusDistanceIcall; + internal static unsafe delegate* unmanaged GetFocusDistanceIcall; public static void SetFocusDistance(float distance) { diff --git a/NuakeNet/src/Input.cs b/NuakeNet/src/Input.cs index 01b2ee88..7cdb28ff 100644 --- a/NuakeNet/src/Input.cs +++ b/NuakeNet/src/Input.cs @@ -175,15 +175,15 @@ public enum ControllerAxis public class Input { - internal static unsafe delegate* ShowMouseIcall; - internal static unsafe delegate* IsKeyDownIcall; - internal static unsafe delegate* IsKeyPressedIcall; - internal static unsafe delegate* IsMouseButtonDownIcall; - internal static unsafe delegate*> GetMousePositionIcall; - internal static unsafe delegate* IsControllerConnectedIcall; - internal static unsafe delegate* GetControllerNameIcall; - internal static unsafe delegate* IsControllerButtonPressedIcall; - internal static unsafe delegate* GetControllerAxisIcall; + internal static unsafe delegate* unmanaged ShowMouseIcall; + internal static unsafe delegate* unmanaged IsKeyDownIcall; + internal static unsafe delegate* unmanaged IsKeyPressedIcall; + internal static unsafe delegate* unmanaged IsMouseButtonDownIcall; + internal static unsafe delegate* unmanaged> GetMousePositionIcall; + internal static unsafe delegate* unmanaged IsControllerConnectedIcall; + internal static unsafe delegate* unmanaged GetControllerNameIcall; + internal static unsafe delegate* unmanaged IsControllerButtonPressedIcall; + internal static unsafe delegate* unmanaged GetControllerAxisIcall; public static bool IsMouseButtonDown(MouseButton button) diff --git a/NuakeNet/src/Physic.cs b/NuakeNet/src/Physic.cs index 98439192..aae0d959 100644 --- a/NuakeNet/src/Physic.cs +++ b/NuakeNet/src/Physic.cs @@ -120,11 +120,11 @@ public enum Layers SENSORS = 5 } - internal static unsafe delegate*> RayCastIcall; - internal static unsafe delegate*> ShapeCastBoxIcall; - internal static unsafe delegate*> ShapeCastSphereIcall; - internal static unsafe delegate*> ShapeCastCapsuleIcall; - internal static unsafe delegate*> ShapeCastCylinderIcall; + internal static unsafe delegate* unmanaged> RayCastIcall; + internal static unsafe delegate* unmanaged> ShapeCastBoxIcall; + internal static unsafe delegate* unmanaged> ShapeCastSphereIcall; + internal static unsafe delegate* unmanaged> ShapeCastCapsuleIcall; + internal static unsafe delegate* unmanaged> ShapeCastCylinderIcall; public static List RayCast(Vector3 from, Vector3 to) { diff --git a/NuakeNet/src/Scene.cs b/NuakeNet/src/Scene.cs index ce25a1e1..f9516530 100644 --- a/NuakeNet/src/Scene.cs +++ b/NuakeNet/src/Scene.cs @@ -6,10 +6,10 @@ namespace Nuake.Net { public class Scene { - internal static unsafe delegate* GetEntityIcall; - internal static unsafe delegate**, void> GetEntityScriptFromNameIcall; - internal static unsafe delegate*> GetEntityScriptFromHandleIcall; - internal static unsafe delegate* InstancePrefabIcall; + internal static unsafe delegate* unmanaged GetEntityIcall; + internal static unsafe delegate* unmanaged*, void> GetEntityScriptFromNameIcall; + internal static unsafe delegate* unmanaged> GetEntityScriptFromHandleIcall; + internal static unsafe delegate* unmanaged InstancePrefabIcall; public static T? GetEntity(string entityName) where T : class { diff --git a/NuakeNet/src/UI/UIComponent.cs b/NuakeNet/src/UI/UIComponent.cs index cf34572b..8d8f08b7 100644 --- a/NuakeNet/src/UI/UIComponent.cs +++ b/NuakeNet/src/UI/UIComponent.cs @@ -78,16 +78,16 @@ public enum Visibility public class Node { - internal static unsafe delegate* FindChildByIDICall; - internal static unsafe delegate* HasNativeInstanceICall; - internal static unsafe delegate*> GetNativeInstanceNodeICall; - internal static unsafe delegate* SetVisibilityICall; - internal static unsafe delegate* GetVisibilityICall; + internal static unsafe delegate* unmanaged FindChildByIDICall; + internal static unsafe delegate* unmanaged HasNativeInstanceICall; + internal static unsafe delegate* unmanaged> GetNativeInstanceNodeICall; + internal static unsafe delegate* unmanaged SetVisibilityICall; + internal static unsafe delegate* unmanaged GetVisibilityICall; - internal static unsafe delegate* GetHeightPercentageICall; - internal static unsafe delegate* SetHeightPercentageICall; - internal static unsafe delegate* GetWidthPercentageICall; - internal static unsafe delegate* SetWidthPercentageICall; + internal static unsafe delegate* unmanaged GetHeightPercentageICall; + internal static unsafe delegate* unmanaged SetHeightPercentageICall; + internal static unsafe delegate* unmanaged GetWidthPercentageICall; + internal static unsafe delegate* unmanaged SetWidthPercentageICall; public string UUID; public string CanvasUUID; @@ -202,8 +202,8 @@ public T FindChildByID(string id) where T : Node public class TextNode : Node { - internal static unsafe delegate* SetTextNodeTextICall; - internal static unsafe delegate* GetTextNodeTextICall; + internal static unsafe delegate* unmanaged SetTextNodeTextICall; + internal static unsafe delegate* unmanaged GetTextNodeTextICall; public string Text { diff --git a/NuakeNet/src/main.cs b/NuakeNet/src/main.cs index 733334de..777e9e12 100644 --- a/NuakeNet/src/main.cs +++ b/NuakeNet/src/main.cs @@ -17,9 +17,9 @@ namespace Nuake.Net /// public class Engine { - internal static unsafe delegate* LoggerLogIcall; - internal static unsafe delegate* LoadSceneIcall; - internal static unsafe delegate*> GetSubsystemByNameIcall; + internal static unsafe delegate* unmanaged LoggerLogIcall; + internal static unsafe delegate* unmanaged LoadSceneIcall; + internal static unsafe delegate* unmanaged> GetSubsystemByNameIcall; public Engine() { } @@ -147,14 +147,14 @@ public PointScript(string description = "") public class Debug { - internal static unsafe delegate* DrawLineIcall; - internal static unsafe delegate* DrawShapeBoxIcall; - internal static unsafe delegate* DrawShapeSphereIcall; - internal static unsafe delegate* DrawShapeCylinderIcall; - internal static unsafe delegate*