forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/upstream/master' into upst…
…ream-sync # Conflicts: # Resources/Prototypes/Accents/word_replacements.yml # Resources/Prototypes/Entities/Clothing/Shoes/boots.yml # Resources/Prototypes/Loadouts/loadout_groups.yml # Resources/Prototypes/Roles/Jobs/Security/detective.yml # Resources/Prototypes/Species/human.yml # Resources/ServerInfo/Guidebook/Antagonist/Traitors.xml # Resources/Textures/Clothing/Head/Helmets/security.rsi/equipped-HELMET.png # Resources/Textures/Clothing/Head/Helmets/security.rsi/icon.png # Resources/Textures/Clothing/Head/Helmets/security.rsi/inhand-left.png # Resources/Textures/Clothing/Head/Helmets/security.rsi/inhand-right.png # Resources/Textures/Structures/Wallmounts/signs.rsi/meta.json
- Loading branch information
Showing
243 changed files
with
19,772 additions
and
8,018 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using System.Numerics; | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
public sealed class StationAiOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IClyde _clyde = default!; | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
|
||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
|
||
private readonly HashSet<Vector2i> _visibleTiles = new(); | ||
|
||
private IRenderTexture? _staticTexture; | ||
private IRenderTexture? _stencilTexture; | ||
|
||
public StationAiOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (_stencilTexture?.Texture.Size != args.Viewport.Size) | ||
{ | ||
_staticTexture?.Dispose(); | ||
_stencilTexture?.Dispose(); | ||
_stencilTexture = _clyde.CreateRenderTarget(args.Viewport.Size, new RenderTargetFormatParameters(RenderTargetColorFormat.Rgba8Srgb), name: "station-ai-stencil"); | ||
_staticTexture = _clyde.CreateRenderTarget(args.Viewport.Size, | ||
new RenderTargetFormatParameters(RenderTargetColorFormat.Rgba8Srgb), | ||
name: "station-ai-static"); | ||
} | ||
|
||
var worldHandle = args.WorldHandle; | ||
|
||
var worldBounds = args.WorldBounds; | ||
|
||
var playerEnt = _player.LocalEntity; | ||
_entManager.TryGetComponent(playerEnt, out TransformComponent? playerXform); | ||
var gridUid = playerXform?.GridUid ?? EntityUid.Invalid; | ||
_entManager.TryGetComponent(gridUid, out MapGridComponent? grid); | ||
|
||
var invMatrix = args.Viewport.GetWorldToLocalMatrix(); | ||
|
||
if (grid != null) | ||
{ | ||
// TODO: Pass in attached entity's grid. | ||
// TODO: Credit OD on the moved to code | ||
// TODO: Call the moved-to code here. | ||
|
||
_visibleTiles.Clear(); | ||
var lookups = _entManager.System<EntityLookupSystem>(); | ||
var xforms = _entManager.System<SharedTransformSystem>(); | ||
_entManager.System<StationAiVisionSystem>().GetView((gridUid, grid), worldBounds, _visibleTiles); | ||
|
||
var gridMatrix = xforms.GetWorldMatrix(gridUid); | ||
var matty = Matrix3x2.Multiply(gridMatrix, invMatrix); | ||
|
||
// Draw visible tiles to stencil | ||
worldHandle.RenderInRenderTarget(_stencilTexture!, () => | ||
{ | ||
worldHandle.SetTransform(matty); | ||
|
||
foreach (var tile in _visibleTiles) | ||
{ | ||
var aabb = lookups.GetLocalBounds(tile, grid.TileSize); | ||
worldHandle.DrawRect(aabb, Color.White); | ||
} | ||
}, | ||
Color.Transparent); | ||
|
||
// Once this is gucci optimise rendering. | ||
worldHandle.RenderInRenderTarget(_staticTexture!, | ||
() => | ||
{ | ||
worldHandle.SetTransform(invMatrix); | ||
var shader = _proto.Index<ShaderPrototype>("CameraStatic").Instance(); | ||
worldHandle.UseShader(shader); | ||
worldHandle.DrawRect(worldBounds, Color.White); | ||
}, | ||
Color.Black); | ||
} | ||
// Not on a grid | ||
else | ||
{ | ||
worldHandle.RenderInRenderTarget(_stencilTexture!, () => | ||
{ | ||
}, | ||
Color.Transparent); | ||
|
||
worldHandle.RenderInRenderTarget(_staticTexture!, | ||
() => | ||
{ | ||
worldHandle.SetTransform(Matrix3x2.Identity); | ||
worldHandle.DrawRect(worldBounds, Color.Black); | ||
}, Color.Black); | ||
} | ||
|
||
// Use the lighting as a mask | ||
worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilMask").Instance()); | ||
worldHandle.DrawTextureRect(_stencilTexture!.Texture, worldBounds); | ||
|
||
// Draw the static | ||
worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilDraw").Instance()); | ||
worldHandle.DrawTextureRect(_staticTexture!.Texture, worldBounds); | ||
|
||
worldHandle.SetTransform(Matrix3x2.Identity); | ||
worldHandle.UseShader(null); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Content.Shared.Silicons.StationAi; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client.Silicons.StationAi; | ||
|
||
public sealed partial class StationAiSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMgr = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
|
||
private StationAiOverlay? _overlay; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
// InitializeAirlock(); | ||
// InitializePowerToggle(); | ||
|
||
SubscribeLocalEvent<StationAiOverlayComponent, LocalPlayerAttachedEvent>(OnAiAttached); | ||
SubscribeLocalEvent<StationAiOverlayComponent, LocalPlayerDetachedEvent>(OnAiDetached); | ||
SubscribeLocalEvent<StationAiOverlayComponent, ComponentInit>(OnAiOverlayInit); | ||
SubscribeLocalEvent<StationAiOverlayComponent, ComponentRemove>(OnAiOverlayRemove); | ||
} | ||
|
||
private void OnAiOverlayInit(Entity<StationAiOverlayComponent> ent, ref ComponentInit args) | ||
{ | ||
var attachedEnt = _player.LocalEntity; | ||
|
||
if (attachedEnt != ent.Owner) | ||
return; | ||
|
||
AddOverlay(); | ||
} | ||
|
||
private void OnAiOverlayRemove(Entity<StationAiOverlayComponent> ent, ref ComponentRemove args) | ||
{ | ||
var attachedEnt = _player.LocalEntity; | ||
|
||
if (attachedEnt != ent.Owner) | ||
return; | ||
|
||
RemoveOverlay(); | ||
} | ||
|
||
private void AddOverlay() | ||
{ | ||
if (_overlay != null) | ||
return; | ||
|
||
_overlay = new StationAiOverlay(); | ||
_overlayMgr.AddOverlay(_overlay); | ||
} | ||
|
||
private void RemoveOverlay() | ||
{ | ||
if (_overlay == null) | ||
return; | ||
|
||
_overlayMgr.RemoveOverlay(_overlay); | ||
_overlay = null; | ||
} | ||
|
||
private void OnAiAttached(Entity<StationAiOverlayComponent> ent, ref LocalPlayerAttachedEvent args) | ||
{ | ||
AddOverlay(); | ||
} | ||
|
||
private void OnAiDetached(Entity<StationAiOverlayComponent> ent, ref LocalPlayerDetachedEvent args) | ||
{ | ||
RemoveOverlay(); | ||
} | ||
|
||
public override void Shutdown() | ||
{ | ||
base.Shutdown(); | ||
_overlayMgr.RemoveOverlay<StationAiOverlay>(); | ||
} | ||
} |
Oops, something went wrong.