Construction System. (#87)
* Construction WiP * Construction kinda works! * Lots more construction work. * It mostly works!
This commit is contained in:
committed by
GitHub
parent
f051078c79
commit
d7074bf74f
62
Content.Client/Construction/ConstructionPlacementHijack.cs
Normal file
62
Content.Client/Construction/ConstructionPlacementHijack.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Content.Client.GameObjects.Components.Construction;
|
||||
using Content.Shared.Construction;
|
||||
using SS14.Client.Graphics;
|
||||
using SS14.Client.Interfaces.ResourceManagement;
|
||||
using SS14.Client.Placement;
|
||||
using SS14.Client.ResourceManagement;
|
||||
using SS14.Client.Utility;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Map;
|
||||
using SS14.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Construction
|
||||
{
|
||||
public class ConstructionPlacementHijack : PlacementHijack
|
||||
{
|
||||
private readonly ConstructionPrototype Prototype;
|
||||
private readonly ConstructorComponent Owner;
|
||||
|
||||
public ConstructionPlacementHijack(ConstructionPrototype prototype, ConstructorComponent owner)
|
||||
{
|
||||
Prototype = prototype;
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
public override bool HijackPlacementRequest(GridLocalCoordinates coords)
|
||||
{
|
||||
if (Prototype != null)
|
||||
{
|
||||
// Stupid god damn Y AXIS.
|
||||
var dir = Manager.Direction;
|
||||
if (dir == Direction.South)
|
||||
{
|
||||
dir = Direction.North;
|
||||
}
|
||||
else if (dir == Direction.North)
|
||||
{
|
||||
dir = Direction.South;
|
||||
}
|
||||
Owner.SpawnGhost(Prototype, coords, dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HijackDeletion(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out ConstructionGhostComponent ghost))
|
||||
{
|
||||
Owner.ClearGhost(ghost.GhostID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void StartHijack(PlacementManager manager)
|
||||
{
|
||||
base.StartHijack(manager);
|
||||
|
||||
var res = IoCManager.Resolve<IResourceCache>();
|
||||
manager.CurrentBaseSprite = Prototype.Icon.DirFrame0();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user