* Update RobustToolbox * Transition direct type usages * More updates * Fix invalid use of to map * Update RobustToolbox * Fix dropping items * Rename name usages of "GridCoordinates" to "EntityCoordinates" * Revert "Update RobustToolbox" This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346. * Revert "Update RobustToolbox" This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09. # Conflicts: # RobustToolbox * Fix cursed IMapGrid method usage. * GridTileLookupTest now uses EntityCoordinates Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es>
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Content.Client.GameObjects.Components.Construction;
|
|
using Content.Client.GameObjects.EntitySystems;
|
|
using Content.Shared.Construction;
|
|
using Robust.Client.Placement;
|
|
using Robust.Client.Utility;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Client.Construction
|
|
{
|
|
public class ConstructionPlacementHijack : PlacementHijack
|
|
{
|
|
private readonly ConstructionSystem _constructionSystem;
|
|
private readonly ConstructionPrototype _prototype;
|
|
|
|
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype prototype)
|
|
{
|
|
_constructionSystem = constructionSystem;
|
|
_prototype = prototype;
|
|
}
|
|
|
|
/// <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);
|
|
|
|
manager.CurrentBaseSprite = _prototype.Icon.DirFrame0();
|
|
}
|
|
}
|
|
}
|