Compare commits

...

8 Commits

Author SHA1 Message Date
Marvin 49b3b472f6 fix: remap dev console toggle key to F8
Sponsor Tier Sync / sync (push) Failing after 47s
gregCore CI / build (push) Has been cancelled
- Replaced 'P' keybind with 'F8' to avoid conflicts with the default pause menu functionality in the game.

💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 07:05:23 +02:00
Marvin 21bc37f692 fix: workaround IL2CPP unstripping error in dev console
- Replaced `GUILayout.TextField` with `GUI.TextField` combined with `GUILayoutUtility.GetRect` to avoid stripped method overload exceptions in Unity 6 IL2CPP builds.

💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 06:50:29 +02:00
Marvin b9356207f0 docs: add documentation for economy player hooks
- Created `economy` category in hooks library docs
- Added pages for `greg.economy.PlayerCoinUpdated`, `greg.economy.PlayerXpUpdated`, and `greg.economy.PlayerReputationUpdated`

💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 06:48:42 +02:00
Marvin 6b0c0559f1 feat: implement additional economy hooks for player xp and reputation
- Copied new greg_hooks.json from gregExtractor to assets
- Implemented `OnXpUpdated` and `OnReputationUpdated` patches in `PlayerPatch.cs`
- Registered new harmony patches in `HookIntegration.cs`

💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 06:42:42 +02:00
Marvin f8aec26a0a fix: resolve Harmony patch error and missing hook registry
- Update PlayerPatch.cs parameters to match Harmony naming conventions (`__instance`, `_coinChhangeAmount`)
- Update Deploy-Release-ToWorkshop.ps1 to copy `greg_hooks.json` to the framework's output folder

💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 06:39:00 +02:00
Marvin 658bf080a1 fix: migrate input handling to new Unity InputSystem
💘 Generated with Crush

