Merge remote-tracking branch 'upstream/master' into ups
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Shared._White.Cult;
|
||||
using Content.Shared._White.Cult.Components;
|
||||
using Content.Shared._White.Cult.Components;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Player;
|
||||
@@ -29,7 +28,7 @@ public sealed class ShowCultHudSystem : EntitySystem
|
||||
_overlay = new CultHudOverlay(EntityManager);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, ShowCultHudComponent component, ComponentInit args)
|
||||
private void OnComponentInit<T>(EntityUid uid, T component, ComponentInit args)
|
||||
{
|
||||
if (_player.LocalSession?.AttachedEntity != uid)
|
||||
return;
|
||||
@@ -38,7 +37,7 @@ public sealed class ShowCultHudSystem : EntitySystem
|
||||
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(EntityUid uid, ShowCultHudComponent component, ComponentRemove args)
|
||||
private void OnComponentRemoved<T>(EntityUid uid, T component, ComponentRemove args)
|
||||
{
|
||||
if (_player.LocalSession?.AttachedEntity != uid)
|
||||
return;
|
||||
@@ -47,7 +46,7 @@ public sealed class ShowCultHudSystem : EntitySystem
|
||||
|
||||
}
|
||||
|
||||
private void OnPlayerAttached(EntityUid uid, ShowCultHudComponent component, PlayerAttachedEvent args)
|
||||
private void OnPlayerAttached<T>(EntityUid uid, T component, PlayerAttachedEvent args)
|
||||
{
|
||||
if (_player.LocalSession != args.Player)
|
||||
return;
|
||||
@@ -55,7 +54,7 @@ public sealed class ShowCultHudSystem : EntitySystem
|
||||
_overlayManager.AddOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnPlayerDetached(EntityUid uid, ShowCultHudComponent component, PlayerDetachedEvent args)
|
||||
private void OnPlayerDetached<T>(EntityUid uid, T component, PlayerDetachedEvent args)
|
||||
{
|
||||
if (_player.LocalSession != args.Player)
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Construction;
|
||||
using Content.Shared._White.Cult.Pylon;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Client.Placement;
|
||||
@@ -8,60 +9,33 @@ using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client._White.Cult.UI.StructureRadial;
|
||||
|
||||
public sealed class CultPylonPlacementHijack : PlacementHijack
|
||||
public sealed class CultPylonPlacementHijack(ConstructionPrototype? prototype, IEntityManager entMan, EntityUid player)
|
||||
: PlacementHijack
|
||||
{
|
||||
private readonly ConstructionSystem _constructionSystem;
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly ConstructionPrototype? _prototype;
|
||||
private readonly EntityUid _player;
|
||||
private readonly ConstructionSystem _constructionSystem = entMan.System<ConstructionSystem>();
|
||||
|
||||
public override bool CanRotate { get; }
|
||||
|
||||
public CultPylonPlacementHijack(ConstructionPrototype? prototype, IEntityManager entMan, EntityUid player)
|
||||
{
|
||||
_prototype = prototype;
|
||||
_entMan = entMan;
|
||||
_player = player;
|
||||
_constructionSystem = entMan.System<ConstructionSystem>();
|
||||
CanRotate = prototype?.CanRotate ?? true;
|
||||
}
|
||||
public override bool CanRotate { get; } = prototype?.CanRotate ?? true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HijackPlacementRequest(EntityCoordinates coordinates)
|
||||
{
|
||||
if (_prototype == null)
|
||||
if (prototype == null)
|
||||
return true;
|
||||
|
||||
if (CheckForStructure(coordinates))
|
||||
if (SharedPylonComponent.CheckForStructure(coordinates, entMan, 10f))
|
||||
{
|
||||
var popup = _entMan.System<SharedPopupSystem>();
|
||||
popup.PopupClient(Loc.GetString("cult-structure-craft-another-structure-nearby"), _player, _player);
|
||||
var popup = entMan.System<SharedPopupSystem>();
|
||||
popup.PopupClient(Loc.GetString("cult-structure-craft-another-structure-nearby"), player, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
_constructionSystem.ClearAllGhosts();
|
||||
var dir = Manager.Direction;
|
||||
_constructionSystem.SpawnGhost(_prototype, coordinates, dir);
|
||||
_constructionSystem.SpawnGhost(prototype, coordinates, dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckForStructure(EntityCoordinates coordinates)
|
||||
{
|
||||
var lookupSystem = _entMan.System<EntityLookupSystem>();
|
||||
var entities = lookupSystem.GetEntitiesInRange(coordinates, 10f);
|
||||
foreach (var ent in entities)
|
||||
{
|
||||
if (!_entMan.TryGetComponent<MetaDataComponent>(ent, out var metadata))
|
||||
continue;
|
||||
|
||||
if (metadata.EntityPrototype?.ID is "CultPylon")
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HijackDeletion(EntityUid entity)
|
||||
{
|
||||
@@ -77,6 +51,6 @@ public sealed class CultPylonPlacementHijack : PlacementHijack
|
||||
public override void StartHijack(PlacementManager manager)
|
||||
{
|
||||
base.StartHijack(manager);
|
||||
manager.CurrentTextures = _prototype?.Layers.Select(sprite => sprite.DirFrame0()).ToList();
|
||||
manager.CurrentTextures = prototype?.Layers.Select(sprite => sprite.DirFrame0()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user