Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stationary teleporters #32134

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
51f67ef
sprite, start work on systems
TheShuEd Sep 11, 2024
0ab33c3
Woah! Its work!
TheShuEd Sep 11, 2024
1e0c449
Show gateways! Yay!
TheShuEd Sep 11, 2024
f23e3bb
Update ring.png
TheShuEd Sep 11, 2024
77333f4
Update portal.yml
TheShuEd Sep 11, 2024
a5f7a36
bububui
TheShuEd Sep 11, 2024
2ecda9a
Fuck UI
TheShuEd Sep 12, 2024
3b30459
draw lines!
TheShuEd Sep 13, 2024
8d0bfc6
clear old links lines
TheShuEd Sep 13, 2024
8fbd697
UI button work now!
TheShuEd Sep 13, 2024
89eaa2b
we can cut links via UI now!
TheShuEd Sep 13, 2024
2ad9fc3
yay! linking via UI
TheShuEd Sep 13, 2024
f093773
comfortable linking
TheShuEd Sep 13, 2024
274b7e0
Update hand_teleporter.yml
TheShuEd Sep 13, 2024
5c18d59
ambience, linked entities events
TheShuEd Sep 13, 2024
f6c645f
nice connect and disconnect sounds!
TheShuEd Sep 13, 2024
691d545
unpowering and memory
TheShuEd Sep 13, 2024
2385d61
power fix
TheShuEd Sep 13, 2024
067e31e
chip added
TheShuEd Sep 13, 2024
963695f
chip linking & auto linking
TheShuEd Sep 13, 2024
7f86a86
chip examined
TheShuEd Sep 13, 2024
3aa106e
auto linked chips&gates variants
TheShuEd Sep 13, 2024
d52204f
Update meta.json
TheShuEd Sep 13, 2024
a16b573
Update computers.yml
TheShuEd Sep 13, 2024
6552a3b
syndicate gateway console, portal coloring, realtime UI update
TheShuEd Sep 15, 2024
2d2d6d2
QoL update
TheShuEd Sep 16, 2024
60ef8cb
Circuitboards
TheShuEd Sep 16, 2024
71d7e32
Update StationGatewayNavMapControl.cs
TheShuEd Sep 16, 2024
6969409
optimize Draw(), add Filled console variant
TheShuEd Sep 16, 2024
48500fb
documentation
TheShuEd Sep 16, 2024
fe25d43
Merge branch 'master' into ed-11-09-2024-station-gates
TheShuEd Sep 17, 2024
62f583b
Merge branch 'master' into ed-11-09-2024-station-gates
TheShuEd Sep 23, 2024
2f4f226
Merge branch 'master' into ed-11-09-2024-station-gates
TheShuEd Dec 17, 2024
eec5811
mass renaming bro
TheShuEd Dec 17, 2024
63eeae5
resprited
TheShuEd Dec 17, 2024
8b01c6c
resprite agani
TheShuEd Dec 18, 2024
e86775c
Update tags.yml
TheShuEd Dec 19, 2024
1159abd
Update Resources/Prototypes/Entities/Structures/Machines/station_tele…
TheShuEd Dec 19, 2024
3373bff
Update Resources/Prototypes/Entities/Structures/Machines/Computers/co…
TheShuEd Dec 19, 2024
ea85781
Update Resources/Prototypes/Entities/Structures/Machines/Computers/co…
TheShuEd Dec 19, 2024
fd520bf
Update Resources/Prototypes/Entities/Structures/Machines/Computers/co…
TheShuEd Dec 19, 2024
f57acca
Update Resources/Prototypes/Entities/Objects/Devices/teleporters_chip…
TheShuEd Dec 19, 2024
97a4b0a
Update Resources/Prototypes/Entities/Objects/Devices/Circuitboards/co…
TheShuEd Dec 19, 2024
599fccf
Update Resources/Prototypes/Entities/Objects/Devices/Circuitboards/co…
TheShuEd Dec 19, 2024
c5528b9
Update Resources/Prototypes/Entities/Objects/Devices/Circuitboards/co…
TheShuEd Dec 19, 2024
d6ce4c9
Update Resources/Prototypes/Entities/Objects/Devices/Circuitboards/co…
TheShuEd Dec 19, 2024
6e62385
Update Content.Server/StationTeleporter/Components/TeleporterChipComp…
TheShuEd Dec 19, 2024
8418370
Update Content.Shared/StationTeleporter/StationTeleporterComponent.cs
TheShuEd Dec 19, 2024
cc63f1b
renaming renaming
TheShuEd Dec 19, 2024
4b71351
sharedization
TheShuEd Dec 19, 2024
65510f1
UI fix
TheShuEd Dec 19, 2024
41a5d97
Data simplify
TheShuEd Dec 19, 2024
593dc78
remove autodeletion
TheShuEd Dec 19, 2024
ab990fe
PostWallDrawingAction
TheShuEd Dec 19, 2024
9120cf6
Update TeleporterChipComponent.cs
TheShuEd Dec 19, 2024
7a5aad0
fix lines offset
TheShuEd Dec 19, 2024
771a6b6
labeler renaming, rebound restiction removed
TheShuEd Dec 19, 2024
caf0f82
prevent link popup and sound spamming
TheShuEd Dec 19, 2024
53cc18a
auto linking refactor
TheShuEd Dec 19, 2024
42981ac
RD handheld teleporter integration
TheShuEd Dec 20, 2024
b13f177
fix randomteleport bug
TheShuEd Dec 20, 2024
f35eab3
Merge branch 'master' into ed-11-09-2024-station-gates
TheShuEd Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Client/Pinpointer/UI/NavMapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public partial class NavMapControl : MapGridControl
// Components
private NavMapComponent? _navMap;
private MapGridComponent? _grid;
private TransformComponent? _xform;
protected TransformComponent? _xform;
private PhysicsComponent? _physics;
private FixturesComponent? _fixtures;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Shared.StationTeleporter;
using Robust.Client.UserInterface;

