Skip to content

Commit

Permalink
add injury popup on click pilot in task mgr
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkroeg committed Jun 7, 2022
1 parent 2829cd3 commit 019601e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 2 deletions.
68 changes: 68 additions & 0 deletions Framework/InjuryDescriptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,74 @@ namespace TisButAScratch.Framework
{
public static class InjuryDescriptions
{
internal static string getPilotInjuryDescCompact(Pilot pilot)
{
var pilotID = pilot.FetchGUID();
if (string.IsNullOrEmpty(pilotID)) return null;

var rtrn = "";
if (PilotInjuryHolder.HolderInstance.pilotInjuriesMap.ContainsKey(pilotID))
{
if (ModInit.modSettings.debilSeverityThreshold > 0)
{
rtrn +=
$"<color=#FF0000>Debilitating Severity Threshold Per-Location: {ModInit.modSettings.debilSeverityThreshold}</color=#FF0000>\n";
}

foreach (var id in PilotInjuryHolder.HolderInstance.pilotInjuriesMap[pilotID])
{
foreach (Injury injury in PilotInjuryManager.ManagerInstance.InjuryEffectsList.Where(x =>
x.injuryID == id))
{
var description = $"Severity {injury.severity}: {injury.injuryName}: {injury.description}";
rtrn += description + "\n";
}
}

if (ModInit.modSettings.enableInternalDmgInjuries)
{
foreach (var id in PilotInjuryHolder.HolderInstance.pilotInjuriesMap[pilotID])
{
foreach (Injury feedbackinjury in PilotInjuryManager.ManagerInstance.InternalDmgInjuries.Where(
x => x.injuryID == id))
{
var description =
$"Severity {feedbackinjury.severity}: {feedbackinjury.injuryName}: {feedbackinjury.description}";
rtrn += description + "\n";
}
}
}


if (pilot.pilotDef.PilotTags.Contains(DEBILITATEDTAG))
{
rtrn += DEBIL.description + "\n";
}
}

if (ModInit.modSettings.UseSimBleedingEffects)
{
foreach (var tempResult in sim.TemporaryResultTracker.Where(x =>
x.TargetPilot == pilot && x.Stats != null))
{
var statDesc = "";
foreach (var tag in tempResult.AddedTags)
{
var matches = TBAS_SimBleedStatMod.Matches(tag);
if (matches.Count <= 0) continue;
var statType = matches[0].Groups["type"].Value;
var statMod = matches[0].Groups["value"].Value;
// var statOp = matches[0].Groups["operation"].Value;
statDesc += $"{statMod} {statType}, ";
}

statDesc += $" for {tempResult.ResultDuration - tempResult.DaysElapsed} days when in combat.";
rtrn += statDesc + "\n";
}
}

return rtrn;
}
internal static string getPilotInjuryDesc(Pilot pilot)
{
var pilotID = pilot.FetchGUID();
Expand Down
22 changes: 22 additions & 0 deletions Patches/DescriptionPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,27 @@ public static void Postfix(TaskManagementElement __instance, WorkOrderEntry ___e
___subTitleColor.SetUIColor(UIColor.RedHalf);
}
}

[HarmonyPatch(typeof(TaskTimelineWidget), "OnTaskDetailsClicked")]
public static class TaskTimelineWidget_OnTaskDetailsClicked_Patch
{
static void Postfix(TaskTimelineWidget __instance, TaskManagementElement element)
{
if (element == null) return;
if (element.Entry.Type != WorkOrderType.MedLabHeal) return;
if (!(element.Entry is WorkOrderEntry_MedBayHeal medbayHealEntry) ||
medbayHealEntry.Pilot.Injuries == 0) return;
var sim = UnityGameInstance.BattleTechGame.Simulation;
sim.SetTimeMoving(false);

var pilot = medbayHealEntry.Pilot;
var Desc = $"<b>PILOT: {pilot.FirstName} \"{pilot.Callsign}\" {pilot.LastName}</b>\n";
Desc += "<b>STATUS: INJURED</b>\n";
Desc += $"<b>SUMMARY:</b>\n";
Desc += $"{InjuryDescriptions.getPilotInjuryDescCompact(pilot)}";

PauseNotification.Show("Medical Summary", Desc, pilot.GetPortraitSprite(), "", true, null);
}
}
}
}
4 changes: 2 additions & 2 deletions 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.4.4")]
[assembly: AssemblyFileVersion("1.0.4.4")]
[assembly: AssemblyVersion("1.0.4.5")]
[assembly: AssemblyFileVersion("1.0.4.5")]
Binary file modified bin/Debug/TisButAScratch.dll
Binary file not shown.
Binary file modified bin/Debug/TisButAScratch.pdb
Binary file not shown.
Binary file modified obj/Debug/TisButAScratch.dll
Binary file not shown.
Binary file modified obj/Debug/TisButAScratch.pdb
Binary file not shown.

0 comments on commit 019601e

Please sign in to comment.