Power-reading multitool (#5046)

* AMEPartComponent: Switch to ToolSystem.HasQuality because this bugs me.

* Multitool can read power when you examine a cable with the multitool held.

* Multitool power reading: Condense storage information

* power-sensing multitool: Fix ToolSystem ref.

* Power-reading multitools: Fix misuse of GetComponent
This commit is contained in:
20kdc
2021-10-29 13:42:18 +01:00
committed by GitHub
parent b2aca94586
commit 44f5f15790
6 changed files with 212 additions and 4 deletions

View File

@@ -31,6 +31,8 @@ namespace Content.Shared.Localizations
loc.LoadCulture(culture);
loc.AddFunction(culture, "PRESSURE", FormatPressure);
loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts);
loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules);
loc.AddFunction(culture, "TOSTRING", args => FormatToString(culture, args));
}
@@ -46,7 +48,7 @@ namespace Content.Shared.Localizations
return new LocValueString(obj?.ToString() ?? "");
}
private static ILocValue FormatPressure(LocArgs args)
private static ILocValue FormatUnitsGeneric(LocArgs args, string mode)
{
const int maxPlaces = 5; // Matches amount in _lib.ftl
var pressure = ((LocValueNumber) args.Args[0]).Value;
@@ -58,7 +60,22 @@ namespace Content.Shared.Localizations
places += 1;
}
return new LocValueString(Loc.GetString("zzzz-fmt-pressure", ("divided", pressure), ("places", places)));
return new LocValueString(Loc.GetString(mode, ("divided", pressure), ("places", places)));
}
private static ILocValue FormatPressure(LocArgs args)
{
return FormatUnitsGeneric(args, "zzzz-fmt-pressure");
}
private static ILocValue FormatPowerWatts(LocArgs args)
{
return FormatUnitsGeneric(args, "zzzz-fmt-power-watts");
}
private static ILocValue FormatPowerJoules(LocArgs args)
{
return FormatUnitsGeneric(args, "zzzz-fmt-power-joules");
}
}
}