Removes the ConstructorComponents and moves the construction blueprint feature into a new ECS system. (#1114)

This commit is contained in:
Acruid
2020-06-15 12:30:11 -07:00
committed by GitHub
parent 548b91df61
commit 189ed9309f
11 changed files with 302 additions and 330 deletions

View File

@@ -1,49 +1,51 @@
using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.EntitySystems;
using Content.Shared.Construction;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Placement;
using Robust.Client.Utility;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Client.Construction
{
public class ConstructionPlacementHijack : PlacementHijack
{
private readonly ConstructionPrototype Prototype;
private readonly ConstructorComponent Owner;
private readonly ConstructionSystem _constructionSystem;
private readonly ConstructionPrototype _prototype;
public ConstructionPlacementHijack(ConstructionPrototype prototype, ConstructorComponent owner)
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype prototype)
{
Prototype = prototype;
Owner = owner;
_constructionSystem = constructionSystem;
_prototype = prototype;
}
/// <inheritdoc />
public override bool HijackPlacementRequest(GridCoordinates coords)
{
if (Prototype != null)
if (_prototype != null)
{
var dir = Manager.Direction;
Owner.SpawnGhost(Prototype, coords, dir);
_constructionSystem.SpawnGhost(_prototype, coords, dir);
}
return true;
}
/// <inheritdoc />
public override bool HijackDeletion(IEntity entity)
{
if (entity.TryGetComponent(out ConstructionGhostComponent ghost))
{
Owner.ClearGhost(ghost.GhostID);
_constructionSystem.ClearGhost(ghost.GhostID);
}
return true;
}
/// <inheritdoc />
public override void StartHijack(PlacementManager manager)
{
base.StartHijack(manager);
manager.CurrentBaseSprite = Prototype.Icon.DirFrame0();
manager.CurrentBaseSprite = _prototype.Icon.DirFrame0();
}
}
}