Skip to content

Commit

Permalink
mics
Browse files Browse the repository at this point in the history
  • Loading branch information
Mor-Dast committed Dec 11, 2024
1 parent b221afe commit 8ec2d9f
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Content.Server/ADT/NightVision/NightVisionSystem.cs
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;
26 changes: 26 additions & 0 deletions Content.Server/_Silver/ThermalVisionComponent.cs
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

View workflow job for this annotation

GitHub Actions / Test Packaging

'ThermalVisionComponent.Name': no suitable method found to override

Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'ThermalVisionComponent.Name': no suitable method found to override

Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.Name': no suitable method found to override

Check failure on line 9 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.Name': no suitable method found to override

[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

View workflow job for this annotation

GitHub Actions / Test Packaging

'ThermalVisionComponent.OnAdd()': no suitable method found to override

Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'ThermalVisionComponent.OnAdd()': no suitable method found to override

Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.OnAdd()': no suitable method found to override

Check failure on line 14 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.OnAdd()': no suitable method found to override
{
base.OnAdd();
EntitySystem.Get<WallVisionSystem>().Register(this);
}

protected override void OnRemove()

Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

'ThermalVisionComponent.OnRemove()': no suitable method found to override

Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'ThermalVisionComponent.OnRemove()': no suitable method found to override

Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.OnRemove()': no suitable method found to override

Check failure on line 20 in Content.Server/_Silver/ThermalVisionComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ThermalVisionComponent.OnRemove()': no suitable method found to override
{
base.OnRemove();
EntitySystem.Get<WallVisionSystem>().Unregister(this);
}
}
}
65 changes: 65 additions & 0 deletions Content.Server/_Silver/ThermalVisionSystem.cs
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

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 14 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

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

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)
{
_wallVisionComponents.Add(component);
}

public void Unregister(WallVisionComponent component)

Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 27 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)
{
_wallVisionComponents.Remove(component);
}

private void OnPlayerAttached(EntityUid uid, WallVisionComponent component, PlayerAttachSystemMessage args)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'PlayerAttachSystemMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'PlayerAttachSystemMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PlayerAttachSystemMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 32 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PlayerAttachSystemMessage' could not be found (are you missing a using directive or an assembly reference?)
{
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

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'IEntity' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'IEntity' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'IEntity' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'WallVisionComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in Content.Server/_Silver/ThermalVisionSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'IEntity' could not be found (are you missing a using directive or an assembly reference?)
{
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;
}
}
}
}
}
25 changes: 25 additions & 0 deletions Content.Shared/ADT/NightVision/ADTNightVisionVisibleComponent.cs
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;
}
38 changes: 38 additions & 0 deletions Content.Shared/ADT/NightVision/NightVisionComponent.cs
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;
28 changes: 28 additions & 0 deletions Content.Shared/ADT/NightVision/NightVisionItemComponent.cs
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;
}
11 changes: 11 additions & 0 deletions Content.Shared/ADT/NightVision/NightVisionItemVisuals.cs
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,
}
Loading

0 comments on commit 8ec2d9f

Please sign in to comment.