Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1.         [HarmonyPatch(typeof(VerbTracker), "CreateVerbTargetCommand")]
  2.         private static class CreateVerbTargetCommandPatch {
  3.             [HarmonyPostfix]
  4.             static void Postfix(Thing ownerThing, Command_VerbTarget __result) {
  5.                 var comp = ownerThing?.TryGetComp<CompLootAffixableThing>();
  6.                 if (comp == null) return;
  7.  
  8.                 Texture2D icon = comp.UIIcon;
  9.                 Log.Message("CreateVerbTargetCommand: end");
  10.             }
  11.         }
  12.  
  13. // In CompLootAffixableThing
  14.  
  15.         private Texture2D GetUIIcon () {
  16.             Log.Message("GetUIIcon 1");
  17.             Texture2D defIcon = parent.def.uiIcon;
  18.             if (affixes.Count == 0)        return defIcon;
  19.             if (!UnityData.IsInMainThread) return defIcon;  // too early to be fetching this stuff
  20.            
  21.             Log.Message("GetUIIcon 2");
  22.  
  23.             Material  overlayMat = OverlayMaterial();
  24.             Log.Message("GetUIIcon 3");
  25.             if (overlayMat == null) return defIcon;  // some sort of error
  26.  
  27.             // DEBUG
  28.             Log.Message("GetUIIcon 4");
  29.             uiIcon = (Texture2D)overlayMat.mainTexture;
  30.             Log.Message("GetUIIcon 5");
  31.             return uiIcon;
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement