됨? => 안됨

vpe 호환 => 메서드를 찾지를 못함 타입 한번 봐야할듯
바닐라 => 망가짐 위와 비슷한 이유일듯
This commit is contained in:
2025-05-28 14:09:32 +09:00
parent 7ce3eb956a
commit cce9f99cde
5 changed files with 416 additions and 24 deletions

13
.idea/.idea.psycastDontNeedPsyfocus/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# 디폴트 무시된 파일
/shelf/
/workspace.xml
# Rider에서 무시된 파일
/modules.xml
/.idea.psycastDontNeedPsyfocus.iml
/contentModel.xml
/projectSettingsUpdater.xml
# 에디터 기반 HTTP 클라이언트 요청
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

333
psyThingsGizmo.cs Normal file
View File

@@ -0,0 +1,333 @@
using System;
using System.Collections.Generic;
using LudeonTK;
using UnityEngine;
using Verse;
using Verse.Sound;
namespace RimWorld
{
// Token: 0x0200136E RID: 4974
[StaticConstructorOnStartup]
public class PsychicEntropyGizmo : Gizmo
{
// Token: 0x060076A0 RID: 30368 RVA: 0x0028CB38 File Offset: 0x0028AD38
public PsychicEntropyGizmo(Pawn_PsychicEntropyTracker tracker)
{
this.tracker = tracker;
this.Order = -100f;
this.targetValue = tracker.TargetPsyfocus;
this.LimitedTex = ContentFinder<Texture2D>.Get("UI/Icons/EntropyLimit/Limited", true);
this.UnlimitedTex = ContentFinder<Texture2D>.Get("UI/Icons/EntropyLimit/Unlimited", true);
}
// Token: 0x060076A1 RID: 30369 RVA: 0x0028CB98 File Offset: 0x0028AD98
private void DrawThreshold(Rect rect, float percent, float entropyValue)
{
Rect position = new Rect
{
x = rect.x + 3f + (rect.width - 8f) * percent,
y = rect.y + rect.height - 9f,
width = 2f,
height = 6f
};
if (entropyValue < percent)
{
GUI.DrawTexture(position, BaseContent.GreyTex);
return;
}
GUI.DrawTexture(position, BaseContent.BlackTex);
}
// Token: 0x060076A2 RID: 30370 RVA: 0x0028CC24 File Offset: 0x0028AE24
private void DrawPsyfocusTarget(Rect rect, float percent)
{
float num = Mathf.Round((rect.width - 8f) * percent);
GUI.DrawTexture(new Rect
{
x = rect.x + 3f + num,
y = rect.y,
width = 2f,
height = rect.height
}, PsychicEntropyGizmo.PsyfocusTargetTex);
float num2 = UIScaling.AdjustCoordToUIScalingFloor(rect.x + 2f + num);
float xMax = UIScaling.AdjustCoordToUIScalingCeil(num2 + 4f);
Rect rect2 = new Rect
{
y = rect.y - 3f,
height = 5f,
xMin = num2,
xMax = xMax
};
GUI.DrawTexture(rect2, PsychicEntropyGizmo.PsyfocusTargetTex);
Rect position = rect2;
position.y = rect.yMax - 2f;
GUI.DrawTexture(position, PsychicEntropyGizmo.PsyfocusTargetTex);
}
// Token: 0x060076A3 RID: 30371 RVA: 0x0028CD20 File Offset: 0x0028AF20
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
{
Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
Rect rect2 = rect.ContractedBy(6f);
MainTabWindow_Inspect mainTabWindow_Inspect = (MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow;
Command_Psycast command_Psycast = ((mainTabWindow_Inspect != null) ? mainTabWindow_Inspect.LastMouseoverGizmo : null) as Command_Psycast;
float num = Mathf.Repeat(Time.time, 0.85f);
float num2 = 1f;
if (num < 0.1f)
{
num2 = num / 0.1f;
}
else if (num >= 0.25f)
{
num2 = 1f - (num - 0.25f) / 0.6f;
}
Widgets.DrawWindowBackground(rect);
Text.Font = GameFont.Small;
Rect rect3 = rect2;
rect3.y += 6f;
rect3.height = Text.LineHeight;
Widgets.Label(rect3, "PsychicEntropyShort".Translate());
Rect rect4 = rect2;
rect4.y += 38f;
rect4.height = Text.LineHeight;
Widgets.Label(rect4, "PsyfocusLabelGizmo".Translate());
Rect rect5 = rect2;
rect5.x += 63f;
rect5.y += 6f;
rect5.width = 100f;
rect5.height = 22f;
float entropyRelativeValue = this.tracker.EntropyRelativeValue;
Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue, 1f), PsychicEntropyGizmo.EntropyBarTex, PsychicEntropyGizmo.EmptyBarTex, true);
if (this.tracker.EntropyValue > this.tracker.MaxEntropy)
{
Widgets.FillableBar(rect5, Mathf.Min(entropyRelativeValue - 1f, 1f), PsychicEntropyGizmo.OverLimitBarTex, PsychicEntropyGizmo.EntropyBarTex, true);
}
if (command_Psycast != null)
{
Ability ability = command_Psycast.Ability;
if (ability.def.EntropyGain > 1E-45f)
{
Rect rect6 = rect5.ContractedBy(3f);
float width = rect6.width;
float num3 = this.tracker.EntropyToRelativeValue(this.tracker.EntropyValue + ability.def.EntropyGain);
float num4 = entropyRelativeValue;
if (num4 > 1f)
{
num4 -= 1f;
num3 -= 1f;
}
rect6.xMin = UIScaling.AdjustCoordToUIScalingFloor(rect6.xMin + num4 * width);
rect6.width = UIScaling.AdjustCoordToUIScalingFloor(Mathf.Max(Mathf.Min(num3, 1f) - num4, 0f) * width);
GUI.color = new Color(1f, 1f, 1f, num2 * 0.7f);
GenUI.DrawTextureWithMaterial(rect6, PsychicEntropyGizmo.EntropyBarTexAdd, null, default(Rect));
GUI.color = Color.white;
}
}
if (this.tracker.EntropyValue > this.tracker.MaxEntropy)
{
foreach (KeyValuePair<PsychicEntropySeverity, float> keyValuePair in Pawn_PsychicEntropyTracker.EntropyThresholds)
{
if (keyValuePair.Value > 1f && keyValuePair.Value < 2f)
{
this.DrawThreshold(rect5, keyValuePair.Value - 1f, entropyRelativeValue);
}
}
}
string label = this.tracker.EntropyValue.ToString("F0") + " / " + this.tracker.MaxEntropy.ToString("F0");
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(rect5, label);
Text.Anchor = TextAnchor.UpperLeft;
Text.Font = GameFont.Tiny;
GUI.color = Color.white;
Rect rect7 = rect2;
rect7.width = 175f;
rect7.height = 38f;
TooltipHandler.TipRegion(rect7, delegate()
{
float f = this.tracker.EntropyValue / this.tracker.RecoveryRate;
TaggedString t = string.Concat(new object[]
{
("PsychicEntropy".Translate() + ": ").Colorize(ColoredText.TipSectionTitleColor),
Mathf.Round(this.tracker.EntropyValue),
" / ",
Mathf.Round(this.tracker.MaxEntropy)
});
t += "\n" + "PawnTooltipPsychicEntropyStats".Translate(this.tracker.RecoveryRate.ToString("0.#"), Mathf.Round(f));
return (t + ("\n\n" + "PawnTooltipPsychicEntropyDesc".Translate())).Resolve();
}, Gen.HashCombineInt(this.tracker.GetHashCode(), 133858));
Rect rect8 = rect2;
rect8.x += 63f;
rect8.y += 38f;
rect8.width = 100f;
rect8.height = 22f;
this.lastTargetValue = this.targetValue;
if (this.tracker.Pawn.IsColonistPlayerControlled)
{
Widgets.DraggableBar(rect8, PsychicEntropyGizmo.PsyfocusBarTex, PsychicEntropyGizmo.PsyfocusBarHighlightTex, PsychicEntropyGizmo.EmptyBarTex, PsychicEntropyGizmo.PsyfocusTargetTex, ref PsychicEntropyGizmo.draggingBar, this.tracker.CurrentPsyfocus, ref this.targetValue, Pawn_PsychicEntropyTracker.PsyfocusBandPercentages, 16, 0f, 1f);
if (this.lastTargetValue != this.targetValue)
{
this.tracker.SetPsyfocusTarget(this.targetValue);
PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MeditationDesiredPsyfocus, KnowledgeAmount.Total);
}
}
else
{
Widgets.FillableBar(rect8, this.tracker.CurrentPsyfocus, PsychicEntropyGizmo.PsyfocusBarTex, PsychicEntropyGizmo.EmptyBarTex, true);
}
UIHighlighter.HighlightOpportunity(rect8, "PsyfocusBar");
if (command_Psycast != null)
{
float min = command_Psycast.Ability.def.PsyfocusCostRange.min;
if (min > 1E-45f)
{
Rect rect9 = rect8.ContractedBy(3f);
float num5 = Mathf.Max(this.tracker.CurrentPsyfocus - min, 0f);
float width2 = rect9.width;
rect9.xMin = UIScaling.AdjustCoordToUIScalingFloor(rect9.xMin + num5 * width2);
rect9.width = UIScaling.AdjustCoordToUIScalingCeil((this.tracker.CurrentPsyfocus - num5) * width2);
GUI.color = new Color(1f, 1f, 1f, num2);
GenUI.DrawTextureWithMaterial(rect9, PsychicEntropyGizmo.PsyfocusBarTexReduce, null, default(Rect));
GUI.color = Color.white;
}
}
Rect rect10 = rect2;
rect10.y += 38f;
rect10.width = 175f;
rect10.height = 38f;
TooltipHandler.TipRegion(rect10, () => this.tracker.PsyfocusTipString(this.selectedPsyfocusTarget), Gen.HashCombineInt(this.tracker.GetHashCode(), 133873));
if (this.tracker.Pawn.IsColonistPlayerControlled)
{
float num6 = 32f;
float num7 = 4f;
float num8 = rect2.height / 2f - num6 + num7;
float num9 = rect2.width - num6;
Rect rect11 = new Rect(rect2.x + num9, rect2.y + num8, num6, num6);
if (Widgets.ButtonImage(rect11, this.tracker.limitEntropyAmount ? this.LimitedTex : this.UnlimitedTex, true, null))
{
this.tracker.limitEntropyAmount = !this.tracker.limitEntropyAmount;
if (this.tracker.limitEntropyAmount)
{
SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
}
else
{
SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
}
}
TooltipHandler.TipRegionByKey(rect11, "PawnTooltipPsychicEntropyLimit");
}
float num10;
if (this.TryGetPainMultiplier(this.tracker.Pawn, out num10))
{
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleCenter;
string recoveryBonus = (num10 - 1f).ToStringPercent("F0");
string recoveryBonus2 = recoveryBonus;
float widthCached = recoveryBonus2.GetWidthCached();
Rect rect12 = rect2;
rect12.x += rect2.width - widthCached / 2f - 16f;
rect12.y += 38f;
rect12.width = widthCached;
rect12.height = Text.LineHeight;
GUI.color = PsychicEntropyGizmo.PainBoostColor;
Widgets.Label(rect12, recoveryBonus2);
GUI.color = Color.white;
Text.Font = GameFont.Tiny;
Text.Anchor = TextAnchor.UpperLeft;
TooltipHandler.TipRegion(rect12.ContractedBy(-1f), () => "PawnTooltipPsychicEntropyPainFocus".Translate(this.tracker.Pawn.health.hediffSet.PainTotal.ToStringPercent("F0"), recoveryBonus), Gen.HashCombineInt(this.tracker.GetHashCode(), 133878));
}
return new GizmoResult(GizmoState.Clear);
}
// Token: 0x060076A4 RID: 30372 RVA: 0x0028D508 File Offset: 0x0028B708
private bool TryGetPainMultiplier(Pawn pawn, out float painMultiplier)
{
List<StatPart> parts = StatDefOf.PsychicEntropyRecoveryRate.parts;
for (int i = 0; i < parts.Count; i++)
{
StatPart_Pain statPart_Pain;
if ((statPart_Pain = (parts[i] as StatPart_Pain)) != null)
{
painMultiplier = statPart_Pain.PainFactor(this.tracker.Pawn);
return true;
}
}
painMultiplier = 0f;
return false;
}
// Token: 0x060076A5 RID: 30373 RVA: 0x0028D55E File Offset: 0x0028B75E
public override float GetWidth(float maxWidth)
{
return 212f;
}
// Token: 0x04004692 RID: 18066
private Pawn_PsychicEntropyTracker tracker;
// Token: 0x04004693 RID: 18067
private float selectedPsyfocusTarget = -1f;
// Token: 0x04004694 RID: 18068
private static bool draggingBar;
// Token: 0x04004695 RID: 18069
private float lastTargetValue;
// Token: 0x04004696 RID: 18070
private float targetValue;
// Token: 0x04004697 RID: 18071
private Texture2D LimitedTex;
// Token: 0x04004698 RID: 18072
private Texture2D UnlimitedTex;
// Token: 0x04004699 RID: 18073
private const string LimitedIconPath = "UI/Icons/EntropyLimit/Limited";
// Token: 0x0400469A RID: 18074
private const string UnlimitedIconPath = "UI/Icons/EntropyLimit/Unlimited";
// Token: 0x0400469B RID: 18075
public const float CostPreviewFadeIn = 0.1f;
// Token: 0x0400469C RID: 18076
public const float CostPreviewSolid = 0.15f;
// Token: 0x0400469D RID: 18077
public const float CostPreviewFadeInSolid = 0.25f;
// Token: 0x0400469E RID: 18078
public const float CostPreviewFadeOut = 0.6f;
// Token: 0x0400469F RID: 18079
private static readonly Color PainBoostColor = new Color(0.2f, 0.65f, 0.35f);
// Token: 0x040046A0 RID: 18080
private static readonly Texture2D EntropyBarTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.46f, 0.34f, 0.35f));
// Token: 0x040046A1 RID: 18081
private static readonly Texture2D EntropyBarTexAdd = SolidColorMaterials.NewSolidColorTexture(new Color(0.78f, 0.72f, 0.66f));
// Token: 0x040046A2 RID: 18082
private static readonly Texture2D OverLimitBarTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.75f, 0.2f, 0.15f));
// Token: 0x040046A3 RID: 18083
private static readonly Texture2D PsyfocusBarTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.34f, 0.42f, 0.43f));
// Token: 0x040046A4 RID: 18084
private static readonly Texture2D PsyfocusBarTexReduce = SolidColorMaterials.NewSolidColorTexture(new Color(0.65f, 0.83f, 0.83f));
// Token: 0x040046A5 RID: 18085
private static readonly Texture2D PsyfocusBarHighlightTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.43f, 0.54f, 0.55f));
// Token: 0x040046A6 RID: 18086
private static readonly Texture2D EmptyBarTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.03f, 0.035f, 0.05f));
// Token: 0x040046A7 RID: 18087
private static readonly Texture2D PsyfocusTargetTex = SolidColorMaterials.NewSolidColorTexture(new Color(0.74f, 0.97f, 0.8f));
}
}

View File

@@ -11,32 +11,64 @@ namespace psycastDontNeedPsyfocus
static HarmonyPatches() static HarmonyPatches()
{ {
var harmony = new Harmony("com.a4plane.psycastDontNeedPsyfocus"); var harmony = new Harmony("com.a4plane.psycastDontNeedPsyfocus");
harmony.PatchAll(Assembly.GetExecutingAssembly()); //harmony.PatchAll(Assembly.GetExecutingAssembly());
var VPEMod = AccessTools.TypeByName("VanillaPsycastsExpanded.AbilityExtension");
if (VPEMod != null)
{
Log.Message("find VPE");
var method = AccessTools.Method(VPEMod, "GetPsyfocusUsedByPawn");
if (method != null)
{
harmony.Patch(method, postfix: new HarmonyMethod(typeof(HarmonyPatches), nameof(Postfix_VPE)));
}
}
else
{
Log.Message("Cant find vpe");
}
var Vmethod = typeof(AbilityDef).GetProperty(nameof(AbilityDef.PsyfocusCost)).GetGetMethod();
harmony.Patch(Vmethod, postfix: new HarmonyMethod(typeof(HarmonyPatch), nameof(Postfix_V)));
if (Vmethod != null)
{
Log.Message("find v method");
} }
} }
public static void Postfix_VPE(ref float __result)
{
Log.Message("qweqwwqe");
__result = 0;
}
public static void Postfix_V(ref float __result)
{
Log.Message("eweqw");
__result = 0;
}
}
//def에서 초집중 값 읽어오는 부분 패치해서 됨 //def에서 초집중 값 읽어오는 부분 패치해서 됨
//todo ui에서 초집중 요소 날리기 //todo ui에서 초집중 요소 날리기
[HarmonyPatch] //[HarmonyPatch]
class Patcher //class Patcher
{
public static MethodBase TargetMethod()
{
return typeof(AbilityDef).GetProperty(nameof(AbilityDef.PsyfocusCost)).GetGetMethod();
}
public static void Postfix(ref float __result)
{
//Log.Message("qewqwe");
__result = 0f;
}
//public static class ValidateTarget_ValidateTarget_Patch
//{ //{
// static void postfix(ref bool __result/*,ref Ability ability*/) // public static MethodBase TargetMethod()
// { // {
// Log.Message("aaa"); // return typeof(AbilityDef).GetProperty(nameof(AbilityDef.PsyfocusCost)).GetGetMethod();
// __result = true;
// } // }
// public static void Postfix(ref float __result)
// {
// //Log.Message("qewqwe");
// __result = 0f;
// }
// //public static class ValidateTarget_ValidateTarget_Patch
// //{
// // static void postfix(ref bool __result/*,ref Ability ability*/)
// // {
// // Log.Message("aaa");
// // __result = true;
// // }
// //}
//} //}
} }
}