Buildable wall light (#2644)

* Added empty light

* Can build light fixture

* Can construct and deconstruct small light

* You can build bulbs only on walls

* Playing with placement conditions

* Refactored code a bit

* Added check for north direction and snapping

* Fixed all small light sprites (wrong directions order)

* Fixed weird problem with bulb lights

* Fixed rotation on all stations

* Fixed map again

* Much better placement mode

* Deleted shared wall component and moved all logic to raycasts

* Missing bracket

* Better texture

* Moved wallmount condition to tags

* Removed station station

* Added suffix and fixed on map init bug
This commit is contained in:
Alex Evgrashin
2021-02-07 02:05:53 +03:00
committed by GitHub
parent 2f01d7899f
commit 59e72697cb
14 changed files with 306 additions and 59 deletions

View File

@@ -0,0 +1,68 @@
#nullable enable
using Robust.Client.Placement;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Content.Client.Placement.Modes
{
public class WallmountLight : PlacementMode
{
public WallmountLight(PlacementManager pMan) : base(pMan)
{
}
public override void AlignPlacementMode(ScreenCoordinates mouseScreen)
{
MouseCoords = ScreenToCursorGrid(mouseScreen);
CurrentTile = GetTileRef(MouseCoords);
if (pManager.CurrentPermission!.IsTile)
{
return;
}
var tileCoordinates = new EntityCoordinates(MouseCoords.EntityId, CurrentTile.GridIndices);
Vector2 offset;
switch (pManager.Direction)
{
case Direction.North:
offset = new Vector2(0.5f, 1f);
break;
case Direction.South:
offset = new Vector2(0.5f, 0f);
break;
case Direction.East:
offset = new Vector2(1f, 0.5f);
break;
case Direction.West:
offset = new Vector2(0f, 0.5f);
break;
default:
return;
}
tileCoordinates = tileCoordinates.Offset(offset);
MouseCoords = tileCoordinates;
}
public override bool IsValidPosition(EntityCoordinates position)
{
if (pManager.CurrentPermission!.IsTile)
{
return false;
}
else if (!RangeCheck(position))
{
return false;
}
return true;
}
}
}