// ============================================================================ // RynthSuite - Plugins/Shared/RynthAiScriptApi.cs // The "RynthAi.Script" interface: what RynthAi offers a scripting plugin // (RynthLua) through the host's GetPluginInterface (API v68). Compiled into // both plugins (linked source), so the layout can't drift between them. // // Rules: // - Append-only: new functions go at the end, and Version goes up. A caller // checks StructSize before using a field past the ones it knows. // - Strings are UTF-8, NUL-terminated. A string handed back through a byte** // belongs to RynthAi and stays valid only until the next call into this // table: copy it at once. // - Call only from the plugin pump thread (OnTick and the events it drains), // never from OnChatBarEnter (AC's thread) or Render. // - Every function returns safely (no exception crosses the boundary). // ============================================================================ using System.Runtime.InteropServices; namespace RynthCore.Plugin.Shared; [StructLayout(LayoutKind.Sequential)] public unsafe struct RynthAiScriptApiV1 { public const string InterfaceName = "RynthAi.Script"; public const uint InterfaceVersion = 1; public uint Version; // InterfaceVersion of the table RynthAi filled public uint StructSize; // sizeof(RynthAiScriptApiV1) as RynthAi built it /// Evaluates a meta expression. 1 = ok (result in *result), 0 = error (message in *result). public delegate* unmanaged[Cdecl] Evaluate; /// A setting from the meta settings map (getsetting names). 1 = found. public delegate* unmanaged[Cdecl] GetSetting; /// Sets a setting and saves the profile. 1 = ok, 0 = no such setting. public delegate* unmanaged[Cdecl] SetSetting; /// Every setting name, newline separated. 1 = ok. public delegate* unmanaged[Cdecl] GetSettingNames; /// 1 while the macro is running. public delegate* unmanaged[Cdecl] IsMacroRunning; /// Starts (1) or stops (0) the macro. public delegate* unmanaged[Cdecl] SetMacroRunning; /// Walk to a spot: a one-point route, macro started. Coordinates are signed (S/W negative). 1 = ok. public delegate* unmanaged[Cdecl] NavGoTo; /// Stop navigation (and the macro when it's running). public delegate* unmanaged[Cdecl] NavStop; /// Nearest object with a position whose name contains the text. flags: 1 = portals and NPCs only. /// 1 = found (*id, *distance in metres). public delegate* unmanaged[Cdecl] FindNearest; /// Metres from the player to an object, -1 when unknown. public delegate* unmanaged[Cdecl] DistanceTo; /// Line of sight to an object: 1 clear, 0 blocked (1 when raycasting isn't ready). public delegate* unmanaged[Cdecl] IsPathClear; /// A chat line as if typed: /ra, /ub, /mt, /vt run in RynthAi now; anything else goes to AC's parser. 1 = sent. public delegate* unmanaged[Cdecl] SubmitCommand; }