-
-
Save VariableVixen/527ba8f547bba85ac9db30245d020a2c to your computer and use it in GitHub Desktop.
| using Unity.Mathematics; | |
| using Unity.Transforms; | |
| using UnityEngine; | |
| using HarmonyLib; | |
| using Pug.UnityExtensions; | |
| [HarmonyPatch] | |
| class teleportmod { | |
| [HarmonyPrefix, HarmonyPatch(typeof(MapMarkerUIElement), nameof(MapMarkerUIElement.OnLeftClicked))] | |
| public static bool OnLeftClicked(MapMarkerUIElement __instance) { | |
| if (!Input.GetKey(KeyCode.LeftShift)) { | |
| return true; | |
| } | |
| if (__instance.markerType == MapMarkerType.Portal | |
| || __instance.markerType == MapMarkerType.Waypoint | |
| || __instance.markerType == MapMarkerType.PlayerGrave | |
| || __instance.markerType == MapMarkerType.Ping | |
| || __instance.markerType == MapMarkerType.UniqueBoss | |
| || __instance.markerType == MapMarkerType.TitanShrine | |
| || __instance.markerType == MapMarkerType.UserPlacedMarker) { | |
| PlayerController playerController = Manager.main.player; | |
| float2 rhs = (EntityUtility.GetObjectData(__instance.mapMarkerEntity, __instance.world).variation == 20) ? new float2(1f, 1f) : new float2(1f, -0.25f); | |
| playerController.QueueInputAction(new UIInputActionData { | |
| action = UIInputAction.Teleport, | |
| position = EntityUtility.GetComponentData<LocalTransform>(__instance.mapMarkerEntity, __instance.world).Position.ToFloat2() + rhs, | |
| }); | |
| if (Manager.ui.isShowingMap) { | |
| Manager.ui.OnMapToggle(); | |
| } | |
| } | |
| return false; | |
| } | |
| } | |
| } | |
| } | |
| return false; | |
| } | |
| } |
Thanks a lot for this, highly appreciated!
Unfortunately, only very few authors of existing mods are still around to keep them functional with latest versions of the game. I don't know if you are willing to look into it, but maybe you could also fix the following mods:
- Auto Door Rework (by Maskoliver)
- Bind4Consumables (by GwendalT35)
- Keep Inventory on Death (by EllieAU)
I'm aware some of these are included in some other QoL mods, but they all include features I don't need. I tried to install the CK SDK to do all this by myself, but TBH it's pretty confusing and I am preoccupied with my own projects. You'd be doing God's work!
I don't actually have the CK SDK, I just decompiled the mod on a lark to see if there was anything obviously broken when linked against the game's live assets. It turned out to be a very simple mod, and IIRC the issue was a missing using statement or two, which I was able to track down. I tested it by editing the source file on my local drive and launching the game, and when it worked I decided to upload the fix for others.
I can't guarantee I'll have the mental energy to look into anything, and even if I do I also can't guarantee I'll be able to do anything, but I'll keep it in mind.
Referring to this mod for a change:
- Jumping to a ping marker doesn't seem to be working, at least not with latest CK version.
- It would be better if another key, e.g. LShift, had to be pressed together with LMB to avoid accidental teleports while panning the map. I have tried this and it seems to work:
Add on top:
using UnityEngine;
Add afterpublic static bool OnLeftClicked(MapMarkerUIElement __instance) {:
if (!Input.GetKey(KeyCode.LeftShift)) {
return true;
}
(Basically just aborts OnLeftClicked if LShift is not held down.)
Missed that notification, but I finally updated the file to use the correct enum entry (Unique → UniqueBoss) and also add the left-shift requirement. It compiles and loads properly, so if anything isn't working then I'm not sure why.
Better late than never, I guess! By now someone else has apparently continued working on this mod, to keep it functional with latest game versions. Will check if their code reflects your adjustments.
Until the author updates the mod.io version, you can download this file and overwrite the original. I don't play Core Keeper on linux, but on windows the path is
C:\Users\Public\mod.io\5289\mods\4464472_5741032\Scripts\TeleportMod.cs.