This reverts commit 1f6663912b.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using Content.Client.Parallax.Managers;
|
using Content.Client.Parallax.Managers;
|
||||||
using Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Parallax.Biomes;
|
using Content.Shared.Parallax.Biomes;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -20,7 +19,6 @@ public sealed class ParallaxOverlay : Overlay
|
|||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly IParallaxManager _manager = default!;
|
[Dependency] private readonly IParallaxManager _manager = default!;
|
||||||
private readonly ParallaxSystem _parallax;
|
private readonly ParallaxSystem _parallax;
|
||||||
private readonly SharedZLevelSystem _zlevel = default!;
|
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowWorld;
|
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowWorld;
|
||||||
|
|
||||||
@@ -29,12 +27,11 @@ public sealed class ParallaxOverlay : Overlay
|
|||||||
ZIndex = ParallaxSystem.ParallaxZIndex;
|
ZIndex = ParallaxSystem.ParallaxZIndex;
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
_parallax = _entManager.System<ParallaxSystem>();
|
_parallax = _entManager.System<ParallaxSystem>();
|
||||||
_zlevel = _entManager.System<SharedZLevelSystem>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
if (args.MapId == MapId.Nullspace || _entManager.HasComponent<BiomeComponent>(_mapManager.GetMapEntityId(args.MapId)) || _zlevel.MapBelow[(int)args.MapId] != null)
|
if (args.MapId == MapId.Nullspace || _entManager.HasComponent<BiomeComponent>(_mapManager.GetMapEntityId(args.MapId)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Client.UserInterface.Systems.Gameplay;
|
using Content.Client.UserInterface.Systems.Gameplay;
|
||||||
using Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -79,28 +77,16 @@ public sealed class ViewportUIController : UIController
|
|||||||
|
|
||||||
base.FrameUpdate(e);
|
base.FrameUpdate(e);
|
||||||
|
|
||||||
|
|
||||||
Viewport.Viewport.Eye = _eyeManager.CurrentEye;
|
Viewport.Viewport.Eye = _eyeManager.CurrentEye;
|
||||||
|
|
||||||
// verify that the current eye is not "null". Fuck IEyeManager.
|
// verify that the current eye is not "null". Fuck IEyeManager.
|
||||||
|
|
||||||
var ent = _playerMan.LocalPlayer?.ControlledEntity;
|
var ent = _playerMan.LocalPlayer?.ControlledEntity;
|
||||||
if (_entMan.TryGetComponent(ent, out ZViewComponent? view))
|
|
||||||
{
|
|
||||||
Viewport.Viewport.LowerEyes = view.DownViewEnts.Select(x =>
|
|
||||||
{
|
|
||||||
var eye = _entMan.GetComponent<EyeComponent>(x);
|
|
||||||
eye.Rotation = _eyeManager.CurrentEye.Rotation;
|
|
||||||
eye.DrawFov = false; // We're z leveling, no FoV.
|
|
||||||
return eye.Eye!;
|
|
||||||
}).ToArray();
|
|
||||||
}
|
|
||||||
if (_eyeManager.CurrentEye.Position != default || ent == null)
|
if (_eyeManager.CurrentEye.Position != default || ent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_entMan.TryGetComponent(ent, out EyeComponent? eye);
|
_entMan.TryGetComponent(ent, out EyeComponent? eye);
|
||||||
|
|
||||||
|
|
||||||
if (eye?.Eye == _eyeManager.CurrentEye
|
if (eye?.Eye == _eyeManager.CurrentEye
|
||||||
&& _entMan.GetComponent<TransformComponent>(ent.Value).WorldPosition == default)
|
&& _entMan.GetComponent<TransformComponent>(ent.Value).WorldPosition == default)
|
||||||
return; // nothing to worry about, the player is just in null space... actually that is probably a problem?
|
return; // nothing to worry about, the player is just in null space... actually that is probably a problem?
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
@@ -25,9 +24,7 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
// Internal viewport creation is deferred.
|
// Internal viewport creation is deferred.
|
||||||
private IClydeViewport? _viewport;
|
private IClydeViewport? _viewport;
|
||||||
private List<IClydeViewport> _lowerPorts = new();
|
|
||||||
private IEye? _eye;
|
private IEye? _eye;
|
||||||
private IEye[] _lowerEyes = new IEye[] {};
|
|
||||||
private Vector2i _viewportSize;
|
private Vector2i _viewportSize;
|
||||||
private int _curRenderScale;
|
private int _curRenderScale;
|
||||||
private ScalingViewportStretchMode _stretchMode = ScalingViewportStretchMode.Bilinear;
|
private ScalingViewportStretchMode _stretchMode = ScalingViewportStretchMode.Bilinear;
|
||||||
@@ -53,27 +50,6 @@ namespace Content.Client.Viewport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEye[] LowerEyes
|
|
||||||
{
|
|
||||||
get => _lowerEyes;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
var old = value;
|
|
||||||
_lowerEyes = value;
|
|
||||||
if (old.Length != value.Length)
|
|
||||||
{
|
|
||||||
InvalidateViewport();
|
|
||||||
Logger.Debug("Eyes updated..");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var (eye, port) in _lowerEyes.Zip(_lowerPorts))
|
|
||||||
{
|
|
||||||
port.Eye = eye;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The size, in unscaled pixels, of the internal viewport.
|
/// The size, in unscaled pixels, of the internal viewport.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -161,11 +137,6 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
_viewport!.Render();
|
_viewport!.Render();
|
||||||
|
|
||||||
foreach (var viewport in _lowerPorts)
|
|
||||||
{
|
|
||||||
viewport.Render();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_queuedScreenshots.Count != 0)
|
if (_queuedScreenshots.Count != 0)
|
||||||
{
|
{
|
||||||
var callbacks = _queuedScreenshots.ToArray();
|
var callbacks = _queuedScreenshots.ToArray();
|
||||||
@@ -184,10 +155,6 @@ namespace Content.Client.Viewport
|
|||||||
var drawBox = GetDrawBox();
|
var drawBox = GetDrawBox();
|
||||||
var drawBoxGlobal = drawBox.Translated(GlobalPixelPosition);
|
var drawBoxGlobal = drawBox.Translated(GlobalPixelPosition);
|
||||||
_viewport.RenderScreenOverlaysBelow(handle, this, drawBoxGlobal);
|
_viewport.RenderScreenOverlaysBelow(handle, this, drawBoxGlobal);
|
||||||
foreach (var viewport in _lowerPorts.AsEnumerable().Reverse())
|
|
||||||
{
|
|
||||||
handle.DrawTextureRect(viewport.RenderTarget.Texture, drawBox);
|
|
||||||
}
|
|
||||||
handle.DrawTextureRect(_viewport.RenderTarget.Texture, drawBox);
|
handle.DrawTextureRect(_viewport.RenderTarget.Texture, drawBox);
|
||||||
_viewport.RenderScreenOverlaysAbove(handle, this, drawBoxGlobal);
|
_viewport.RenderScreenOverlaysAbove(handle, this, drawBoxGlobal);
|
||||||
}
|
}
|
||||||
@@ -257,23 +224,6 @@ namespace Content.Client.Viewport
|
|||||||
{
|
{
|
||||||
Filter = StretchMode == ScalingViewportStretchMode.Bilinear,
|
Filter = StretchMode == ScalingViewportStretchMode.Bilinear,
|
||||||
});
|
});
|
||||||
_viewport.ClearColor = Color.Blue.WithAlpha(0.02f);
|
|
||||||
|
|
||||||
_lowerPorts.Clear();
|
|
||||||
for (var i = 0; i < _lowerEyes.Length; i++)
|
|
||||||
{
|
|
||||||
_lowerPorts.Add(_clyde.CreateViewport(
|
|
||||||
ViewportSize * renderScale,
|
|
||||||
new TextureSampleParameters
|
|
||||||
{
|
|
||||||
Filter = StretchMode == ScalingViewportStretchMode.Bilinear,
|
|
||||||
}));
|
|
||||||
_lowerPorts[i].RenderScale = (renderScale, renderScale);
|
|
||||||
_lowerPorts[i].ClearColor = Color.Blue.WithAlpha(0.02f);
|
|
||||||
|
|
||||||
_lowerPorts[i].Eye = _lowerEyes[i];
|
|
||||||
_lowerPorts[i].Eye!.Zoom = _lowerPorts[i].Eye!.Zoom * (1.02f + i * 0.02f);
|
|
||||||
}
|
|
||||||
|
|
||||||
_viewport.RenderScale = (renderScale, renderScale);
|
_viewport.RenderScale = (renderScale, renderScale);
|
||||||
|
|
||||||
@@ -291,11 +241,6 @@ namespace Content.Client.Viewport
|
|||||||
{
|
{
|
||||||
_viewport?.Dispose();
|
_viewport?.Dispose();
|
||||||
_viewport = null;
|
_viewport = null;
|
||||||
foreach (var port in _lowerPorts)
|
|
||||||
{
|
|
||||||
port.Dispose();
|
|
||||||
}
|
|
||||||
_lowerPorts = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapCoordinates ScreenToMap(Vector2 coords)
|
public MapCoordinates ScreenToMap(Vector2 coords)
|
||||||
@@ -346,7 +291,7 @@ namespace Content.Client.Viewport
|
|||||||
|
|
||||||
private void EnsureViewportCreated()
|
private void EnsureViewportCreated()
|
||||||
{
|
{
|
||||||
if (_viewport == null || _lowerPorts.Count != _lowerEyes.Length)
|
if (_viewport == null)
|
||||||
{
|
{
|
||||||
RegenerateViewport();
|
RegenerateViewport();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
using Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
|
|
||||||
namespace Content.Client.zlevels;
|
|
||||||
|
|
||||||
public sealed class ZViewSystem : SharedZViewSystem
|
|
||||||
{
|
|
||||||
public override EntityUid SpawnViewEnt(EntityUid source, MapCoordinates loc)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSetup(EntityUid source)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
||||||
|
|
||||||
namespace Content.Server._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is used for ladders and traversing them.
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class LadderComponent : Component
|
|
||||||
{
|
|
||||||
[DataField("primary")]
|
|
||||||
public bool Primary = false;
|
|
||||||
|
|
||||||
[DataField("otherHalf")]
|
|
||||||
public EntityUid? OtherHalf = EntityUid.Invalid;
|
|
||||||
|
|
||||||
[DataField("otherHalfProto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
||||||
public string OtherHalfProto = "LadderLower";
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
using Content.Shared.Interaction;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
|
|
||||||
namespace Content.Server._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This handles...
|
|
||||||
/// </summary>
|
|
||||||
public sealed class LadderSystem : EntitySystem
|
|
||||||
{
|
|
||||||
[Dependency] private readonly SharedZLevelSystem _zLevel = default!;
|
|
||||||
[Dependency] private readonly TransformSystem _transform = default!;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<LadderComponent, InteractHandEvent>(OnInteractHand);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
|
||||||
{
|
|
||||||
var query = EntityQueryEnumerator<LadderComponent, TransformComponent>();
|
|
||||||
|
|
||||||
while (query.MoveNext(out _, out var ladder, out var xform))
|
|
||||||
{
|
|
||||||
if (!ladder.Primary || Deleted(ladder.OtherHalf))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Track it, it "hangs" from above.
|
|
||||||
_transform.SetWorldPosition(ladder.OtherHalf.Value, _transform.GetWorldPosition(xform));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnInteractHand(EntityUid uid, LadderComponent component, InteractHandEvent args)
|
|
||||||
{
|
|
||||||
EnsureOpposing(uid, component);
|
|
||||||
_zLevel.TryTraverse(!component.Primary, args.User);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnsureOpposing(EntityUid uid, LadderComponent ladder)
|
|
||||||
{
|
|
||||||
if (!ladder.Primary || !Deleted(ladder.OtherHalf))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var parentXform = Transform(uid);
|
|
||||||
var maybeBelow = _zLevel.MapBelow[(int) parentXform.MapID];
|
|
||||||
|
|
||||||
if (maybeBelow is not {} below)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var newCoords = new MapCoordinates(_transform.GetWorldPosition(parentXform), below);
|
|
||||||
ladder.OtherHalf = Spawn(ladder.OtherHalfProto, newCoords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Server.Player;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Network;
|
|
||||||
|
|
||||||
namespace Content.Server._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
public sealed class ZViewSystem : SharedZViewSystem
|
|
||||||
{
|
|
||||||
[Dependency] private readonly ViewSubscriberSystem _view = default!;
|
|
||||||
[Dependency] private readonly SharedZLevelSystem _zLevel = default!;
|
|
||||||
[Dependency] private readonly IServerNetManager _serverNet = default!;
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
_serverNet.Connected += (sender, args) => _zLevel.UpdateMapList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EntityUid SpawnViewEnt(EntityUid source, MapCoordinates loc)
|
|
||||||
{
|
|
||||||
var ent = Spawn(null, loc);
|
|
||||||
EnsureComp<EyeComponent>(ent);
|
|
||||||
var actor = Comp<ActorComponent>(source);
|
|
||||||
_view.AddViewSubscriber(ent, actor.PlayerSession);
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSetup(EntityUid source)
|
|
||||||
{
|
|
||||||
return TryComp<ActorComponent>(source, out var actor) && actor.PlayerSession.AttachedEntity == source;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,239 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Administration;
|
|
||||||
using Content.Shared.Administration.Managers;
|
|
||||||
using Content.Shared.Damage;
|
|
||||||
using Content.Shared.Damage.Prototypes;
|
|
||||||
using Content.Shared.FixedPoint;
|
|
||||||
using Content.Shared.Ghost;
|
|
||||||
using Content.Shared.Gravity;
|
|
||||||
using Content.Shared.Movement.Components;
|
|
||||||
using Robust.Shared.Console;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Map.Components;
|
|
||||||
using Robust.Shared.Network;
|
|
||||||
using Robust.Shared.Physics.Components;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This handles Z levels. I'm sorry to everyone who has to witness this.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class SharedZLevelSystem : EntitySystem
|
|
||||||
{
|
|
||||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
|
||||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
|
||||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
|
||||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
||||||
[Dependency] private readonly IMapManager _map = default!;
|
|
||||||
[Dependency] private readonly INetManager _net = default!;
|
|
||||||
[Dependency] private readonly IConsoleHost _conHost = default!;
|
|
||||||
[Dependency] private readonly ISharedAdminManager _admin = default!;
|
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
private List<MapId?> _mapAbove = new();
|
|
||||||
[ViewVariables]
|
|
||||||
private List<MapId?> _mapBelow = new();
|
|
||||||
|
|
||||||
public IReadOnlyList<MapId?> MapAbove => _mapAbove;
|
|
||||||
public IReadOnlyList<MapId?> MapBelow => _mapBelow;
|
|
||||||
|
|
||||||
private bool DontDrop = false; //HACK: oh god
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
|
||||||
SubscribeNetworkEvent<MapListChangedEvent>(OnMapListChanged);
|
|
||||||
if (_net.IsServer)
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<MoveEvent>(OnMove); // Sloth forgive me.
|
|
||||||
_conHost.RegisterCommand("ztool", ZTool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMove(ref MoveEvent ev)
|
|
||||||
{
|
|
||||||
if (DontDrop || _mapBelow[(int) ev.Component.MapID] == null || HasComp<MapGridComponent>(ev.Sender) || _gravity.IsWeightless(ev.Sender) || HasComp<SharedGhostComponent>(ev.Sender) || !HasComp<PhysicsComponent>(ev.Sender))
|
|
||||||
return; // get out!
|
|
||||||
|
|
||||||
var mapEid = _map.GetMapEntityId(ev.Component.MapID);
|
|
||||||
|
|
||||||
if (ev.Component.Coordinates.EntityId != mapEid)
|
|
||||||
return; // Can't fall through the map if we're not on it!
|
|
||||||
|
|
||||||
if (TryComp<MapGridComponent>(mapEid, out var grid))
|
|
||||||
{
|
|
||||||
if (grid.TryGetTileRef(_xformSystem.GetWorldPosition(ev.Component), out var tile) && !tile.Tile.IsEmpty)
|
|
||||||
{
|
|
||||||
return; // Can't fall through grids.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var phys = Comp<PhysicsComponent>(ev.Sender);
|
|
||||||
if (phys.Momentum.Length < 0.2 || HasComp<InputMoverComponent>(ev.Sender) || HasComp<MobMoverComponent>(ev.Sender))
|
|
||||||
{
|
|
||||||
TryTraverse(false, ev.Sender);
|
|
||||||
// THWACK
|
|
||||||
_damageableSystem.TryChangeDamage(ev.Sender,
|
|
||||||
new DamageSpecifier(_prototype.Index<DamageTypePrototype>("Blunt"), FixedPoint2.New(69)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[AnyCommand]
|
|
||||||
private void ZTool(IConsoleShell shell, string argstr, string[] args)
|
|
||||||
{
|
|
||||||
if (shell.Player?.AttachedEntity is not {} ent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_admin.IsAdmin(ent))
|
|
||||||
{
|
|
||||||
shell.WriteLine("This code may be bad but it's not gonna let you break things.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0].ToLowerInvariant())
|
|
||||||
{
|
|
||||||
case "above":
|
|
||||||
{
|
|
||||||
var xform = Transform(ent);
|
|
||||||
var map = MapAbove[(int) xform.MapID];
|
|
||||||
shell.WriteLine($"The map above you is {(map is not null ? ToPrettyString(_map.GetMapEntityId(map.Value)) : "none")}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "below":
|
|
||||||
{
|
|
||||||
var xform = Transform(ent);
|
|
||||||
var map = MapBelow[(int) xform.MapID];
|
|
||||||
shell.WriteLine($"The map below you is {(map is not null ? ToPrettyString(_map.GetMapEntityId(map.Value)) : "none")}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "link":
|
|
||||||
{
|
|
||||||
var dir = args[2].ToLowerInvariant();
|
|
||||||
var baseMap = new MapId(int.Parse(args[1]));
|
|
||||||
var linkedMap = new MapId(int.Parse(args[3]));
|
|
||||||
|
|
||||||
if (dir != "above" && dir != "below")
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (dir != "above")
|
|
||||||
{
|
|
||||||
LinkMaps(baseMap, linkedMap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LinkMaps(linkedMap, baseMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "traverse":
|
|
||||||
{
|
|
||||||
var dir = args[1].ToLowerInvariant();
|
|
||||||
|
|
||||||
if (dir != "above" && dir != "below")
|
|
||||||
return;
|
|
||||||
|
|
||||||
TryTraverse(dir == "above", ent);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int AllMapsBelow(MapId map, ref MapId[] maps)
|
|
||||||
{
|
|
||||||
var curr = map;
|
|
||||||
var idx = 0;
|
|
||||||
|
|
||||||
while (MapBelow[(int)curr] is { } below && idx < maps.Length)
|
|
||||||
{
|
|
||||||
maps[idx++] = below;
|
|
||||||
curr = below;
|
|
||||||
}
|
|
||||||
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryTraverse(bool direction, EntityUid traverser, TransformComponent? xform = default!)
|
|
||||||
{
|
|
||||||
if (!Resolve(traverser, ref xform))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var worldPosition = _xformSystem.GetWorldPosition(xform);
|
|
||||||
MapId? newMap;
|
|
||||||
if (direction) // Going up!
|
|
||||||
{
|
|
||||||
newMap = MapAbove[(int)xform.MapID];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newMap = MapBelow[(int)xform.MapID];
|
|
||||||
}
|
|
||||||
Logger.Debug($"Traversing to {newMap}..");
|
|
||||||
|
|
||||||
if (newMap is null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var coords = EntityCoordinates.FromMap(_map, new MapCoordinates(worldPosition, newMap.Value));
|
|
||||||
DontDrop = true;
|
|
||||||
_xformSystem.SetCoordinates(traverser, coords);
|
|
||||||
DontDrop = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LinkMaps(MapId below, MapId above)
|
|
||||||
{
|
|
||||||
_mapBelow[(int)above] = below;
|
|
||||||
_mapAbove[(int)below] = above;
|
|
||||||
UpdateMapList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMapListChanged(MapListChangedEvent ev)
|
|
||||||
{
|
|
||||||
if (!_net.IsClient)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//yoink
|
|
||||||
_mapAbove = ev.MapAbove.ToList();
|
|
||||||
_mapBelow = ev.MapBelow.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMapChanged(MapChangedEvent ev)
|
|
||||||
{
|
|
||||||
if (!ev.Created)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while ((int) ev.Map + 1 > _mapAbove.Count)
|
|
||||||
{
|
|
||||||
// Resize time.
|
|
||||||
_mapAbove.Add(null);
|
|
||||||
_mapBelow.Add(null);
|
|
||||||
}
|
|
||||||
UpdateMapList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateMapList()
|
|
||||||
{
|
|
||||||
if (!_net.IsServer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RaiseNetworkEvent(new MapListChangedEvent(_mapAbove.ToArray(), _mapBelow.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class MapListChangedEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
public MapId?[] MapAbove;
|
|
||||||
public MapId?[] MapBelow;
|
|
||||||
|
|
||||||
public MapListChangedEvent(MapId?[] mapAbove, MapId?[] mapBelow)
|
|
||||||
{
|
|
||||||
MapAbove = mapAbove;
|
|
||||||
MapBelow = mapBelow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is used for...
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent, NetworkedComponent]
|
|
||||||
public sealed class ZViewComponent : Component
|
|
||||||
{
|
|
||||||
[ViewVariables]
|
|
||||||
public List<EntityUid> DownViewEnts = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class ZViewComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public List<EntityUid> DownViewEnts;
|
|
||||||
|
|
||||||
public ZViewComponentState(List<EntityUid> downViewEnts)
|
|
||||||
{
|
|
||||||
DownViewEnts = downViewEnts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Body.Components;
|
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Network;
|
|
||||||
using Robust.Shared.Players;
|
|
||||||
|
|
||||||
namespace Content.Shared._Afterlight.ThirdDimension;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This handles view between z levels
|
|
||||||
/// </summary>
|
|
||||||
public abstract class SharedZViewSystem : EntitySystem
|
|
||||||
{
|
|
||||||
[Dependency] private readonly INetManager _net = default!;
|
|
||||||
[Dependency] private readonly IMapManager _map = default!;
|
|
||||||
[Dependency] private readonly ISharedPlayerManager _player = default!;
|
|
||||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
|
||||||
[Dependency] private readonly SharedZLevelSystem _zLevel = default!;
|
|
||||||
|
|
||||||
private const int ViewDepth = 3;
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<ZViewComponent, ComponentHandleState>(ZViewComponentHandleState);
|
|
||||||
SubscribeLocalEvent<ZViewComponent, ComponentGetState>(ZViewComponentGetState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ZViewComponentGetState(EntityUid uid, ZViewComponent component, ref ComponentGetState args)
|
|
||||||
{
|
|
||||||
args.State = new ZViewComponentState(component.DownViewEnts);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ZViewComponentHandleState(EntityUid uid, ZViewComponent component, ref ComponentHandleState args)
|
|
||||||
{
|
|
||||||
if (args.Current is not ZViewComponentState state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
component.DownViewEnts = state.DownViewEnts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
|
||||||
{
|
|
||||||
if (_net.IsServer)
|
|
||||||
FrameUpdate(frameTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override void FrameUpdate(float frameTime)
|
|
||||||
{
|
|
||||||
var query = EntityQueryEnumerator<SharedEyeComponent>();
|
|
||||||
var toUpdate = new List<EntityUid>();
|
|
||||||
while (query.MoveNext(out var uid, out _))
|
|
||||||
{
|
|
||||||
var view = EnsureComp<ZViewComponent>(uid);
|
|
||||||
var xform = Transform(uid);
|
|
||||||
var maps = new MapId[ViewDepth];
|
|
||||||
var amt = _zLevel.AllMapsBelow(xform.MapID, ref maps);
|
|
||||||
if (amt == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var currPos = _xformSystem.GetWorldPosition(xform);
|
|
||||||
|
|
||||||
if (view.DownViewEnts.Count != amt)
|
|
||||||
{
|
|
||||||
if (_net.IsClient || !CanSetup(uid))
|
|
||||||
continue;
|
|
||||||
toUpdate.Add(uid);
|
|
||||||
Logger.Debug("Queued Z view update.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var (ent, map) in view.DownViewEnts.Zip(maps))
|
|
||||||
{
|
|
||||||
if (map == MapId.Nullspace)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var coords = EntityCoordinates.FromMap(_map, new MapCoordinates(currPos, map));
|
|
||||||
_xformSystem.SetCoordinates(ent, coords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var uid in toUpdate)
|
|
||||||
{
|
|
||||||
Logger.Debug("Did z view update.");
|
|
||||||
var view = EnsureComp<ZViewComponent>(uid);
|
|
||||||
var xform = Transform(uid);
|
|
||||||
foreach (var e in view.DownViewEnts)
|
|
||||||
{
|
|
||||||
QueueDel(e);
|
|
||||||
}
|
|
||||||
view.DownViewEnts.Clear();
|
|
||||||
var maps = new MapId[ViewDepth];
|
|
||||||
var amt = _zLevel.AllMapsBelow(xform.MapID, ref maps);
|
|
||||||
if (amt == 0)
|
|
||||||
continue;
|
|
||||||
var currPos = _xformSystem.GetWorldPosition(xform);
|
|
||||||
foreach (var map in maps)
|
|
||||||
{
|
|
||||||
if (map == MapId.Nullspace)
|
|
||||||
continue;
|
|
||||||
view.DownViewEnts.Add(SpawnViewEnt(uid, new MapCoordinates(currPos, map)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dirty(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract EntityUid SpawnViewEnt(EntityUid source, MapCoordinates loc);
|
|
||||||
public abstract bool CanSetup(EntityUid source);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
- type: entity
|
|
||||||
id: BaseLadder
|
|
||||||
parent: BaseStructure
|
|
||||||
abstract: true
|
|
||||||
placement:
|
|
||||||
mode: SnapgridCenter
|
|
||||||
components:
|
|
||||||
- type: Ladder
|
|
||||||
- type: Sprite
|
|
||||||
netsync: false
|
|
||||||
sprite: Structures/ladder.rsi
|
|
||||||
- type: Transform
|
|
||||||
noRot: true
|
|
||||||
- type: InteractionOutline
|
|
||||||
|
|
||||||
- type: entity
|
|
||||||
id: Ladder
|
|
||||||
parent: BaseLadder
|
|
||||||
name: ladder
|
|
||||||
description: This doesn't look very safe.
|
|
||||||
components:
|
|
||||||
- type: Ladder
|
|
||||||
primary: true
|
|
||||||
- type: Sprite
|
|
||||||
sprite: Structures/ladder.rsi
|
|
||||||
state: top
|
|
||||||
|
|
||||||
- type: entity
|
|
||||||
id: LadderLower
|
|
||||||
parent: BaseLadder
|
|
||||||
name: ladder
|
|
||||||
description: This doesn't look very safe.
|
|
||||||
noSpawn: true
|
|
||||||
components:
|
|
||||||
- type: Ladder
|
|
||||||
primary: false
|
|
||||||
- type: Sprite
|
|
||||||
sprite: Structures/ladder.rsi
|
|
||||||
state: bottom
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 413 B |
Binary file not shown.
|
Before Width: | Height: | Size: 546 B |
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 1,
|
|
||||||
"license": "CC-BY-SA-3.0",
|
|
||||||
"copyright": "Taken from /tg/station at commit https://github.com/tgstation/tgstation/commit/a66d78ef5b3339bbaa13a8d3167af266485d4589",
|
|
||||||
"size": {
|
|
||||||
"x": 32,
|
|
||||||
"y": 32
|
|
||||||
},
|
|
||||||
"states":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "bottom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "icon"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "middle"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "top"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 1,
|
|
||||||
"license": "CC-BY-SA-3.0",
|
|
||||||
"copyright": "Taken from /tg/station at commit https://github.com/tgstation/tgstation/commit/a66d78ef5b3339bbaa13a8d3167af266485d4589",
|
|
||||||
"size": {
|
|
||||||
"x": 32,
|
|
||||||
"y": 32
|
|
||||||
},
|
|
||||||
"states":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "bottom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "icon",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "middle",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "top"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 515 B |
Binary file not shown.
|
Before Width: | Height: | Size: 461 B |
Reference in New Issue
Block a user