mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 07:12:27 +02:00
RobustToolbox projects should be named Robust.* This PR changes the RobustToolbox projects from SS14.* to Robust.* Updates SS14.* prefixes/namespaces to Robust.* Updates SpaceStation14.sln to RobustToolbox.sln Updates MSBUILD/SS14.* to MSBUILD/Robust.* Updates CSProject and MSBuild references for the above Updates git_helper.py Removes Runserver and Runclient as they are unusable
65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using Robust.Client.Interfaces.GameObjects;
|
|
using Robust.Client.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Input;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Client.GameObjects
|
|
{
|
|
// Notice: Most actual logic for clicking is done by the game screen.
|
|
public class ClickableComponent : Component, IClientClickableComponent
|
|
{
|
|
private string _baseShader;
|
|
private string _selectionShader;
|
|
|
|
public override string Name => "Clickable";
|
|
public override uint? NetID => NetIDs.CLICKABLE;
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public string BaseShader { get => _baseShader; private set => _baseShader = value; }
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public string SelectionShader { get => _selectionShader; set => _selectionShader = value; }
|
|
|
|
public override void ExposeData(Shared.Serialization.ObjectSerializer serializer)
|
|
{
|
|
serializer.DataFieldCached(ref _baseShader, "baseshader", "shaded");
|
|
serializer.DataFieldCached(ref _selectionShader, "selectionshader", "selection_outline");
|
|
}
|
|
|
|
public bool CheckClick(GridCoordinates worldPos, out int drawdepth)
|
|
{
|
|
var component = Owner.GetComponent<IClickTargetComponent>();
|
|
|
|
if (Owner.TryGetComponent(out ISpriteComponent sprite) && !sprite.Visible)
|
|
{
|
|
drawdepth = default;
|
|
return false;
|
|
}
|
|
|
|
drawdepth = (int)component.DrawDepth;
|
|
return true;
|
|
}
|
|
|
|
public void DispatchClick(IEntity user, ClickType clickType)
|
|
{
|
|
var message = new ClientEntityClickMsg(user.Uid, clickType);
|
|
SendMessage(message);
|
|
}
|
|
|
|
public void OnMouseEnter()
|
|
{
|
|
var sprite = Owner.GetComponent<ISpriteComponent>();
|
|
sprite.LayerSetShader(0, SelectionShader);
|
|
}
|
|
|
|
public void OnMouseLeave()
|
|
{
|
|
var sprite = Owner.GetComponent<ISpriteComponent>();
|
|
sprite.LayerSetShader(0, BaseShader);
|
|
}
|
|
}
|
|
}
|