Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stun and stagger info display added #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/-/Languages/English/Keyed/Layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<RimHUD.Layout.Carrying>Carrying</RimHUD.Layout.Carrying>
<RimHUD.Layout.CompInfo>Extra information</RimHUD.Layout.CompInfo>
<RimHUD.Layout.PrisonerInfo>Prisoner information</RimHUD.Layout.PrisonerInfo>
<RimHUD.Layout.StunInfo>Stun and stagger information</RimHUD.Layout.StunInfo>

<RimHUD.Layout.Target.PlayerHumanlike>Player Humanlike</RimHUD.Layout.Target.PlayerHumanlike>
<RimHUD.Layout.Target.OtherHumanlike>Other Humanlike</RimHUD.Layout.Target.OtherHumanlike>
Expand Down
1 change: 1 addition & 0 deletions source/-/Languages/English/Keyed/Model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<RimHUD.Model.Info.Queued>Queued: {0}</RimHUD.Model.Info.Queued>
<RimHUD.Model.Info.Equipped>Equipped: {0}</RimHUD.Model.Info.Equipped>
<RimHUD.Model.Info.Carrying>Carrying: {0}</RimHUD.Model.Info.Carrying>
<RimHUD.Model.Info.StunInfo>{0}</RimHUD.Model.Info.StunInfo>

<RimHUD.Model.Selector.OutfitFormat>Outfit: {0}</RimHUD.Model.Selector.OutfitFormat>
<RimHUD.Model.Selector.FoodFormat>Food: {0}</RimHUD.Model.Selector.FoodFormat>
Expand Down
3 changes: 2 additions & 1 deletion source/Interface/Hud/HudContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static class HudContent
HudWidget.FromModel<EquippedValue>("Equipped"),
HudWidget.FromModel<CarryingValue>("Carrying"),
HudWidget.FromModel<CompInfoValue>("CompInfo"),
HudWidget.FromModel<PrisonerInfoValue>("PrisonerInfo")
HudWidget.FromModel<PrisonerInfoValue>("PrisonerInfo"),
HudWidget.FromModel<StunInfoValue>("StunInfo")
};

private static readonly HudWidget[] BarWidgets =
Expand Down
49 changes: 49 additions & 0 deletions source/Interface/Hud/Models/Values/StunInfoValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using RimHUD.Configuration;
using RimHUD.Configuration.Settings;
using RimHUD.Engine;
using Verse;

namespace RimHUD.Interface.Hud.Models.Values
{
public sealed class StunInfoValue : ValueModel
{
protected override string Value { get; }

protected override TextStyle TextStyle => Theme.SmallTextStyle;

public StunInfoValue()
{
Value = GetValue();
}

private static string GetValue()
{
string str = "";

var stunner = Active.Pawn.stances?.stunner;
if (stunner is not null && stunner.Stunned)
{
if (stunner.Hypnotized)
{
str += "InTrance".Translate();
}
else if (stunner.StunFromEMP)
{
str += "StunnedByEMP".Translate() + ": " + stunner.StunTicksLeft.ToStringSecondsFromTicks();
}
else
{
str += "StunLower".Translate().CapitalizeFirst() + ": " + stunner.StunTicksLeft.ToStringSecondsFromTicks();
}
}

var stagger = Active.Pawn.stances?.stagger;
if (stagger is not null && stagger.Staggered)
{
str += (str.NullOrEmpty() ? "" : "\n") + "SlowedByDamage".Translate() + ": " + stagger.StaggerTicksLeft.ToStringSecondsFromTicks();
}

return Lang.Get("Model.Info.StunInfo", str);
}
}
}
3 changes: 2 additions & 1 deletion source/RimHUD.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -173,6 +173,7 @@
<Compile Include="Interface\Hud\Models\Values\SkillSocialValue.cs" />
<Compile Include="Interface\Hud\Models\Values\SkillValue.cs" />
<Compile Include="Interface\Hud\Models\Values\StatValue.cs" />
<Compile Include="Interface\Hud\Models\Values\StunInfoValue.cs" />
<Compile Include="Interface\Hud\Models\Values\TrainableValue.cs" />
<Compile Include="Interface\Hud\Tooltips\AnimalTooltip.cs" />
<Compile Include="Interface\Hud\Tooltips\BioTooltip.cs" />
Expand Down