-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Content.Shared.ADT.NightVision; | ||
|
||
namespace Content.Server.ADT.NightVision; | ||
|
||
public sealed class NightVisionSystem : SharedNightVisionSystem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.ViewVariables; | ||
|
||
namespace Content.Server._Silver.ThermalVision | ||
{ | ||
[RegisterComponent] | ||
public class ThermalVisionComponent : Component | ||
{ | ||
public override string Name => "ThermalVision"; | ||
Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / Test Packaging
Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / YAML Linter
Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / build (ubuntu-latest)
|
||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
public float VisionRadius { get; set; } = 10.0f; | ||
|
||
protected override void OnAdd() | ||
Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / Test Packaging
Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / YAML Linter
Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
base.OnAdd(); | ||
EntitySystem.Get<WallVisionSystem>().Register(this); | ||
} | ||
|
||
protected override void OnRemove() | ||
Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / Test Packaging
Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / YAML Linter
Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
base.OnRemove(); | ||
EntitySystem.Get<WallVisionSystem>().Unregister(this); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Physics; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.IoC; | ||
using System.Collections.Generic; | ||
|
||
namespace Content.Server.Systems | ||
{ | ||
public class WallVisionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
|
||
private readonly HashSet<WallVisionComponent> _wallVisionComponents = new(); | ||
Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<WallVisionComponent, PlayerAttachSystemMessage>(OnPlayerAttached); | ||
} | ||
|
||
public void Register(WallVisionComponent component) | ||
Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
_wallVisionComponents.Add(component); | ||
} | ||
|
||
public void Unregister(WallVisionComponent component) | ||
Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
_wallVisionComponents.Remove(component); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, WallVisionComponent component, PlayerAttachSystemMessage args) | ||
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
UpdateVision(component, args.PlayerSession.AttachedEntity); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
foreach (var component in _wallVisionComponents) | ||
{ | ||
if (component.Owner.TryGetComponent(out IMapGridComponent? grid) && | ||
component.Owner.TryGetComponent(out TransformComponent? transform)) | ||
{ | ||
UpdateVision(component, component.Owner); | ||
} | ||
} | ||
} | ||
|
||
private void UpdateVision(WallVisionComponent component, IEntity owner) | ||
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / Test Packaging
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / YAML Linter
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
var mapGrid = _mapManager.GetGrid(owner.Transform.GridID); | ||
var worldPosition = owner.Transform.WorldPosition; | ||
|
||
foreach (var entity in mapGrid.GetEntitiesInRange(owner.Transform.Coordinates, component.VisionRadius)) | ||
{ | ||
if (entity.HasComponent<MobComponent>()) // Assuming MobComponent denotes a living entity | ||
{ | ||
entity.Visible = true; | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.ADT.NightVision; | ||
|
||
/// <summary> | ||
/// For rendering sprites on top of FOV when the user has a <see cref="NightVisionComponent"/>. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class NightVisionVisibleComponent : Component | ||
{ | ||
/// <summary> | ||
/// Priority for rendering order. | ||
/// Rendered from lowest to highest, which means higher numbers will be rendered above lower numbers. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public int Priority = 0; | ||
|
||
/// <summary> | ||
/// Transparency of the rendered sprite. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public float? Transparency = null; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Content.Shared.Alert; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.ADT.NightVision; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] | ||
[Access(typeof(SharedNightVisionSystem))] | ||
public sealed partial class NightVisionComponent : Component | ||
{ | ||
[DataField] | ||
public ProtoId<AlertPrototype>? Alert; | ||
|
||
[DataField, AutoNetworkedField] | ||
public NightVisionState State = NightVisionState.Full; | ||
|
||
[DataField, AutoNetworkedField] | ||
public bool Overlay; | ||
|
||
[DataField, AutoNetworkedField] | ||
public bool Innate; | ||
|
||
[DataField, AutoNetworkedField] | ||
public bool SeeThroughContainers; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum NightVisionState | ||
{ | ||
Off, | ||
Half, | ||
Full | ||
} | ||
|
||
public sealed partial class ToggleNightVision : BaseAlertEvent; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Content.Shared.Inventory; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared.ADT.NightVision; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[Access(typeof(SharedNightVisionSystem))] | ||
public sealed partial class NightVisionItemComponent : Component | ||
{ | ||
[DataField, AutoNetworkedField] | ||
public EntProtoId ActionId = "ActionToggleNinjaNightVision"; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid? Action; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid? User; | ||
|
||
[DataField, AutoNetworkedField] | ||
public bool Toggleable = true; | ||
|
||
// Only allows for a single slotflag right now because some code uses strings and some code uses enums to determine slots :( | ||
[DataField, AutoNetworkedField] | ||
public SlotFlags SlotFlags { get; set; } = SlotFlags.EYES; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// taken and adapted from https://github.com/RMC-14/RMC-14?ysclid=lzx00zxd6e53093995 | ||
|
||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.ADT.NightVision; | ||
|
||
[Serializable, NetSerializable] | ||
public enum NightVisionItemVisuals | ||
{ | ||
Active, | ||
} |