Revert "Moony z level hack (#15031)" (#15032)

This reverts commit 1f6663912b.
This commit is contained in:
Moony
2023-03-31 21:50:11 -05:00
committed by GitHub
parent 1f6663912b
commit eee96125df
17 changed files with 2 additions and 665 deletions

View File

@@ -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";
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}