ConstructionPlacementHijack nullability fix

This commit is contained in:
Víctor Aguilera Puerto
2020-10-19 15:43:12 +02:00
parent 7ad46ddabf
commit 90b7239dcb

View File

@@ -1,4 +1,5 @@
using Content.Client.GameObjects.Components.Construction;
#nullable enable
using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.EntitySystems;
using Content.Shared.Construction;
using Robust.Client.Placement;
@@ -11,15 +12,15 @@ namespace Content.Client.Construction
public sealed class ConstructionPlacementHijack : PlacementHijack
{
private readonly ConstructionSystem _constructionSystem;
private readonly ConstructionPrototype _prototype;
private readonly ConstructionPrototype? _prototype;
public override bool CanRotate { get; }
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype prototype)
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype? prototype)
{
_constructionSystem = constructionSystem;
_prototype = prototype;
CanRotate = prototype.CanRotate;
CanRotate = prototype?.CanRotate ?? true;
}
/// <inheritdoc />
@@ -36,7 +37,7 @@ namespace Content.Client.Construction
/// <inheritdoc />
public override bool HijackDeletion(IEntity entity)
{
if (entity.TryGetComponent(out ConstructionGhostComponent ghost))
if (entity.TryGetComponent(out ConstructionGhostComponent? ghost))
{
_constructionSystem.ClearGhost(ghost.GhostID);
}
@@ -48,7 +49,7 @@ namespace Content.Client.Construction
{
base.StartHijack(manager);
manager.CurrentBaseSprite = _prototype.Icon.DirFrame0();
manager.CurrentBaseSprite = _prototype?.Icon.DirFrame0();
}
}
}