Gateway destinations (#21040)

* Gateway generation

* Gateway stuff

* gatewehs

* mercenaries

* play area

* Range fixes and tweaks

* weh

* Gateway UI polish

* Lots of fixes

* Knock some items off

* Fix dungeon spawning

Realistically we should probably be using a salvage job.

* wahwah

* wehvs

* expression

* weh

* eee

* a

* a

* WEH

* frfr

* Gatwey

* Fix gateway windows

* Fix gateway windows

* a

* a

* Better layer masking

* a

* a

* Noise fixes

* a

* Fix fractal calculations

* a

* More fixes

* Fixes

* Add layers back in

* Fixes

* namespaces and ftl

* Other TODO

* Fix distance

* Cleanup

* Fix test
This commit is contained in:
metalgearsloth
2023-11-15 13:23:40 +11:00
committed by GitHub
parent 67a3c3a6a3
commit 816ee2e1ab
51 changed files with 1562 additions and 959 deletions

View File

@@ -0,0 +1,88 @@
using System.Numerics;
using System.Text;
using Content.Shared.Parallax.Biomes;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.ResourceManagement;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Client.Parallax;
public sealed class BiomeDebugOverlay : Overlay
{
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
private BiomeSystem _biomes;
private SharedMapSystem _maps;
private Font _font;
public BiomeDebugOverlay()
{
IoCManager.InjectDependencies(this);
_biomes = _entManager.System<BiomeSystem>();
_maps = _entManager.System<SharedMapSystem>();
_font = new VectorFont(_cache.GetResource<FontResource>("/EngineFonts/NotoSans/NotoSans-Regular.ttf"), 12);
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
{
var mapUid = _mapManager.GetMapEntityId(args.MapId);
return _entManager.HasComponent<BiomeComponent>(mapUid);
}
protected override void Draw(in OverlayDrawArgs args)
{
var mouseScreenPos = _inputManager.MouseScreenPosition;
var mousePos = _eyeManager.ScreenToMap(mouseScreenPos);
if (mousePos.MapId == MapId.Nullspace || mousePos.MapId != args.MapId)
return;
var mapUid = _mapManager.GetMapEntityId(args.MapId);
if (!_entManager.TryGetComponent(mapUid, out BiomeComponent? biomeComp) || !_entManager.TryGetComponent(mapUid, out MapGridComponent? grid))
return;
var sb = new StringBuilder();
var nodePos = _maps.WorldToTile(mapUid, grid, mousePos.Position);
if (_biomes.TryGetEntity(nodePos, biomeComp, grid, out var ent))
{
var text = $"Entity: {ent}";
sb.AppendLine(text);
}
if (_biomes.TryGetDecals(nodePos, biomeComp.Layers, biomeComp.Seed, grid, out var decals))
{
var text = $"Decals: {decals.Count}";
sb.AppendLine(text);
foreach (var decal in decals)
{
var decalText = $"- {decal.ID}";
sb.AppendLine(decalText);
}
}
if (_biomes.TryGetBiomeTile(nodePos, biomeComp.Layers, biomeComp.Seed, grid, out var tile))
{
var tileText = $"Tile: {_tileDefManager[tile.Value.TypeId].ID}";
sb.AppendLine(tileText);
}
args.ScreenHandle.DrawString(_font, mouseScreenPos.Position + new Vector2(0f, 32f), sb.ToString());
}
}

View File

@@ -0,0 +1,22 @@
using Robust.Client.Graphics;
using Robust.Shared.Console;
namespace Content.Client.Parallax.Commands;
public sealed class ShowBiomeCommand : LocalizedCommands
{
[Dependency] private readonly IOverlayManager _overlayMgr = default!;
public override string Command => "showbiome";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (_overlayMgr.HasOverlay<BiomeDebugOverlay>())
{
_overlayMgr.RemoveOverlay<BiomeDebugOverlay>();
}
else
{
_overlayMgr.AddOverlay(new BiomeDebugOverlay());
}
}
}

View File

@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.Parallax.Data;
using Content.Client.Parallax.Managers;
using Content.Shared.Parallax;
@@ -72,4 +73,56 @@ public sealed class ParallaxSystem : SharedParallaxSystem
{
return TryComp<ParallaxComponent>(mapUid, out var parallax) ? parallax.Parallax : Fallback;
}
/// <summary>
/// Draws a texture as parallax in the specified world handle.
/// </summary>
/// <param name="worldHandle"></param>
/// <param name="worldAABB">WorldAABB to use</param>
/// <param name="sprite">Sprite to draw</param>
/// <param name="curTime">Current time, unused if scrolling not set</param>
/// <param name="position">Current position of the parallax</param>
/// <param name="scrolling">How much to scroll the parallax texture per second</param>
/// <param name="scale">Scale of the texture</param>
/// <param name="slowness">How slow the parallax moves compared to position</param>
/// <param name="modulate">Color modulation applied to drawing the texture</param>
public void DrawParallax(
DrawingHandleWorld worldHandle,
Box2 worldAABB,
Texture sprite,
TimeSpan curTime,
Vector2 position,
Vector2 scrolling,
float scale = 1f,
float slowness = 0f,
Color? modulate = null)
{
// Size of the texture in world units.
var size = sprite.Size / (float) EyeManager.PixelsPerMeter * scale;
var scrolled = scrolling * (float) curTime.TotalSeconds;
// Origin - start with the parallax shift itself.
var originBL = position * slowness + scrolled;
// Centre the image.
originBL -= size / 2;
// Remove offset so we can floor.
var flooredBL = worldAABB.BottomLeft - originBL;
// Floor to background size.
flooredBL = (flooredBL / size).Floored() * size;
// Re-offset.
flooredBL += originBL;
for (var x = flooredBL.X; x < worldAABB.Right; x += size.X)
{
for (var y = flooredBL.Y; y < worldAABB.Top; y += size.Y)
{
var box = Box2.FromDimensions(new Vector2(x, y), size);
worldHandle.DrawTextureRect(sprite, box, modulate);
}
}
}
}