Outlines moved to InteractionOutlineComponent, now change color when in interaction range.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using Robust.Client.Graphics.Shaders;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class InteractionOutlineComponent : Component
|
||||
{
|
||||
private const string ShaderInRange = "selection_outline_inrange";
|
||||
private const string ShaderOutOfRange = "selection_outline";
|
||||
|
||||
public override string Name => "InteractionOutline";
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private ShaderInstance _selectionShaderInstance;
|
||||
private ShaderInstance _selectionShaderInRangeInstance;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_selectionShaderInRangeInstance = _prototypeManager.Index<ShaderPrototype>(ShaderInRange).Instance();
|
||||
_selectionShaderInstance = _prototypeManager.Index<ShaderPrototype>(ShaderOutOfRange).Instance();
|
||||
}
|
||||
|
||||
public void OnMouseEnter(bool inInteractionRange)
|
||||
{
|
||||
if (Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance;
|
||||
sprite.RenderOrder = Owner.EntityManager.CurrentTick.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseLeave()
|
||||
{
|
||||
if (Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
sprite.PostShader = null;
|
||||
sprite.RenderOrder = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInRange(bool inInteractionRange)
|
||||
{
|
||||
if (Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects;
|
||||
using Robust.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Interfaces.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
@@ -63,21 +66,37 @@ namespace Content.Client.State
|
||||
|
||||
var mousePosWorld = eyeManager.ScreenToWorld(new ScreenCoordinates(inputManager.MouseScreenPosition));
|
||||
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
||||
|
||||
var inRange = false;
|
||||
if (playerManager.LocalPlayer.ControlledEntity != null && entityToClick != null)
|
||||
{
|
||||
var playerPos = playerManager.LocalPlayer.ControlledEntity.Transform.GridPosition;
|
||||
var entityPos = entityToClick.Transform.GridPosition;
|
||||
var distance = playerPos.Distance(_mapManager, entityPos);
|
||||
inRange = distance <= VerbUtility.InteractionRange;
|
||||
}
|
||||
|
||||
InteractionOutlineComponent outline;
|
||||
if (entityToClick == lastHoveredEntity)
|
||||
{
|
||||
if (entityToClick != null && entityToClick.TryGetComponent(out outline))
|
||||
{
|
||||
outline.UpdateInRange(inRange);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastHoveredEntity != null && !lastHoveredEntity.Deleted)
|
||||
if (lastHoveredEntity != null && !lastHoveredEntity.Deleted &&
|
||||
lastHoveredEntity.TryGetComponent(out outline))
|
||||
{
|
||||
lastHoveredEntity.GetComponent<IClientClickableComponent>().OnMouseLeave();
|
||||
outline.OnMouseLeave();
|
||||
}
|
||||
|
||||
lastHoveredEntity = entityToClick;
|
||||
|
||||
if (lastHoveredEntity != null)
|
||||
if (lastHoveredEntity != null && lastHoveredEntity.TryGetComponent(out outline))
|
||||
{
|
||||
lastHoveredEntity.GetComponent<IClientClickableComponent>().OnMouseEnter();
|
||||
outline.OnMouseEnter(inRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +110,8 @@ namespace Content.Client.State
|
||||
{
|
||||
// Find all the entities intersecting our click
|
||||
var worldCoords = coordinates.ToWorld(_mapManager);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(_mapManager.GetGrid(coordinates.GridID).ParentMapId, worldCoords.Position);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(_mapManager.GetGrid(coordinates.GridID).ParentMapId,
|
||||
worldCoords.Position);
|
||||
|
||||
// Check the entities against whether or not we can click them
|
||||
var foundEntities = new List<(IEntity clicked, int drawDepth)>();
|
||||
@@ -123,6 +143,7 @@ namespace Content.Client.State
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
var transx = x.clicked.Transform;
|
||||
var transy = y.clicked.Transform;
|
||||
return transx.GridPosition.Y.CompareTo(transy.GridPosition.Y);
|
||||
@@ -142,7 +163,8 @@ namespace Content.Client.State
|
||||
|
||||
var mousePosWorld = eyeManager.ScreenToWorld(args.PointerLocation);
|
||||
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
||||
var message = new FullInputCmdMessage(timing.CurTick, funcId, args.State, mousePosWorld, args.PointerLocation, entityToClick?.Uid ?? EntityUid.Invalid);
|
||||
var message = new FullInputCmdMessage(timing.CurTick, funcId, args.State, mousePosWorld,
|
||||
args.PointerLocation, entityToClick?.Uid ?? EntityUid.Invalid);
|
||||
|
||||
// client side command handlers will always be sent the local player session.
|
||||
var session = playerManager.LocalPlayer.Session;
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace Content.Server
|
||||
"LowWall",
|
||||
"Window",
|
||||
"CharacterInfo",
|
||||
"InteractionOutline",
|
||||
"MeleeWeaponArcAnimation",
|
||||
"AnimationsTest",
|
||||
};
|
||||
|
||||
foreach (var ignoreName in registerIgnore)
|
||||
@@ -49,6 +52,7 @@ namespace Content.Server
|
||||
var cast = (ServerModuleTestingCallbacks) TestingCallbacks;
|
||||
cast.ServerBeforeIoC?.Invoke();
|
||||
}
|
||||
|
||||
IoCManager.BuildGraph();
|
||||
|
||||
_gameTicker = IoCManager.Resolve<IGameTicker>();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: Thing that heats up on its own and dies
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
texture: Objects/Misc/shoes.png
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
- type: Icon
|
||||
texture: Objects/Janitorial/mopbucket.png
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Solution
|
||||
maxVol: 500
|
||||
caps: 3
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
sprite: Buildings/research.rsi
|
||||
state: server
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
@@ -34,6 +35,7 @@
|
||||
sprite: Buildings/research.rsi
|
||||
state: tdoppler
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
description: It opens, it closes, and maybe crushes you.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
components:
|
||||
- type: AsteroidRock
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
sprite: Buildings/Walls/asteroid_rock.rsi
|
||||
state: 0
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: Catwalk
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
mass: 25
|
||||
Anchored: true
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
IsScrapingFloor: true
|
||||
shapes:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
texture: Buildings/weldtank.png
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
id: stool
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
sprite: Buildings/furniture.rsi
|
||||
@@ -18,6 +19,7 @@
|
||||
components:
|
||||
- type: Rotatable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
sprite: Buildings/furniture.rsi
|
||||
@@ -32,6 +34,7 @@
|
||||
components:
|
||||
- type: Rotatable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
sprite: Buildings/furniture.rsi
|
||||
@@ -45,6 +48,7 @@
|
||||
id: chair
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
sprite: Buildings/furniture.rsi
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: Girder
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
texture: Buildings/wall_girder.png
|
||||
- type: Icon
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
handheld: false
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
|
||||
- type: Collidable
|
||||
shapes:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: "Lathe"
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: "Unpowered Light"
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sound
|
||||
- type: Sprite
|
||||
@@ -29,6 +30,7 @@
|
||||
parent: wall_light
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
sprite: Buildings/light_tube.rsi
|
||||
@@ -53,6 +55,7 @@
|
||||
parent: wall_light
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
sprite: Buildings/light_small.rsi
|
||||
state: off
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
description: Goes up to about your waist.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
color: "#71797a"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
state: scanner_open
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
- !type:PhysShapeAabb
|
||||
layer: 32
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
mass: 25
|
||||
Anchored: true
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
description: Transfers power, avoid letting things come down it
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
@@ -40,6 +41,7 @@
|
||||
description: A portal to hell which summons power from the nether
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -57,6 +59,7 @@
|
||||
description: Supplies power directly to nearby objects
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -113,6 +116,7 @@
|
||||
description: Stores power in its super-magnetic cells
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -152,6 +156,7 @@
|
||||
description: A monstrosity that does nothing but suck up power from the nearby wires
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -172,6 +177,7 @@
|
||||
description: A terrifying monstrosity that sucks up power from the wireless transmitters, Tesla would be proud
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
id: reagent_dispenser_base
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
state: generic_door
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
state: crate
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: "worktop"
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: PlaceableSurface
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: Turret Base
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
texture: Buildings/TurrBase.png
|
||||
@@ -12,6 +13,7 @@
|
||||
name: Turret (Gun)
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
drawdepth: WallMountedItems
|
||||
@@ -26,6 +28,7 @@
|
||||
name: Turret (Light)
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
- type: Sprite
|
||||
drawdepth: WallMountedItems
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
Anchored: true
|
||||
- type: Rotatable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
sprite: Buildings/VendingMachines/empty.rsi
|
||||
layers:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
description: Keeps the air in and the greytide out.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Walls
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
description: Don't smudge up the glass down there.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: WallTops
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
- type: Item
|
||||
Size: 5
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
- type: Physics
|
||||
mass: 5
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -149,6 +150,7 @@
|
||||
- type: Physics
|
||||
mass: 5
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
@@ -179,6 +181,7 @@
|
||||
- type: Physics
|
||||
mass: 5
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
shapes:
|
||||
- !type:PhysShapeAabb
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
- type: ConstructionGhost
|
||||
- type: Collidable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
|
||||
- type: entity
|
||||
name: somebody-messed-up frame
|
||||
@@ -18,3 +19,4 @@
|
||||
- type: Construction
|
||||
- type: Collidable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
- type: Inventory
|
||||
- type: Constructor
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
texture: Buildings/watertank.png
|
||||
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Collidable
|
||||
layer: 31
|
||||
shape:
|
||||
@@ -42,4 +43,3 @@
|
||||
reagents:
|
||||
- ReagentId: chem.H2O
|
||||
Quantity: 1500
|
||||
|
||||
@@ -5,3 +5,11 @@
|
||||
params:
|
||||
outline_width: 2
|
||||
outline_color: "#FF000055"
|
||||
|
||||
- type: shader
|
||||
id: selection_outline_inrange
|
||||
kind: source
|
||||
path: "/Shaders/outline.swsl"
|
||||
params:
|
||||
outline_width: 2
|
||||
outline_color: "#00FF0055"
|
||||
|
||||
Reference in New Issue
Block a user