namespace Content.Client.StationTeleporter;

public sealed class StationTeleporterConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private StationTeleporterConsoleWindow? _menu;

public StationTeleporterConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
EntityUid? gridUid = null;
var stationName = string.Empty;

if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;

if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
{
stationName = metaData.EntityName;
}
}

_menu = this.CreateWindow<StationTeleporterConsoleWindow>();
_menu.Set(this, stationName, gridUid);
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

switch (state)
{
case StationTeleporterState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowTeleporters(st, Owner, xform?.Coordinates);
break;
}
}

public void SendTeleporterLinkChangeMessage(NetEntity? teleporter)
{
SendMessage(new StationTeleporterClickMessage(teleporter));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.StationTeleporter"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'teleporter-console-user-interface-title'}"
Resizable="False"
SetSize="1010 700"
MinSize="1010 700">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" VerticalExpand="True" HorizontalExpand="True">
<ui:StationTeleporterNavMapControl Name="NavMap" HorizontalExpand="True" VerticalExpand="True" Margin="5 5"/>
<BoxContainer Orientation="Vertical" Margin="0 10 0 10">
<controls:StripeBack>
<PanelContainer>
<Label Name="StationName" Text="Unknown station" Align="Center" Margin="0 5 0 3"/>
</PanelContainer>
</controls:StripeBack>

<ScrollContainer Name="TeleportersScroller"
VerticalExpand="True"
SetWidth="320"
Margin="8, 8, 8, 8">
<BoxContainer Name="TeleportersTable"
Orientation="Vertical"
HorizontalExpand="True"
Margin="0 0 10 0">
<!-- Table rows are filled by code -->
</BoxContainer>
<Label Name="NoTeleportersLabel"
Text="{Loc 'teleporter-console-user-interface-no-teleporters'}"
StyleClasses="LabelHeading"
FontColorOverride="Red"
HorizontalAlignment="Center"
Visible="false"/>
</ScrollContainer>
</BoxContainer>
</BoxContainer>

<!-- Footer -->
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'teleporter-console-user-interface-flavor-left'}" StyleClasses="WindowFooterText" />
<Label Text="{Loc 'teleporter-console-user-interface-flavor-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
using Content.Client.Message;
using Content.Client.UserInterface.Controls;
using Content.Shared.StationTeleporter;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map;
using Robust.Shared.Utility;
using Content.Client.Pinpointer.UI;
using static Robust.Client.UserInterface.Controls.BoxContainer;

