First Commit on new Git-Base, yey!

This commit is contained in:
2026-01-22 12:30:53 -05:00
parent 2061d588e7
commit 303b835ba7
93 changed files with 17252 additions and 1138 deletions

282
Scripts/AnimationWindow.cpp Normal file
View File

@@ -0,0 +1,282 @@
#include "ScriptRuntime.h"
#include "SceneObject.h"
#include "ThirdParty/imgui/imgui.h"
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
namespace {
struct Keyframe {
float time = 0.0f;
glm::vec3 position = glm::vec3(0.0f);
glm::vec3 rotation = glm::vec3(0.0f);
glm::vec3 scale = glm::vec3(1.0f);
};
int targetId = -1;
char targetName[128] = "";
std::vector<Keyframe> keyframes;
int selectedKey = -1;
float clipLength = 2.0f;
float currentTime = 0.0f;
float playSpeed = 1.0f;
bool isPlaying = false;
bool loop = true;
bool applyOnScrub = true;
glm::vec3 lerpVec3(const glm::vec3& a, const glm::vec3& b, float t) {
return a + (b - a) * t;
}
float clampFloat(float value, float minValue, float maxValue) {
return std::max(minValue, std::min(value, maxValue));
}
SceneObject* resolveTarget(ScriptContext& ctx) {
if (targetId >= 0) {
if (auto* obj = ctx.FindObjectById(targetId)) {
return obj;
}
}
if (targetName[0] != '\0') {
if (auto* obj = ctx.FindObjectByName(targetName)) {
targetId = obj->id;
return obj;
}
}
return nullptr;
}
void syncTargetLabel(SceneObject* obj) {
if (!obj) return;
strncpy(targetName, obj->name.c_str(), sizeof(targetName) - 1);
targetName[sizeof(targetName) - 1] = '\0';
}
void captureKeyframe(SceneObject& obj, float time) {
float clamped = clampFloat(time, 0.0f, clipLength);
auto it = std::find_if(keyframes.begin(), keyframes.end(),
[&](const Keyframe& k) { return std::abs(k.time - clamped) < 0.0001f; });
if (it == keyframes.end()) {
keyframes.push_back(Keyframe{clamped, obj.position, obj.rotation, obj.scale});
} else {
it->position = obj.position;
it->rotation = obj.rotation;
it->scale = obj.scale;
}
std::sort(keyframes.begin(), keyframes.end(),
[](const Keyframe& a, const Keyframe& b) { return a.time < b.time; });
}
void deleteKeyframe(int index) {
if (index < 0 || index >= static_cast<int>(keyframes.size())) return;
keyframes.erase(keyframes.begin() + index);
if (selectedKey == index) selectedKey = -1;
if (selectedKey > index) selectedKey--;
}
void applyPoseAtTime(ScriptContext& ctx, SceneObject& obj, float time) {
if (keyframes.empty()) return;
if (time <= keyframes.front().time) {
ctx.SetPosition(keyframes.front().position);
ctx.SetRotation(keyframes.front().rotation);
ctx.SetScale(keyframes.front().scale);
ctx.MarkDirty();
return;
}
if (time >= keyframes.back().time) {
ctx.SetPosition(keyframes.back().position);
ctx.SetRotation(keyframes.back().rotation);
ctx.SetScale(keyframes.back().scale);
ctx.MarkDirty();
return;
}
for (size_t i = 0; i + 1 < keyframes.size(); ++i) {
const Keyframe& a = keyframes[i];
const Keyframe& b = keyframes[i + 1];
if (time >= a.time && time <= b.time) {
float span = b.time - a.time;
float t = (span > 0.0f) ? (time - a.time) / span : 0.0f;
ctx.SetPosition(lerpVec3(a.position, b.position, t));
ctx.SetRotation(lerpVec3(a.rotation, b.rotation, t));
ctx.SetScale(lerpVec3(a.scale, b.scale, t));
ctx.MarkDirty();
return;
}
}
}
void drawTimeline(float& time, float length, int& selection) {
ImVec2 size = ImVec2(ImGui::GetContentRegionAvail().x, 70.0f);
ImVec2 start = ImGui::GetCursorScreenPos();
ImGui::InvisibleButton("Timeline", size);
ImDrawList* draw = ImGui::GetWindowDrawList();
ImU32 bg = ImGui::GetColorU32(ImGuiCol_FrameBg);
ImU32 border = ImGui::GetColorU32(ImGuiCol_Border);
ImU32 accent = ImGui::GetColorU32(ImGuiCol_CheckMark);
ImU32 keyColor = ImGui::GetColorU32(ImGuiCol_SliderGrab);
draw->AddRectFilled(start, ImVec2(start.x + size.x, start.y + size.y), bg, 6.0f);
draw->AddRect(start, ImVec2(start.x + size.x, start.y + size.y), border, 6.0f);
float clamped = clampFloat(time, 0.0f, length);
float playheadX = start.x + (length > 0.0f ? (clamped / length) * size.x : 0.0f);
draw->AddLine(ImVec2(playheadX, start.y), ImVec2(playheadX, start.y + size.y), accent, 2.0f);
for (size_t i = 0; i < keyframes.size(); ++i) {
float keyX = start.x + (length > 0.0f ? (keyframes[i].time / length) * size.x : 0.0f);
ImVec2 center(keyX, start.y + size.y * 0.5f);
float radius = (selection == static_cast<int>(i)) ? 6.0f : 4.5f;
draw->AddCircleFilled(center, radius, keyColor);
ImRect hit(ImVec2(center.x - 7.0f, center.y - 7.0f), ImVec2(center.x + 7.0f, center.y + 7.0f));
if (ImGui::IsMouseHoveringRect(hit.Min, hit.Max) && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
selection = static_cast<int>(i);
time = keyframes[i].time;
}
}
if (ImGui::IsItemActive() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
float mouseX = ImGui::GetIO().MousePos.x;
float t = (mouseX - start.x) / size.x;
time = clampFloat(t * length, 0.0f, length);
}
}
void drawKeyframeTable() {
if (keyframes.empty()) {
ImGui::TextDisabled("No keyframes yet.");
return;
}
if (ImGui::BeginTable("KeyframeTable", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) {
ImGui::TableSetupColumn("Time");
ImGui::TableSetupColumn("Position");
ImGui::TableSetupColumn("Rotation");
ImGui::TableSetupColumn("Scale");
ImGui::TableHeadersRow();
for (size_t i = 0; i < keyframes.size(); ++i) {
const auto& key = keyframes[i];
ImGui::TableNextRow();
ImGui::TableNextColumn();
bool selected = selectedKey == static_cast<int>(i);
std::string label = std::to_string(key.time);
if (ImGui::Selectable(label.c_str(), selected, ImGuiSelectableFlags_SpanAllColumns)) {
selectedKey = static_cast<int>(i);
currentTime = key.time;
}
ImGui::TableNextColumn();
ImGui::Text("%.2f, %.2f, %.2f", key.position.x, key.position.y, key.position.z);
ImGui::TableNextColumn();
ImGui::Text("%.2f, %.2f, %.2f", key.rotation.x, key.rotation.y, key.rotation.z);
ImGui::TableNextColumn();
ImGui::Text("%.2f, %.2f, %.2f", key.scale.x, key.scale.y, key.scale.z);
}
ImGui::EndTable();
}
}
} // namespace
extern "C" void RenderEditorWindow(ScriptContext& ctx) {
ImGui::TextUnformatted("Simple Animation");
ImGui::Separator();
SceneObject* selectedObj = ctx.object;
SceneObject* targetObj = resolveTarget(ctx);
ImGui::TextDisabled("Select a GameObject to animate:");
ImGui::BeginDisabled();
ImGui::InputText("##TargetName", targetName, sizeof(targetName));
ImGui::EndDisabled();
ImGui::SameLine();
if (ImGui::Button("Use Selected") && selectedObj) {
targetId = selectedObj->id;
syncTargetLabel(selectedObj);
}
ImGui::SameLine();
if (ImGui::Button("Clear")) {
targetId = -1;
targetName[0] = '\0';
targetObj = nullptr;
}
ImGui::Spacing();
if (ImGui::BeginTabBar("AnimModeTabs")) {
if (ImGui::BeginTabItem("Pose Mode")) {
ImGui::TextDisabled("Pose Editor");
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6.0f);
if (ImGui::Button("Key")) {
if (targetObj) captureKeyframe(*targetObj, currentTime);
}
ImGui::SameLine();
if (ImGui::Button("Delete") && selectedKey >= 0) {
deleteKeyframe(selectedKey);
}
ImGui::PopStyleVar();
ImGui::Spacing();
drawTimeline(currentTime, clipLength, selectedKey);
ImGui::SliderFloat("Time", &currentTime, 0.0f, clipLength, "%.2fs");
ImGui::Spacing();
drawKeyframeTable();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Config Mode")) {
ImGui::TextDisabled("Playback");
ImGui::Separator();
ImGui::Checkbox("Loop", &loop);
ImGui::Checkbox("Apply On Scrub", &applyOnScrub);
ImGui::SliderFloat("Length", &clipLength, 0.1f, 20.0f, "%.2fs");
ImGui::SliderFloat("Speed", &playSpeed, 0.1f, 4.0f, "%.2fx");
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::Spacing();
ImGui::Separator();
ImGui::TextDisabled("Transport");
if (ImGui::Button(isPlaying ? "Pause" : "Play")) {
isPlaying = !isPlaying;
}
ImGui::SameLine();
if (ImGui::Button("Stop")) {
isPlaying = false;
currentTime = 0.0f;
}
if (targetObj) {
ImGui::SameLine();
ImGui::TextDisabled("Target: %s", targetObj->name.c_str());
} else {
ImGui::TextDisabled("No target selected.");
}
if (isPlaying && clipLength > 0.0f) {
currentTime += ImGui::GetIO().DeltaTime * playSpeed;
if (currentTime > clipLength) {
if (loop) currentTime = std::fmod(currentTime, clipLength);
else {
currentTime = clipLength;
isPlaying = false;
}
}
}
if (targetObj && (isPlaying || applyOnScrub)) {
applyPoseAtTime(ctx, *targetObj, currentTime);
}
}
extern "C" void ExitRenderEditorWindow(ScriptContext& ctx) {
(void)ctx;
}

297
Scripts/Managed/ModuCPP.cs Normal file
View File

@@ -0,0 +1,297 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace ModuCPP {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ScriptTickDelegate(IntPtr ctx, float deltaTime);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ScriptInspectorDelegate(IntPtr ctx);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void SetNativeApiDelegate(IntPtr apiPtr);
[StructLayout(LayoutKind.Sequential)]
public struct Vec3 {
public float X;
public float Y;
public float Z;
public Vec3(float x, float y, float z) {
X = x;
Y = y;
Z = z;
}
public static Vec3 operator +(Vec3 a, Vec3 b) => new Vec3(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
public static Vec3 operator -(Vec3 a, Vec3 b) => new Vec3(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
public static Vec3 operator *(Vec3 a, float s) => new Vec3(a.X * s, a.Y * s, a.Z * s);
}
public enum ConsoleMessageType {
Info = 0,
Warning = 1,
Error = 2,
Success = 3
}
[StructLayout(LayoutKind.Sequential)]
public struct NativeApi {
public uint Version;
public IntPtr GetObjectId;
public IntPtr GetPosition;
public IntPtr SetPosition;
public IntPtr GetRotation;
public IntPtr SetRotation;
public IntPtr GetScale;
public IntPtr SetScale;
public IntPtr HasRigidbody;
public IntPtr EnsureRigidbody;
public IntPtr SetRigidbodyVelocity;
public IntPtr GetRigidbodyVelocity;
public IntPtr AddRigidbodyForce;
public IntPtr AddRigidbodyImpulse;
public IntPtr GetSettingFloat;
public IntPtr GetSettingBool;
public IntPtr GetSettingString;
public IntPtr SetSettingFloat;
public IntPtr SetSettingBool;
public IntPtr SetSettingString;
public IntPtr AddConsoleMessage;
}
internal unsafe static class Native {
public static NativeApi Api;
public static GetObjectIdFn GetObjectId;
public static GetPositionFn GetPosition;
public static SetPositionFn SetPosition;
public static GetRotationFn GetRotation;
public static SetRotationFn SetRotation;
public static GetScaleFn GetScale;
public static SetScaleFn SetScale;
public static HasRigidbodyFn HasRigidbody;
public static EnsureRigidbodyFn EnsureRigidbody;
public static SetRigidbodyVelocityFn SetRigidbodyVelocity;
public static GetRigidbodyVelocityFn GetRigidbodyVelocity;
public static AddRigidbodyForceFn AddRigidbodyForce;
public static AddRigidbodyImpulseFn AddRigidbodyImpulse;
public static GetSettingFloatFn GetSettingFloat;
public static GetSettingBoolFn GetSettingBool;
public static GetSettingStringFn GetSettingString;
public static SetSettingFloatFn SetSettingFloat;
public static SetSettingBoolFn SetSettingBool;
public static SetSettingStringFn SetSettingString;
public static AddConsoleMessageFn AddConsoleMessage;
public static void BindDelegates() {
GetObjectId = Marshal.GetDelegateForFunctionPointer<GetObjectIdFn>(Api.GetObjectId);
GetPosition = Marshal.GetDelegateForFunctionPointer<GetPositionFn>(Api.GetPosition);
SetPosition = Marshal.GetDelegateForFunctionPointer<SetPositionFn>(Api.SetPosition);
GetRotation = Marshal.GetDelegateForFunctionPointer<GetRotationFn>(Api.GetRotation);
SetRotation = Marshal.GetDelegateForFunctionPointer<SetRotationFn>(Api.SetRotation);
GetScale = Marshal.GetDelegateForFunctionPointer<GetScaleFn>(Api.GetScale);
SetScale = Marshal.GetDelegateForFunctionPointer<SetScaleFn>(Api.SetScale);
HasRigidbody = Marshal.GetDelegateForFunctionPointer<HasRigidbodyFn>(Api.HasRigidbody);
EnsureRigidbody = Marshal.GetDelegateForFunctionPointer<EnsureRigidbodyFn>(Api.EnsureRigidbody);
SetRigidbodyVelocity = Marshal.GetDelegateForFunctionPointer<SetRigidbodyVelocityFn>(Api.SetRigidbodyVelocity);
GetRigidbodyVelocity = Marshal.GetDelegateForFunctionPointer<GetRigidbodyVelocityFn>(Api.GetRigidbodyVelocity);
AddRigidbodyForce = Marshal.GetDelegateForFunctionPointer<AddRigidbodyForceFn>(Api.AddRigidbodyForce);
AddRigidbodyImpulse = Marshal.GetDelegateForFunctionPointer<AddRigidbodyImpulseFn>(Api.AddRigidbodyImpulse);
GetSettingFloat = Marshal.GetDelegateForFunctionPointer<GetSettingFloatFn>(Api.GetSettingFloat);
GetSettingBool = Marshal.GetDelegateForFunctionPointer<GetSettingBoolFn>(Api.GetSettingBool);
GetSettingString = Marshal.GetDelegateForFunctionPointer<GetSettingStringFn>(Api.GetSettingString);
SetSettingFloat = Marshal.GetDelegateForFunctionPointer<SetSettingFloatFn>(Api.SetSettingFloat);
SetSettingBool = Marshal.GetDelegateForFunctionPointer<SetSettingBoolFn>(Api.SetSettingBool);
SetSettingString = Marshal.GetDelegateForFunctionPointer<SetSettingStringFn>(Api.SetSettingString);
AddConsoleMessage = Marshal.GetDelegateForFunctionPointer<AddConsoleMessageFn>(Api.AddConsoleMessage);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int GetObjectIdFn(IntPtr ctx);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void GetPositionFn(IntPtr ctx, float* x, float* y, float* z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetPositionFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void GetRotationFn(IntPtr ctx, float* x, float* y, float* z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetRotationFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void GetScaleFn(IntPtr ctx, float* x, float* y, float* z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetScaleFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int HasRigidbodyFn(IntPtr ctx);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int EnsureRigidbodyFn(IntPtr ctx, int useGravity, int kinematic);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int SetRigidbodyVelocityFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int GetRigidbodyVelocityFn(IntPtr ctx, float* x, float* y, float* z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AddRigidbodyForceFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int AddRigidbodyImpulseFn(IntPtr ctx, float x, float y, float z);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate float GetSettingFloatFn(IntPtr ctx, byte* key, float fallback);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate int GetSettingBoolFn(IntPtr ctx, byte* key, int fallback);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void GetSettingStringFn(IntPtr ctx, byte* key, byte* fallback, byte* outBuffer, int outBufferSize);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetSettingFloatFn(IntPtr ctx, byte* key, float value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetSettingBoolFn(IntPtr ctx, byte* key, int value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SetSettingStringFn(IntPtr ctx, byte* key, byte* value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void AddConsoleMessageFn(IntPtr ctx, byte* message, int type);
}
public static unsafe class Host {
public static void SetNativeApi(IntPtr apiPtr) {
Native.Api = Marshal.PtrToStructure<NativeApi>(apiPtr);
Native.BindDelegates();
}
}
public readonly unsafe struct Context {
private readonly IntPtr handle;
public Context(IntPtr ctx) {
handle = ctx;
}
public int ObjectId => Native.GetObjectId(handle);
public Vec3 Position {
get {
float x = 0f, y = 0f, z = 0f;
Native.GetPosition(handle, &x, &y, &z);
return new Vec3(x, y, z);
}
set {
Native.SetPosition(handle, value.X, value.Y, value.Z);
}
}
public Vec3 Rotation {
get {
float x = 0f, y = 0f, z = 0f;
Native.GetRotation(handle, &x, &y, &z);
return new Vec3(x, y, z);
}
set {
Native.SetRotation(handle, value.X, value.Y, value.Z);
}
}
public Vec3 Scale {
get {
float x = 0f, y = 0f, z = 0f;
Native.GetScale(handle, &x, &y, &z);
return new Vec3(x, y, z);
}
set {
Native.SetScale(handle, value.X, value.Y, value.Z);
}
}
public bool HasRigidbody => Native.HasRigidbody(handle) != 0;
public bool EnsureRigidbody(bool useGravity = true, bool kinematic = false) {
return Native.EnsureRigidbody(handle, useGravity ? 1 : 0, kinematic ? 1 : 0) != 0;
}
public Vec3 RigidbodyVelocity {
get {
float x = 0f, y = 0f, z = 0f;
if (Native.GetRigidbodyVelocity(handle, &x, &y, &z) == 0) {
return new Vec3(0f, 0f, 0f);
}
return new Vec3(x, y, z);
}
set {
Native.SetRigidbodyVelocity(handle, value.X, value.Y, value.Z);
}
}
public void AddRigidbodyForce(Vec3 force) {
Native.AddRigidbodyForce(handle, force.X, force.Y, force.Z);
}
public void AddRigidbodyImpulse(Vec3 impulse) {
Native.AddRigidbodyImpulse(handle, impulse.X, impulse.Y, impulse.Z);
}
public float GetSettingFloat(string key, float fallback = 0f) {
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
fixed (byte* keyPtr = keyBytes) {
return Native.GetSettingFloat(handle, keyPtr, fallback);
}
}
public bool GetSettingBool(string key, bool fallback = false) {
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
fixed (byte* keyPtr = keyBytes) {
int value = Native.GetSettingBool(handle, keyPtr, fallback ? 1 : 0);
return value != 0;
}
}
public string GetSettingString(string key, string fallback = "") {
const int bufferSize = 256;
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
byte[] fallbackBytes = Encoding.UTF8.GetBytes((fallback ?? string.Empty) + "\0");
byte* buffer = stackalloc byte[bufferSize];
fixed (byte* keyPtr = keyBytes)
fixed (byte* fallbackPtr = fallbackBytes) {
Native.GetSettingString(handle, keyPtr, fallbackPtr, buffer, bufferSize);
}
return FromUtf8(buffer);
}
public void SetSettingFloat(string key, float value) {
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
fixed (byte* keyPtr = keyBytes) {
Native.SetSettingFloat(handle, keyPtr, value);
}
}
public void SetSettingBool(string key, bool value) {
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
fixed (byte* keyPtr = keyBytes) {
Native.SetSettingBool(handle, keyPtr, value ? 1 : 0);
}
}
public void SetSettingString(string key, string value) {
byte[] keyBytes = Encoding.UTF8.GetBytes((key ?? string.Empty) + "\0");
byte[] valueBytes = Encoding.UTF8.GetBytes((value ?? string.Empty) + "\0");
fixed (byte* keyPtr = keyBytes)
fixed (byte* valuePtr = valueBytes) {
Native.SetSettingString(handle, keyPtr, valuePtr);
}
}
public void AddConsoleMessage(string message, ConsoleMessageType type = ConsoleMessageType.Info) {
byte[] msgBytes = Encoding.UTF8.GetBytes((message ?? string.Empty) + "\0");
fixed (byte* msgPtr = msgBytes) {
Native.AddConsoleMessage(handle, msgPtr, (int)type);
}
}
private static string FromUtf8(byte* ptr) {
if (ptr == null) return string.Empty;
int length = 0;
while (ptr[length] != 0) {
length++;
}
if (length == 0) return string.Empty;
byte[] bytes = new byte[length];
Marshal.Copy((IntPtr)ptr, bytes, 0, length);
return Encoding.UTF8.GetString(bytes);
}
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,68 @@
using System;
namespace ModuCPP {
public static class SampleInspector {
private static bool autoRotate = false;
private static Vec3 spinSpeed = new Vec3(0f, 45f, 0f);
private static Vec3 offset = new Vec3(0f, 1f, 0f);
private static string targetName = "MyTarget"; // Stored for parity; object lookup API not wired yet.
private static void LoadSettings(Context context) {
autoRotate = context.GetSettingBool("autoRotate", autoRotate);
spinSpeed = new Vec3(
context.GetSettingFloat("spinSpeedX", spinSpeed.X),
context.GetSettingFloat("spinSpeedY", spinSpeed.Y),
context.GetSettingFloat("spinSpeedZ", spinSpeed.Z)
);
offset = new Vec3(
context.GetSettingFloat("offsetX", offset.X),
context.GetSettingFloat("offsetY", offset.Y),
context.GetSettingFloat("offsetZ", offset.Z)
);
targetName = context.GetSettingString("targetName", targetName);
}
private static void SaveSettings(Context context) {
context.SetSettingBool("autoRotate", autoRotate);
context.SetSettingFloat("spinSpeedX", spinSpeed.X);
context.SetSettingFloat("spinSpeedY", spinSpeed.Y);
context.SetSettingFloat("spinSpeedZ", spinSpeed.Z);
context.SetSettingFloat("offsetX", offset.X);
context.SetSettingFloat("offsetY", offset.Y);
context.SetSettingFloat("offsetZ", offset.Z);
context.SetSettingString("targetName", targetName);
}
private static void ApplyAutoRotate(Context context, float deltaTime) {
if (!autoRotate) return;
context.Rotation = context.Rotation + (spinSpeed * deltaTime);
}
public static void Script_Begin(IntPtr ctx, float deltaTime) {
var context = new Context(ctx);
LoadSettings(context);
SaveSettings(context);
context.EnsureRigidbody(useGravity: true, kinematic: false);
context.AddConsoleMessage("Managed script begin (C#)", ConsoleMessageType.Info);
}
public static void Script_OnInspector(IntPtr ctx) {
var context = new Context(ctx);
LoadSettings(context);
SaveSettings(context);
context.AddConsoleMessage("Managed inspector hook (no UI yet)", ConsoleMessageType.Info);
}
public static void Script_Spec(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
public static void Script_TestEditor(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
public static void Script_TickUpdate(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
namespace ModuCPP {
public static class SampleInspectorManaged {
private static bool autoRotate = false;
private static Vec3 spinSpeed = new Vec3(0f, 45f, 0f);
private static Vec3 offset = new Vec3(0f, 1f, 0f);
private static string targetName = "MyTarget"; // Stored for parity; object lookup API not wired yet.
private static void LoadSettings(Context context) {
autoRotate = context.GetSettingBool("autoRotate", autoRotate);
spinSpeed = new Vec3(
context.GetSettingFloat("spinSpeedX", spinSpeed.X),
context.GetSettingFloat("spinSpeedY", spinSpeed.Y),
context.GetSettingFloat("spinSpeedZ", spinSpeed.Z)
);
offset = new Vec3(
context.GetSettingFloat("offsetX", offset.X),
context.GetSettingFloat("offsetY", offset.Y),
context.GetSettingFloat("offsetZ", offset.Z)
);
targetName = context.GetSettingString("targetName", targetName);
}
private static void SaveSettings(Context context) {
context.SetSettingBool("autoRotate", autoRotate);
context.SetSettingFloat("spinSpeedX", spinSpeed.X);
context.SetSettingFloat("spinSpeedY", spinSpeed.Y);
context.SetSettingFloat("spinSpeedZ", spinSpeed.Z);
context.SetSettingFloat("offsetX", offset.X);
context.SetSettingFloat("offsetY", offset.Y);
context.SetSettingFloat("offsetZ", offset.Z);
context.SetSettingString("targetName", targetName);
}
private static void ApplyAutoRotate(Context context, float deltaTime) {
if (!autoRotate) return;
context.Rotation = context.Rotation + (spinSpeed * deltaTime);
}
public static void Script_Begin(IntPtr ctx, float deltaTime) {
var context = new Context(ctx);
LoadSettings(context);
SaveSettings(context);
context.EnsureRigidbody(useGravity: true, kinematic: false);
context.AddConsoleMessage("Managed script begin (C#)", ConsoleMessageType.Info);
}
public static void Script_OnInspector(IntPtr ctx) {
var context = new Context(ctx);
LoadSettings(context);
SaveSettings(context);
context.AddConsoleMessage("Managed inspector hook (no UI yet)", ConsoleMessageType.Info);
}
public static void Script_Spec(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
public static void Script_TestEditor(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
public static void Script_TickUpdate(IntPtr ctx, float deltaTime) {
ApplyAutoRotate(new Context(ctx), deltaTime);
}
}
}

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v10.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v10.0": {
"ModuCPP/1.0.0": {
"runtime": {
"ModuCPP.dll": {}
}
}
}
},
"libraries": {
"ModuCPP/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,14 @@
{
"runtimeOptions": {
"tfm": "net10.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "10.0.0"
},
"configProperties": {
"System.Runtime.InteropServices.EnableComHosting": false,
"System.Runtime.InteropServices.BuiltInComInterop": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,24 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"ModuCPP/1.0.0": {
"runtime": {
"ModuCPP.dll": {}
}
}
}
},
"libraries": {
"ModuCPP/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2061d588e7a10416f073bb34ad8bda8e068f291b")]
[assembly: System.Reflection.AssemblyProductAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyTitleAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
78499018a8a6914630a79de98a62c3a139d45e8a04deb724bf7e5060d9670375

View File

@@ -0,0 +1,17 @@
is_global = true
build_property.TargetFramework = net10.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v10.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = ModuCPP
build_property.ProjectDir = /home/anemunt/Git-base/Modularity/Scripts/Managed/
build_property.EnableComHosting = false
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 10.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Threading;
global using System.Threading.Tasks;

Binary file not shown.

View File

@@ -0,0 +1 @@
0579f849781bddafc2e55261290008c5a7fb6bddd064d155e3e9c2dd44aec502

View File

@@ -0,0 +1,14 @@
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/net10.0/ModuCPP.deps.json
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/net10.0/ModuCPP.runtimeconfig.json
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/net10.0/ModuCPP.dll
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/net10.0/ModuCPP.pdb
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.GeneratedMSBuildEditorConfig.editorconfig
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.AssemblyInfoInputs.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.AssemblyInfo.cs
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.csproj.CoreCompileInputs.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.sourcelink.json
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.dll
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/refint/ModuCPP.dll
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.pdb
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ModuCPP.genruntimeconfig.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/net10.0/ref/ModuCPP.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
b14c7a505f46d8314ef755360e8bbee5cc4a67ee7d033805e0a7f8e8d9b71b40

Binary file not shown.

View File

@@ -0,0 +1 @@
{"documents":{"/home/anemunt/Git-base/Modularity/src/ThirdParty/PhysX/*":"https://raw.githubusercontent.com/NVIDIA-Omniverse/PhysX/09ff24f3279b735e672ff27b155cbf49f6296f4d/*"}}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2061d588e7a10416f073bb34ad8bda8e068f291b")]
[assembly: System.Reflection.AssemblyProductAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyTitleAttribute("ModuCPP")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
78499018a8a6914630a79de98a62c3a139d45e8a04deb724bf7e5060d9670375

View File

@@ -0,0 +1,8 @@
is_global = true
build_property.RootNamespace = ModuCPP
build_property.ProjectDir = /home/anemunt/Git-base/Modularity/Scripts/Managed/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.CsWinRTUseWindowsUIXamlProjections = false
build_property.EffectiveAnalysisLevelStyle =
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Threading;
global using System.Threading.Tasks;

View File

@@ -0,0 +1 @@
12a173d9ad34d74a13f6f07a58c9a75f8033484b726d3271d6b9bdffb23c227b

View File

@@ -0,0 +1,11 @@
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.csproj.AssemblyReference.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.GeneratedMSBuildEditorConfig.editorconfig
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.AssemblyInfoInputs.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.AssemblyInfo.cs
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.csproj.CoreCompileInputs.cache
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.sourcelink.json
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/netstandard2.0/ModuCPP.deps.json
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/netstandard2.0/ModuCPP.dll
/home/anemunt/Git-base/Modularity/Scripts/Managed/bin/Debug/netstandard2.0/ModuCPP.pdb
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.dll
/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/Debug/netstandard2.0/ModuCPP.pdb

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
{"documents":{"/home/anemunt/Git-base/Modularity/src/ThirdParty/PhysX/*":"https://raw.githubusercontent.com/NVIDIA-Omniverse/PhysX/09ff24f3279b735e672ff27b155cbf49f6296f4d/*"}}

View File

@@ -0,0 +1,70 @@
{
"format": 1,
"restore": {
"/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj": {}
},
"projects": {
"/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj",
"projectName": "ModuCPP",
"projectPath": "/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj",
"packagesPath": "/home/anemunt/.nuget/packages/",
"outputPath": "/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/anemunt/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netstandard2.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"dependencies": {
"NETStandard.Library": {
"suppressParent": "All",
"target": "Package",
"version": "[2.0.3, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/10.0.100/RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/anemunt/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/anemunt/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/anemunt/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets')" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,247 @@
{
"version": 3,
"targets": {
".NETStandard,Version=v2.0": {
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"compile": {
"lib/netstandard1.0/_._": {}
},
"runtime": {
"lib/netstandard1.0/_._": {}
}
},
"NETStandard.Library/2.0.3": {
"type": "package",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
},
"compile": {
"lib/netstandard1.0/_._": {}
},
"runtime": {
"lib/netstandard1.0/_._": {}
},
"build": {
"build/netstandard2.0/NETStandard.Library.targets": {}
}
}
}
},
"libraries": {
"Microsoft.NETCore.Platforms/1.1.0": {
"sha512": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"type": "package",
"path": "microsoft.netcore.platforms/1.1.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/netstandard1.0/_._",
"microsoft.netcore.platforms.1.1.0.nupkg.sha512",
"microsoft.netcore.platforms.nuspec",
"runtime.json"
]
},
"NETStandard.Library/2.0.3": {
"sha512": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"type": "package",
"path": "netstandard.library/2.0.3",
"files": [
".nupkg.metadata",
".signature.p7s",
"LICENSE.TXT",
"THIRD-PARTY-NOTICES.TXT",
"build/netstandard2.0/NETStandard.Library.targets",
"build/netstandard2.0/ref/Microsoft.Win32.Primitives.dll",
"build/netstandard2.0/ref/System.AppContext.dll",
"build/netstandard2.0/ref/System.Collections.Concurrent.dll",
"build/netstandard2.0/ref/System.Collections.NonGeneric.dll",
"build/netstandard2.0/ref/System.Collections.Specialized.dll",
"build/netstandard2.0/ref/System.Collections.dll",
"build/netstandard2.0/ref/System.ComponentModel.Composition.dll",
"build/netstandard2.0/ref/System.ComponentModel.EventBasedAsync.dll",
"build/netstandard2.0/ref/System.ComponentModel.Primitives.dll",
"build/netstandard2.0/ref/System.ComponentModel.TypeConverter.dll",
"build/netstandard2.0/ref/System.ComponentModel.dll",
"build/netstandard2.0/ref/System.Console.dll",
"build/netstandard2.0/ref/System.Core.dll",
"build/netstandard2.0/ref/System.Data.Common.dll",
"build/netstandard2.0/ref/System.Data.dll",
"build/netstandard2.0/ref/System.Diagnostics.Contracts.dll",
"build/netstandard2.0/ref/System.Diagnostics.Debug.dll",
"build/netstandard2.0/ref/System.Diagnostics.FileVersionInfo.dll",
"build/netstandard2.0/ref/System.Diagnostics.Process.dll",
"build/netstandard2.0/ref/System.Diagnostics.StackTrace.dll",
"build/netstandard2.0/ref/System.Diagnostics.TextWriterTraceListener.dll",
"build/netstandard2.0/ref/System.Diagnostics.Tools.dll",
"build/netstandard2.0/ref/System.Diagnostics.TraceSource.dll",
"build/netstandard2.0/ref/System.Diagnostics.Tracing.dll",
"build/netstandard2.0/ref/System.Drawing.Primitives.dll",
"build/netstandard2.0/ref/System.Drawing.dll",
"build/netstandard2.0/ref/System.Dynamic.Runtime.dll",
"build/netstandard2.0/ref/System.Globalization.Calendars.dll",
"build/netstandard2.0/ref/System.Globalization.Extensions.dll",
"build/netstandard2.0/ref/System.Globalization.dll",
"build/netstandard2.0/ref/System.IO.Compression.FileSystem.dll",
"build/netstandard2.0/ref/System.IO.Compression.ZipFile.dll",
"build/netstandard2.0/ref/System.IO.Compression.dll",
"build/netstandard2.0/ref/System.IO.FileSystem.DriveInfo.dll",
"build/netstandard2.0/ref/System.IO.FileSystem.Primitives.dll",
"build/netstandard2.0/ref/System.IO.FileSystem.Watcher.dll",
"build/netstandard2.0/ref/System.IO.FileSystem.dll",
"build/netstandard2.0/ref/System.IO.IsolatedStorage.dll",
"build/netstandard2.0/ref/System.IO.MemoryMappedFiles.dll",
"build/netstandard2.0/ref/System.IO.Pipes.dll",
"build/netstandard2.0/ref/System.IO.UnmanagedMemoryStream.dll",
"build/netstandard2.0/ref/System.IO.dll",
"build/netstandard2.0/ref/System.Linq.Expressions.dll",
"build/netstandard2.0/ref/System.Linq.Parallel.dll",
"build/netstandard2.0/ref/System.Linq.Queryable.dll",
"build/netstandard2.0/ref/System.Linq.dll",
"build/netstandard2.0/ref/System.Net.Http.dll",
"build/netstandard2.0/ref/System.Net.NameResolution.dll",
"build/netstandard2.0/ref/System.Net.NetworkInformation.dll",
"build/netstandard2.0/ref/System.Net.Ping.dll",
"build/netstandard2.0/ref/System.Net.Primitives.dll",
"build/netstandard2.0/ref/System.Net.Requests.dll",
"build/netstandard2.0/ref/System.Net.Security.dll",
"build/netstandard2.0/ref/System.Net.Sockets.dll",
"build/netstandard2.0/ref/System.Net.WebHeaderCollection.dll",
"build/netstandard2.0/ref/System.Net.WebSockets.Client.dll",
"build/netstandard2.0/ref/System.Net.WebSockets.dll",
"build/netstandard2.0/ref/System.Net.dll",
"build/netstandard2.0/ref/System.Numerics.dll",
"build/netstandard2.0/ref/System.ObjectModel.dll",
"build/netstandard2.0/ref/System.Reflection.Extensions.dll",
"build/netstandard2.0/ref/System.Reflection.Primitives.dll",
"build/netstandard2.0/ref/System.Reflection.dll",
"build/netstandard2.0/ref/System.Resources.Reader.dll",
"build/netstandard2.0/ref/System.Resources.ResourceManager.dll",
"build/netstandard2.0/ref/System.Resources.Writer.dll",
"build/netstandard2.0/ref/System.Runtime.CompilerServices.VisualC.dll",
"build/netstandard2.0/ref/System.Runtime.Extensions.dll",
"build/netstandard2.0/ref/System.Runtime.Handles.dll",
"build/netstandard2.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll",
"build/netstandard2.0/ref/System.Runtime.InteropServices.dll",
"build/netstandard2.0/ref/System.Runtime.Numerics.dll",
"build/netstandard2.0/ref/System.Runtime.Serialization.Formatters.dll",
"build/netstandard2.0/ref/System.Runtime.Serialization.Json.dll",
"build/netstandard2.0/ref/System.Runtime.Serialization.Primitives.dll",
"build/netstandard2.0/ref/System.Runtime.Serialization.Xml.dll",
"build/netstandard2.0/ref/System.Runtime.Serialization.dll",
"build/netstandard2.0/ref/System.Runtime.dll",
"build/netstandard2.0/ref/System.Security.Claims.dll",
"build/netstandard2.0/ref/System.Security.Cryptography.Algorithms.dll",
"build/netstandard2.0/ref/System.Security.Cryptography.Csp.dll",
"build/netstandard2.0/ref/System.Security.Cryptography.Encoding.dll",
"build/netstandard2.0/ref/System.Security.Cryptography.Primitives.dll",
"build/netstandard2.0/ref/System.Security.Cryptography.X509Certificates.dll",
"build/netstandard2.0/ref/System.Security.Principal.dll",
"build/netstandard2.0/ref/System.Security.SecureString.dll",
"build/netstandard2.0/ref/System.ServiceModel.Web.dll",
"build/netstandard2.0/ref/System.Text.Encoding.Extensions.dll",
"build/netstandard2.0/ref/System.Text.Encoding.dll",
"build/netstandard2.0/ref/System.Text.RegularExpressions.dll",
"build/netstandard2.0/ref/System.Threading.Overlapped.dll",
"build/netstandard2.0/ref/System.Threading.Tasks.Parallel.dll",
"build/netstandard2.0/ref/System.Threading.Tasks.dll",
"build/netstandard2.0/ref/System.Threading.Thread.dll",
"build/netstandard2.0/ref/System.Threading.ThreadPool.dll",
"build/netstandard2.0/ref/System.Threading.Timer.dll",
"build/netstandard2.0/ref/System.Threading.dll",
"build/netstandard2.0/ref/System.Transactions.dll",
"build/netstandard2.0/ref/System.ValueTuple.dll",
"build/netstandard2.0/ref/System.Web.dll",
"build/netstandard2.0/ref/System.Windows.dll",
"build/netstandard2.0/ref/System.Xml.Linq.dll",
"build/netstandard2.0/ref/System.Xml.ReaderWriter.dll",
"build/netstandard2.0/ref/System.Xml.Serialization.dll",
"build/netstandard2.0/ref/System.Xml.XDocument.dll",
"build/netstandard2.0/ref/System.Xml.XPath.XDocument.dll",
"build/netstandard2.0/ref/System.Xml.XPath.dll",
"build/netstandard2.0/ref/System.Xml.XmlDocument.dll",
"build/netstandard2.0/ref/System.Xml.XmlSerializer.dll",
"build/netstandard2.0/ref/System.Xml.dll",
"build/netstandard2.0/ref/System.dll",
"build/netstandard2.0/ref/mscorlib.dll",
"build/netstandard2.0/ref/netstandard.dll",
"build/netstandard2.0/ref/netstandard.xml",
"lib/netstandard1.0/_._",
"netstandard.library.2.0.3.nupkg.sha512",
"netstandard.library.nuspec"
]
}
},
"projectFileDependencyGroups": {
".NETStandard,Version=v2.0": [
"NETStandard.Library >= 2.0.3"
]
},
"packageFolders": {
"/home/anemunt/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj",
"projectName": "ModuCPP",
"projectPath": "/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj",
"packagesPath": "/home/anemunt/.nuget/packages/",
"outputPath": "/home/anemunt/Git-base/Modularity/Scripts/Managed/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/anemunt/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netstandard2.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"dependencies": {
"NETStandard.Library": {
"suppressParent": "All",
"target": "Package",
"version": "[2.0.3, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/10.0.100/RuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,11 @@
{
"version": 2,
"dgSpecHash": "iTrhv2TT9CE=",
"success": true,
"projectFilePath": "/home/anemunt/Git-base/Modularity/Scripts/Managed/ModuCPP.csproj",
"expectedPackageFiles": [
"/home/anemunt/.nuget/packages/microsoft.netcore.platforms/1.1.0/microsoft.netcore.platforms.1.1.0.nupkg.sha512",
"/home/anemunt/.nuget/packages/netstandard.library/2.0.3/netstandard.library.2.0.3.nupkg.sha512"
],
"logs": []
}

View File

@@ -0,0 +1,74 @@
#include "ScriptRuntime.h"
#include "SceneObject.h"
#include "ThirdParty/imgui/imgui.h"
namespace {
float walkSpeed = 4.0f;
float runSpeed = 7.0f;
float acceleration = 18.0f;
float drag = 8.0f;
bool useRigidbody2D = true;
bool warnedMissingRb = false;
} // namespace
extern "C" void Script_OnInspector(ScriptContext& ctx) {
ctx.AutoSetting("walkSpeed", walkSpeed);
ctx.AutoSetting("runSpeed", runSpeed);
ctx.AutoSetting("acceleration", acceleration);
ctx.AutoSetting("drag", drag);
ctx.AutoSetting("useRigidbody2D", useRigidbody2D);
ImGui::TextUnformatted("Top Down Movement 2D");
ImGui::Separator();
ImGui::DragFloat("Walk Speed", &walkSpeed, 0.1f, 0.0f, 50.0f, "%.2f");
ImGui::DragFloat("Run Speed", &runSpeed, 0.1f, 0.0f, 80.0f, "%.2f");
ImGui::DragFloat("Acceleration", &acceleration, 0.1f, 0.0f, 200.0f, "%.2f");
ImGui::DragFloat("Drag", &drag, 0.1f, 0.0f, 200.0f, "%.2f");
ImGui::Checkbox("Use Rigidbody2D", &useRigidbody2D);
}
void TickUpdate(ScriptContext& ctx, float dt) {
if (!ctx.object || dt <= 0.0f) return;
glm::vec2 input(0.0f);
if (ImGui::IsKeyDown(ImGuiKey_W)) input.y += 1.0f;
if (ImGui::IsKeyDown(ImGuiKey_S)) input.y -= 1.0f;
if (ImGui::IsKeyDown(ImGuiKey_D)) input.x += 1.0f;
if (ImGui::IsKeyDown(ImGuiKey_A)) input.x -= 1.0f;
if (glm::length(input) > 1e-3f) input = glm::normalize(input);
float speed = ctx.IsSprintDown() ? runSpeed : walkSpeed;
glm::vec2 targetVel = input * speed;
if (useRigidbody2D) {
if (!ctx.HasRigidbody2D()) {
if (!warnedMissingRb) {
ctx.AddConsoleMessage("TopDownMovement2D: add Rigidbody2D to use velocity-based motion.", ConsoleMessageType::Warning);
warnedMissingRb = true;
}
return;
}
glm::vec2 vel(0.0f);
ctx.GetRigidbody2DVelocity(vel);
if (acceleration <= 0.0f) {
vel = targetVel;
} else {
glm::vec2 dv = targetVel - vel;
float maxDelta = acceleration * dt;
float len = glm::length(dv);
if (len > maxDelta && len > 1e-4f) {
dv *= (maxDelta / len);
}
vel += dv;
}
if (glm::length(input) < 1e-3f && drag > 0.0f) {
float damp = std::max(0.0f, 1.0f - drag * dt);
vel *= damp;
}
ctx.SetRigidbody2DVelocity(vel);
} else {
glm::vec2 pos = ctx.object->ui.position;
pos += targetVel * dt;
ctx.SetPosition2D(pos);
}
}