Files
tbd-station-14/Content.Client/Construction/ConstructionPlacementHijack.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

66 lines
2.0 KiB
C#

#nullable enable
using System.Collections.Generic;
using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.EntitySystems;
using Content.Shared.Construction;
using Robust.Client.Graphics;
using Robust.Client.Placement;
using Robust.Client.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Client.Construction
{
public sealed class ConstructionPlacementHijack : PlacementHijack
{
private readonly ConstructionSystem _constructionSystem;
private readonly ConstructionPrototype? _prototype;
public override bool CanRotate { get; }
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype? prototype)
{
_constructionSystem = constructionSystem;
_prototype = prototype;
CanRotate = prototype?.CanRotate ?? true;
}
/// <inheritdoc />
public override bool HijackPlacementRequest(EntityCoordinates coordinates)
{
if (_prototype != null)
{
var dir = Manager.Direction;
_constructionSystem.SpawnGhost(_prototype, coordinates, dir);
}
return true;
}
/// <inheritdoc />
public override bool HijackDeletion(IEntity entity)
{
if (entity.TryGetComponent(out ConstructionGhostComponent? ghost))
{
_constructionSystem.ClearGhost(ghost.GhostID);
}
return true;
}
/// <inheritdoc />
public override void StartHijack(PlacementManager manager)
{
base.StartHijack(manager);
var frame = _prototype?.Icon.DirFrame0();
if (frame == null)
{
manager.CurrentTextures = null;
}
else
{
manager.CurrentTextures = new List<IDirectionalTextureProvider> {frame};
}
}
}
}