Machine upgrade examine verb (#12119)

This commit is contained in:
0x6273
2022-11-04 04:27:47 +01:00
committed by GitHub
parent 5ede1f4862
commit a201d777bc
22 changed files with 205 additions and 3 deletions

View File

@@ -15,9 +15,11 @@ public sealed class UpgradePowerSystem : EntitySystem
{
SubscribeLocalEvent<UpgradePowerDrawComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<UpgradePowerDrawComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<UpgradePowerDrawComponent, UpgradeExamineEvent>(OnUpgradeExamine);
SubscribeLocalEvent<UpgradePowerSupplierComponent, MapInitEvent>(OnSupplierMapInit);
SubscribeLocalEvent<UpgradePowerSupplierComponent, RefreshPartsEvent>(OnSupplierRefreshParts);
SubscribeLocalEvent<UpgradePowerSupplierComponent, UpgradeExamineEvent>(OnSupplierUpgradeExamine);
}
private void OnMapInit(EntityUid uid, UpgradePowerDrawComponent component, MapInitEvent args)
@@ -51,6 +53,16 @@ public sealed class UpgradePowerSystem : EntitySystem
powa2.DrawRate = load;
}
private void OnUpgradeExamine(EntityUid uid, UpgradePowerDrawComponent component, UpgradeExamineEvent args)
{
// UpgradePowerDrawComponent.PowerDrawMultiplier is not the actual multiplier, so we have to do this.
var powerDrawMultiplier = CompOrNull<ApcPowerReceiverComponent>(uid)?.Load / component.BaseLoad
?? CompOrNull<PowerConsumerComponent>(uid)?.DrawRate / component.BaseLoad;
if (powerDrawMultiplier is not null)
args.AddPercentageUpgrade("upgrade-power-draw", powerDrawMultiplier.Value);
}
private void OnSupplierMapInit(EntityUid uid, UpgradePowerSupplierComponent component, MapInitEvent args)
{
if (TryComp<PowerSupplierComponent>(uid, out var supplier))
@@ -77,4 +89,11 @@ public sealed class UpgradePowerSystem : EntitySystem
break;
}
}
private void OnSupplierUpgradeExamine(EntityUid uid, UpgradePowerSupplierComponent component, UpgradeExamineEvent args)
{
// UpgradePowerSupplierComponent.PowerSupplyMultiplier is not the actual multiplier, so we have to do this.
if (TryComp<PowerSupplierComponent>(uid, out var powa))
args.AddPercentageUpgrade("upgrade-power-supply", powa.MaxSupply / component.BaseSupplyRate);
}
}