namespace Content.Client.StationTeleporter;

[GenerateTypedNameReferences]
public sealed partial class StationTeleporterConsoleWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entManager = default!;
private readonly SpriteSystem _spriteSystem;
private readonly SharedTransformSystem _xformSystem;

public event Action<NetEntity?>? SendTeleporterLinkChangeAction;

private NetEntity? _trackedEntity;
private Texture? _ringTexture;
private Texture? _ringFilledTexture;

public StationTeleporterConsoleWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_spriteSystem = _entManager.System<SpriteSystem>();
_xformSystem = _entManager.System<SharedTransformSystem>();

NavMap.TrackedEntitySelectedAction += ClickTeleporterOnNavMap;
}

public void Set(StationTeleporterConsoleBoundUserInterface userInterface, string stationName, EntityUid? mapUid)
{
_ringTexture =
_spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/ring.png")));
_ringFilledTexture =
_spriteSystem.Frame0(
new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/ring_filled.png")));

if (_entManager.TryGetComponent<TransformComponent>(mapUid, out var xform))
NavMap.MapUid = xform.GridUid;
else
NavMap.Visible = false;

StationName.AddStyleClass("LabelBig");
StationName.Text = stationName;
NavMap.ForceNavMapUpdate();

SendTeleporterLinkChangeAction += userInterface.SendTeleporterLinkChangeMessage;
}

public void ShowTeleporters(StationTeleporterState state, EntityUid monitor, EntityCoordinates? monitorCoords)
{
ClearOutDatedData();

var teleporters = state.Teleporters;

//No teleporters
if (teleporters.Count == 0)
{
NoTeleportersLabel.Visible = true;
return;
}

NoTeleportersLabel.Visible = false;


// Show all teleporters
foreach (var teleporter in teleporters)
{
var coordinates = _entManager.GetCoordinates(teleporter.Coordinates);

var selected = teleporter.TeleporterUid == state.SelectedTeleporter;
var linked = teleporter.LinkCoordinates is not null;

var bgColor = linked ? new Color(18, 61, 82) : new Color(30, 30, 34);
if (selected)
bgColor = new Color(49, 117, 7);


// Primary container to hold the button UI elements
var panelContainer = new PanelContainer()
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
HorizontalExpand = true,
Margin = new Thickness(10),
PanelOverride = new StyleBoxFlat
{
BackgroundColor = bgColor,
BorderColor = Color.Black,
BorderThickness = new(2),
},
};

TeleportersTable.AddChild(panelContainer);

var mainBox = new BoxContainer()
{
Orientation = LayoutOrientation.Vertical,
HorizontalExpand = true,
};

panelContainer.AddChild(mainBox);


// Teleporter name
var nameLabel = new RichTextLabel()
{
HorizontalExpand = true,
HorizontalAlignment = HAlignment.Center,
Margin = new Thickness(0, 5),
};
nameLabel.SetMarkup($"[bold]{teleporter.Name}[/bold]");

mainBox.AddChild(nameLabel);


//Left subpart
var leftBox = new BoxContainer()
{
SetWidth = 30,
Orientation = LayoutOrientation.Vertical,
HorizontalExpand = true,
};

mainBox.AddChild(leftBox);


//Right subpart
var rightBox = new BoxContainer()
{
Orientation = LayoutOrientation.Vertical,
HorizontalExpand = true,
};

mainBox.AddChild(rightBox);


// Locating button
var locateButton = new TeleporterButton()
{
Text = Loc.GetString("teleporter-console-user-interface-locate"),
TeleporterUid = teleporter.TeleporterUid,
Coordinates = coordinates,
HorizontalAlignment = HAlignment.Right,
SetWidth = 200f,
};

rightBox.AddChild(locateButton);


// Link\Unlink button
var buttonLoc = "teleporter-console-user-interface-start-connection";
if (linked)
buttonLoc = "teleporter-console-user-interface-cut-connection";
if (!teleporter.Powered)
buttonLoc = "teleporter-console-user-interface-no-power";

var linkButton = new TeleporterButton()
{
Text = Loc.GetString(buttonLoc),
TeleporterUid = teleporter.TeleporterUid,
Coordinates = coordinates,
HorizontalAlignment = HAlignment.Right,
SetWidth = 200f,
Disabled = !teleporter.Powered,
};
linkButton.OnButtonUp += _ =>
{
SendTeleporterLinkChangeAction?.Invoke(teleporter.TeleporterUid);
};

rightBox.AddChild(linkButton);


//Add teleporter coordinates to the NavMap
var blipColor = Color.Aqua;
if (!teleporter.Powered)
blipColor = Color.Gray;
if (selected)
blipColor = Color.Green;

if (coordinates != null && NavMap.Visible && _ringTexture is not null && _ringFilledTexture is not null)
{
var blip = new NavMapBlip(
coordinates.Value,
linked ? _ringFilledTexture : _ringTexture,
blipColor,
false);
NavMap.TrackedEntities.TryAdd(teleporter.TeleporterUid, blip);

locateButton.OnButtonUp += _ =>
{
if (_trackedEntity == teleporter.TeleporterUid)
_trackedEntity = null;
else
{
_trackedEntity = teleporter.TeleporterUid;
NavMap.CenterToCoordinates(coordinates.Value);
}

UpdateTeleportersTable();
};
}

//Add teleporters links lines
if (teleporter.Coordinates is not null && teleporter.LinkCoordinates is not null)
{
var coordsOne = _entManager.GetCoordinates(teleporter.Coordinates);
var coordTwo = _entManager.GetCoordinates(teleporter.LinkCoordinates);

if (coordsOne is null || coordTwo is null)
return;

var mapId1 = _xformSystem.GetMapId(coordsOne.Value);
var mapId2 = _xformSystem.GetMapId(coordTwo.Value);

if (mapId1 != mapId2)
return;

if (mapId1 == MapId.Nullspace || mapId2 == MapId.Nullspace)
return;

NavMap.LinkedTeleportersCoordinates.Add((
_xformSystem.ToMapCoordinates(coordsOne.Value).Position,
_xformSystem.ToMapCoordinates(coordTwo.Value).Position));
}
}
}

private void ClickTeleporterOnNavMap(NetEntity? netEntity)
{
SendTeleporterLinkChangeAction?.Invoke(netEntity);
}

private void ClearOutDatedData()
{
TeleportersTable.RemoveAllChildren();
NavMap.TrackedCoordinates.Clear();
NavMap.TrackedEntities.Clear();
NavMap.LinkedTeleportersCoordinates.Clear();
}

private void UpdateTeleportersTable()
{
foreach (var teleporter in TeleportersTable.Children)
{
if (teleporter is not TeleporterButton)
continue;

var castTeleporter = (TeleporterButton)teleporter;

if (castTeleporter?.Coordinates == null)
continue;

if (NavMap.TrackedEntities.TryGetValue(castTeleporter.TeleporterUid, out var data))
{
data = new NavMapBlip(
data.Coordinates,
data.Texture,
Color.Aqua,
false);

NavMap.TrackedEntities[castTeleporter.TeleporterUid] = data;
}
}
}
}

public sealed class TeleporterButton : Button
{
public int IndexInTable;
public NetEntity TeleporterUid;
public EntityCoordinates? Coordinates;
}
Loading
Loading