Some Power nullable & ComponentDependency (#3050)

* Power nullability

* AME nullability

* re-adds EnsureComponents

* conflict fix

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryStorageComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryStorageComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryDischargerComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryDischargerComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* removes duplicate component assignment

Co-authored-by: py01 <pyronetics01@gmail.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
collinlunn
2021-02-01 10:19:43 -06:00
committed by GitHub
parent 044040effe
commit b51b8cb182
18 changed files with 94 additions and 62 deletions

View File

@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Server.GameObjects;
@@ -62,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Power.PowerNetComponents
private void UpdateSupply()
{
if (Owner.TryGetComponent(out PowerSupplierComponent supplier))
if (Owner.TryGetComponent<PowerSupplierComponent>(out var supplier))
{
supplier.SupplyRate = (int) (_maxSupply * _coverage);
}
@@ -72,7 +73,7 @@ namespace Content.Server.GameObjects.Components.Power.PowerNetComponents
{
base.Initialize();
Owner.EnsureComponentWarn(out PowerSupplierComponent _);
Owner.EnsureComponentWarn<PowerSupplierComponent>();
UpdateSupply();
}
@@ -86,7 +87,9 @@ namespace Content.Server.GameObjects.Components.Power.PowerNetComponents
public void OnBreak(BreakageEventArgs args)
{
var sprite = Owner.GetComponent<SpriteComponent>();
if (!Owner.TryGetComponent<SpriteComponent>(out var sprite))
return;
sprite.LayerSetState(0, "broken");
MaxSupply = 0;
}