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:
68
Content.Client/Placement/Modes/WallmountLight.cs
Normal file
68
Content.Client/Placement/Modes/WallmountLight.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user