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,7 +1,7 @@
using Content.Server.GameObjects.Components.Stack;
#nullable enable
using Content.Server.GameObjects.Components.Stack;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.Interfaces.Map;
@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Power
public override string Name => "WirePlacer";
[ViewVariables]
private string _wirePrototypeID;
private string? _wirePrototypeID;
[ViewVariables]
private WireType _blockingWireType;
@@ -36,6 +36,9 @@ namespace Content.Server.GameObjects.Components.Power
/// <inheritdoc />
public async Task AfterInteract(AfterInteractEventArgs eventArgs)
{
if (_wirePrototypeID == null)
return;
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return;
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid))
return;
@@ -50,7 +53,7 @@ namespace Content.Server.GameObjects.Components.Power
return;
}
}
if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1))
if (Owner.TryGetComponent<StackComponent>(out var stack) && !stack.Use(1))
return;
Owner.EntityManager.SpawnEntity(_wirePrototypeID, grid.GridTileToLocal(snapPos));
}