Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user menu update #239

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/MultiplayerMod/Game/KEventSystemExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using UnityEngine;

namespace MultiplayerMod.Game;

public static class KEventSystemExtensions {

public static void Trigger(this GameObject go, GameHashes hash, object? data = null) {
var kObject = KObjectManager.Instance.Get(go);
if (kObject == null || !kObject.hasEventSystem)
return;

kObject.GetEventSystem().Trigger(go, (int) hash, data);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using MultiplayerMod.Core.Logging;
using MultiplayerMod.Game;
using MultiplayerMod.Multiplayer.Objects;
using MultiplayerMod.Multiplayer.Objects.Reference;
using UnityEngine;
Expand Down Expand Up @@ -31,7 +32,10 @@ public override void Execute(MultiplayerCommandContext context) {
new Type[] { },
new ParameterModifier[] { }
);
methodInfo?.Invoke(reference.GetComponent(actionDeclaringType), new object[] { });
var target = reference.GetGameObject();
methodInfo?.Invoke(target.GetComponent(actionDeclaringType), new object[] { });
target.Trigger(GameHashes.RefreshUserMenu);
target.Trigger(GameHashes.UIRefresh);
} catch (Exception e) {
log.Error(e.ToString());
}
Expand Down