summaryrefslogtreecommitdiff
path: root/Djup.Native/src/LibDjup.cs
blob: 864f330d6546b3990de292b28178266918ee71b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Runtime.InteropServices;

namespace Djup.Native;

public static partial class LibDjup
{
    const string LibraryName = "djup";

    [LibraryImport(LibraryName, EntryPoint = nameof(vec2_dot))]
    public static partial Vec2 vec2_dot(Vec2 a, Vec2 b);

    [LibraryImport(LibraryName, EntryPoint = nameof(vec2_length))]
    public static partial float vec2_length(Vec2 v);

    [LibraryImport(LibraryName, EntryPoint = nameof(vec2_normal))]
    public static partial Vec2 vec2_normal(Vec2 v);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_log_init))]
    public static partial void sim_log_init(IntPtr simulation, [MarshalAs(UnmanagedType.FunctionPtr)] LoggerDelegate logger, [MarshalAs(UnmanagedType.FunctionPtr)] AssertDelegate assert);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_set_log_level))]
    public static partial void sim_set_log_level(IntPtr simulation, LogLevel minLevel);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_create))]
    public static partial IntPtr sim_create(int snapshots, int entities);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_free))]
    public static partial void sim_free(IntPtr simulation);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_get_snapshot))]
    public unsafe static partial Snapshot* sim_get_snapshot(IntPtr simulation);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_return_snapshot))]
    public unsafe static partial void sim_return_snapshot(IntPtr simulation, Snapshot* snapshot);

    [LibraryImport(LibraryName, EntryPoint = nameof(sim_tick))]
    public unsafe static partial void sim_tick(Snapshot* current, Snapshot* next);

    [LibraryImport(LibraryName, EntryPoint = nameof(snapshot_create_entity))]
    public unsafe static partial EntityId snapshot_create_entity(Snapshot* snapshot);

    public enum ComponentAddError
    {
        None,
        InvalidArg,
        InvalidId,
        EntityNotFound
    }

    [LibraryImport(LibraryName, EntryPoint = nameof(snapshot_add_component))]
    public unsafe static partial ComponentAddError snapshot_add_component(Snapshot* snapshot, EntityId entity, Component component, void* init);

    public enum ComponentRemoveError
    {
        None,
        InvalidArg,
        InvalidId,
        EntityNotFound
    }

    [LibraryImport(LibraryName, EntryPoint = nameof(snapshot_remove_components))]
    public unsafe static partial ComponentRemoveError snapshot_remove_components(Snapshot* snapshot, EntityId entity, Components components);

    [LibraryImport(LibraryName, EntryPoint = nameof(snapshot_reset_entity))]
    public unsafe static partial ComponentRemoveError snapshot_reset_entity(Snapshot* snapshot, EntityId entity);
}