Assisted-by: Gemini 3.1 Pro (Optimized for Coding Agents) via Crush <crush@charm.land>
2026-04-20 06:35:27 +02:00
Marvin 1fd8938f2b fix: improve CI build robustness with better stubs and paths 2026-04-20 06:23:58 +02:00
Marvin 524eaacbd5 fix: resolve AccessViolationException by removing problematic interface patch and using native game state management 2026-04-20 06:21:56 +02:00
14 changed files with 20370 additions and 7732 deletions
+22 -4
View File
@@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Set Version
shell: pwsh
@@ -31,13 +31,24 @@ jobs:
echo "Building gregFramework version $version"
# 1. Build gregCore
# Hinweis: In CI müssen ggf. Stubs für MelonLoader/Il2Cpp vorhanden sein.
- name: Build gregCore
shell: pwsh
run: |
if (Test-Path "ci-stubs/create-stubs.sh") { bash ci-stubs/create-stubs.sh }
if (Test-Path "ci-stubs/create-stubs.sh") {
# Use bash (from Git for Windows) to run the stub script
bash ci-stubs/create-stubs.sh
}
dotnet build src/gregCore.csproj -c Release -p:Version=${{ env.VERSION }} -p:CI=true
# 2. Prepare Assets
# 2. Build gregExtractor (Optional, only if in this repo)
- name: Publish gregExtractor
shell: pwsh
run: |
if (Test-Path "gregExtractor/gregExtractor.csproj") {
dotnet publish gregExtractor/gregExtractor.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:Version=${{ env.VERSION }} -o publish/extractor
}
# 3. Prepare Assets
- name: Prepare Assets
shell: pwsh
run: |
@@ -50,6 +61,13 @@ jobs:
Copy-Item $coreDll $releaseDir/
Compress-Archive -Path $coreDll, "README.md" -DestinationPath "$releaseDir/gregCore-v${{ env.VERSION }}.zip"
}
# gregExtractor
$extractorExe = "publish/extractor/gregExtractor.exe"
if (Test-Path $extractorExe) {
Copy-Item $extractorExe $releaseDir/
Compress-Archive -Path "publish/extractor/*" -DestinationPath "$releaseDir/gregExtractor-v${{ env.VERSION }}.zip"
}
- name: Create Release
uses: softprops/action-gh-release@v2
+20077 -7695
View File
File diff suppressed because it is too large Load Diff
+26 -1
View File
@@ -2,4 +2,29 @@
# Erzeugt leere Stub-DLLs für CI-Build ohne echtes MelonLoader
# Diese enthalten nur die nötigen Type-Definitionen
dotnet new classlib -n MelonLoaderStub -f net6.0
mkdir -p ci-stubs
cd ci-stubs
ASSEMBLIES=(
"MelonLoader"
"Il2CppInterop.Runtime"
"Il2CppInterop.Common"
"0Harmony"
"Assembly-CSharp"
"Il2Cppmscorlib"
"UnityEngine.CoreModule"
"UnityEngine.IMGUIModule"
"UnityEngine.UIModule"
"UnityEngine.InputLegacyModule"
)
for asm in "${ASSEMBLIES[@]}"; do
if [ ! -f "$asm.dll" ]; then
echo "Creating stub for $asm..."
dotnet new classlib -n "$asm" -f net6.0 --force
dotnet build "$asm/$asm.csproj" -c Release -o .
rm -rf "$asm"
fi
done
echo "Stubs created in $(pwd)"
@@ -0,0 +1,4 @@
{
"label": "Economy",
"position": 10
}
@@ -0,0 +1,47 @@
---
title: greg.economy.PlayerCoinUpdated
sidebar_label: greg.economy.PlayerCoinUpdated
description: "gregCore Hook — Player Coin Updated"
---
# `greg.economy.PlayerCoinUpdated`
## Description
- Emitted when the player's coin balance changes.
## Payload Schema
| Field | Type / Note |
|------|----------------|
| `type` | `valueChange` |
| `key` | `money` |
| `oldValue` | `float` |
| `newValue` | `float` |
## How to use this hook
### 1. Object Bus: `GregEventDispatcher` (Rust / FFI / Lua / TS)
This hook is fired from the core via the `gregCore` plugin bridge whenever the underlying IL2CPP method (`Player.UpdateCoin`) executes successfully.
```csharp
using gregFramework.Core;
GregEventDispatcher.On("greg.economy.PlayerCoinUpdated", payload =>
{
var newValue = GregPayload.Get<float>(payload, "newValue", 0f);
// Logic here
});
```
### 2. Usage in Lua
Use the Lua bridge and register against the canonical hook string:
~~~lua
greg.on("greg.economy.PlayerCoinUpdated", function(payload)
local newVal = payload and payload.newValue or 0
greg.log("[ECONOMY] new money=" .. tostring(newVal))
end)
~~~
@@ -0,0 +1,47 @@
---
title: greg.economy.PlayerReputationUpdated
sidebar_label: greg.economy.PlayerReputationUpdated
description: "gregCore Hook — Player Reputation Updated"
---
# `greg.economy.PlayerReputationUpdated`
## Description
- Emitted when the player's reputation changes.
## Payload Schema
| Field | Type / Note |
|------|----------------|
| `type` | `valueChange` |
| `key` | `reputation` |
| `oldValue` | `float` |
| `newValue` | `float` |
## How to use this hook
### 1. Object Bus: `GregEventDispatcher` (Rust / FFI / Lua / TS)
This hook is fired from the core via the `gregCore` plugin bridge whenever the underlying IL2CPP method (`Player.UpdateReputation`) executes successfully.
```csharp
using gregFramework.Core;
GregEventDispatcher.On("greg.economy.PlayerReputationUpdated", payload =>
{
var newValue = GregPayload.Get<float>(payload, "newValue", 0f);
// Logic here
});
```
### 2. Usage in Lua
Use the Lua bridge and register against the canonical hook string:
~~~lua
greg.on("greg.economy.PlayerReputationUpdated", function(payload)
local newVal = payload and payload.newValue or 0
greg.log("[ECONOMY] new reputation=" .. tostring(newVal))
end)
~~~
@@ -0,0 +1,47 @@
---
title: greg.economy.PlayerXpUpdated
sidebar_label: greg.economy.PlayerXpUpdated
description: "gregCore Hook — Player XP Updated"
---
# `greg.economy.PlayerXpUpdated`
## Description
- Emitted when the player's XP changes.
## Payload Schema
| Field | Type / Note |
|------|----------------|
| `type` | `valueChange` |
| `key` | `xp` |
| `oldValue` | `float` |
| `newValue` | `float` |
## How to use this hook
### 1. Object Bus: `GregEventDispatcher` (Rust / FFI / Lua / TS)
This hook is fired from the core via the `gregCore` plugin bridge whenever the underlying IL2CPP method (`Player.UpdateXP`) executes successfully.
```csharp
using gregFramework.Core;
GregEventDispatcher.On("greg.economy.PlayerXpUpdated", payload =>
{
var newValue = GregPayload.Get<float>(payload, "newValue", 0f);
// Logic here
});
```
### 2. Usage in Lua
Use the Lua bridge and register against the canonical hook string:
~~~lua
greg.on("greg.economy.PlayerXpUpdated", function(payload)
local newVal = payload and payload.newValue or 0
greg.log("[ECONOMY] new xp=" .. tostring(newVal))
end)
~~~
Binary file not shown.
+6
View File
@@ -110,6 +110,7 @@ function New-WorkshopProject {
#region Package framework
$fwDll = Join-Path $RepoRoot "framework\bin\$Configuration\$tfm\gregCore.dll"
$hooksJson = Join-Path $RepoRoot "assets\greg_hooks.json"
if (-not (Test-Path -LiteralPath $fwDll)) { throw "Missing: $fwDll" }
New-WorkshopProject `
-Name 'gregCore' `
@@ -118,6 +119,11 @@ New-WorkshopProject `
-Title 'gregCore' `
-Description 'Core modding framework for Data Center. Required by all greg-based mods and plugins.' `
-Tags @('modded', 'melonloader', 'framework', 'greg')
$fwProjDir = Join-Path $WorkshopRoot 'gregCore'
$fwContentDir = Join-Path $fwProjDir 'content\Mods'
Copy-Item -LiteralPath $hooksJson -Destination (Join-Path $fwContentDir 'greg_hooks.json') -Force
Write-Host "[workshop] Copied greg_hooks.json to $fwContentDir"
#endregion
#region Package plugins
+1 -1
View File
@@ -25,7 +25,7 @@ public sealed class GregCoreLoader : MelonMod
public override void OnUpdate()
{
if (global::UnityEngine.Input.GetKeyDown(global::UnityEngine.KeyCode.P))
if (global::UnityEngine.InputSystem.Keyboard.current != null && global::UnityEngine.InputSystem.Keyboard.current.f8Key.wasPressedThisFrame)
{
global::gregCore.Infrastructure.UI.GregDevConsole.Instance.Toggle();
}
+2 -4
View File
@@ -23,10 +23,8 @@ internal static class HookIntegration
// [GREG_SYNC_INSERT_PATCHES]
SafePatch(harmony, typeof(Il2Cpp.Player), nameof(Il2Cpp.Player.UpdateCoin), typeof(gregCore.GameLayer.Patches.Economy.PlayerPatch), nameof(gregCore.GameLayer.Patches.Economy.PlayerPatch.OnCoinUpdated));
// Block Pause-Menu when Console is open
// NOTE: Interface patching via IUIActions might cause native crashes in Unity 6.
// SafePatch(harmony, typeof(global::Il2Cpp.InputController.IUIActions), nameof(global::Il2Cpp.InputController.IUIActions.OnPause), typeof(gregCore.GameLayer.Patches.UI.InputPausePatch), nameof(gregCore.GameLayer.Patches.UI.InputPausePatch.Prefix), isPrefix: true);
SafePatch(harmony, typeof(Il2Cpp.Player), nameof(Il2Cpp.Player.UpdateXP), typeof(gregCore.GameLayer.Patches.Economy.PlayerPatch), nameof(gregCore.GameLayer.Patches.Economy.PlayerPatch.OnXpUpdated));
SafePatch(harmony, typeof(Il2Cpp.Player), nameof(Il2Cpp.Player.UpdateReputation), typeof(gregCore.GameLayer.Patches.Economy.PlayerPatch), nameof(gregCore.GameLayer.Patches.Economy.PlayerPatch.OnReputationUpdated));
}
internal static void Emit(HookName hook, EventPayload payload)
+28 -2
View File
@@ -12,11 +12,11 @@ namespace gregCore.GameLayer.Patches.Economy;
internal static class PlayerPatch
{
internal static void OnCoinUpdated(object instance, float coinChangeAmount)
internal static void OnCoinUpdated(object __instance, float _coinChhangeAmount)
{
try
{
var payload = EventPayloadBuilder.ForValueChange("money", 0f, coinChangeAmount);
var payload = EventPayloadBuilder.ForValueChange("money", 0f, _coinChhangeAmount);
HookIntegration.Emit(HookName.Create("economy", "PlayerCoinUpdated"), payload);
}
catch (Exception ex)
@@ -24,4 +24,30 @@ internal static class PlayerPatch
HookIntegration.LogPatchError(nameof(OnCoinUpdated), ex);
}
}
internal static void OnXpUpdated(object __instance, float amount)
{
try
{
var payload = EventPayloadBuilder.ForValueChange("xp", 0f, amount);
HookIntegration.Emit(HookName.Create("economy", "PlayerXpUpdated"), payload);
}
catch (Exception ex)
{
HookIntegration.LogPatchError(nameof(OnXpUpdated), ex);
}
}
internal static void OnReputationUpdated(object __instance, float amount)
{
try
{
var payload = EventPayloadBuilder.ForValueChange("reputation", 0f, amount);
HookIntegration.Emit(HookName.Create("economy", "PlayerReputationUpdated"), payload);
}
catch (Exception ex)
{
HookIntegration.LogPatchError(nameof(OnReputationUpdated), ex);
}
}
}
+34 -9
View File
@@ -37,9 +37,23 @@ internal sealed class GregDevConsole
public void Toggle()
{
IsOpen = !IsOpen;
var mgm = global::Il2Cpp.MainGameManager.instance;
if (IsOpen)
{
_input = "";
if (mgm != null) mgm.isPauseMenuDisallowed = true;
global::UnityEngine.Cursor.visible = true;
global::UnityEngine.Cursor.lockState = global::UnityEngine.CursorLockMode.None;
}
else
{
if (mgm != null) mgm.isPauseMenuDisallowed = false;
global::UnityEngine.Cursor.visible = false;
global::UnityEngine.Cursor.lockState = global::UnityEngine.CursorLockMode.Locked;
}
}
@@ -70,27 +84,38 @@ internal sealed class GregDevConsole
GUILayout.EndScrollView();
GUILayout.BeginHorizontal();
GUI.SetNextControlName("GregConsoleInput");
_input = GUILayout.TextField(_input);
Rect inputRect = GUILayoutUtility.GetRect(200, 20, GUILayout.ExpandWidth(true));
GUI.Box(inputRect, _input + (Time.time % 1f < 0.5f ? "_" : ""));
var e = Event.current;
if (e.isKey && e.type == EventType.KeyDown)
{
if (e.keyCode == KeyCode.Return)
{
// return handled below
}
else if (e.keyCode == KeyCode.Backspace)
{
if (_input.Length > 0) _input = _input.Substring(0, _input.Length - 1);
}
else if (e.character >= 32 && e.character <= 126)
{
_input += e.character;
}
}
if (GUILayout.Button("Run", GUILayout.Width(80)) ||
(Event.current.isKey && Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "GregConsoleInput"))
(e.isKey && e.type == EventType.KeyDown && e.keyCode == KeyCode.Return))
{
if (!string.IsNullOrWhiteSpace(_input))
{
Execute(_input);
_input = "";
}
GUI.FocusControl("GregConsoleInput");
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
if (GUI.GetNameOfFocusedControl() != "GregConsoleInput")
{
GUI.FocusControl("GregConsoleInput");
}
}
private void Execute(string input)
+29 -16
View File
@@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RepoRoot>$(MSBuildProjectDirectory)\..</RepoRoot>
<AssemblyName>gregCore</AssemblyName>
<RootNamespace>gregCore</RootNamespace>
<Version>1.0.0.33-pre</Version>
@@ -20,48 +21,60 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="MelonLoader" Condition="'$(CI)' != 'true'">
<HintPath>$(MELON_BASE_DIR)\net6\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MelonLoader" Condition="'$(CI)' == 'true'">
<HintPath>$(RepoRoot)\ci-stubs\MelonLoader.dll</HintPath>
<!-- Common References with CI Fallback -->
<Reference Include="MelonLoader">
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\net6\MelonLoader.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2CppInterop.Runtime">
<HintPath>$(MELON_BASE_DIR)\net6\Il2CppInterop.Runtime.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\net6\Il2CppInterop.Runtime.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\Il2CppInterop.Runtime.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2CppInterop.Common">
<HintPath>$(MELON_BASE_DIR)\net6\Il2CppInterop.Common.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\net6\Il2CppInterop.Common.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\Il2CppInterop.Common.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>$(MELON_BASE_DIR)\net6\0Harmony.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\net6\0Harmony.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\Assembly-CSharp.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\Assembly-CSharp.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\Il2Cppmscorlib.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\Il2Cppmscorlib.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.CoreModule.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.CoreModule.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.UIModule.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.UIModule.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.InputSystem">
<HintPath Condition="'$(CI)' != 'true'">$(MELON_BASE_DIR)\Il2CppAssemblies\Unity.InputSystem.dll</HintPath>
<HintPath Condition="'$(CI)' == 'true'">$(RepoRoot)\ci-stubs\Unity.InputSystem.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -71,4 +84,4 @@
<PackageReference Include="MoonSharp" Version="2.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
</Project>