Skip to content

Commit

Permalink
fix bug, work on all inspectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
eia485 committed Sep 15, 2021
1 parent 775c9a6 commit 2dee4b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ShowDriveSource/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
23 changes: 8 additions & 15 deletions ShowDriveSource/ShowDriveSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,30 @@ public class ShowDriveSource : NeosMod
{
public override string Name => "ShowDriveSource";
public override string Author => "art0007i";
public override string Version => "1.0.0";
public override string Version => "1.1.0";
public override string Link => "https://github.com/art0007i/NeosTemplate/";
public override void OnEngineInit()
{
Harmony harmony = new Harmony("me.art0007i.ShowDriveSource");
harmony.PatchAll();

}
[HarmonyPatch(typeof(SyncMemberEditorBuilder))]
[HarmonyPatch("GenerateMemberField")]
[HarmonyPatch(typeof(Button))]
[HarmonyPatch("RunPressed")]
class SyncMemberEditorBuilder_GenerateMemberField_Patch
{
private static void ShowDrive(IButton button, ButtonEventData data)
public static void Postfix(Button __instance)
{
var refProxy = button.Slot.GetComponent<ReferenceProxySource>();
ReferenceProxySource refProxy = __instance.Slot.GetComponent<ReferenceProxySource>();
if (refProxy == null) return;
var field = refProxy.Reference.Target as IField;
IField field = refProxy.Reference.Target as IField;
if (field == null || (!field.IsDriven && !field.IsLinked)) return;
SyncElement syncElement = field.ActiveLink as SyncElement;
InspectorHelper.OpenInspectorForTarget(syncElement.Component, null, true);
float3 pos = float3.Zero;
floatQ rot = floatQ.Identity;
(button as Component).LocalUser.GetPointInFrontOfUser(out pos, out rot, null, new float3(0, 0, -0.1f));
NotificationMessage.SpawnTextMessage((button as Component).World, pos, syncElement.Name, color.Magenta);
}
public static void Postfix(UIBuilder ui, string name)
{
if (!string.IsNullOrEmpty(name))
{
ui.Root.GetComponentInChildren<ReferenceProxySource>().Slot.GetComponent<Button>().LocalPressed += ShowDrive;
}
__instance.LocalUser.GetPointInFrontOfUser(out pos, out rot, null, new float3(0, 0, -0.1f));
NotificationMessage.SpawnTextMessage(__instance.World, pos, syncElement.Name, color.Magenta);
}
}
}
Expand Down

0 comments on commit 2dee4b9

Please sign in to comment.