Compare commits
4 Commits
ed-23-09-2
...
ed-03-07-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60a87f1c35 | ||
|
|
786c0ed97c | ||
|
|
d3895e8288 | ||
|
|
d184f795c4 |
@@ -1,6 +1,7 @@
|
||||
using System.Numerics;
|
||||
using Content.Client.Parallax;
|
||||
using Content.Client.Weather;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.WorldEdge;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Weather;
|
||||
@@ -73,12 +74,17 @@ public sealed partial class StencilOverlay : Overlay
|
||||
DrawRestrictedRange(args, restrictedRangeComponent, invMatrix);
|
||||
}
|
||||
|
||||
//CP14 World Edge overlay
|
||||
//CP14 Overlays
|
||||
if (_entManager.TryGetComponent<CP14CloudShadowsComponent>(mapUid, out var shadows))
|
||||
{
|
||||
DrawCloudShadows(args, shadows, invMatrix);
|
||||
}
|
||||
|
||||
if (_entManager.TryGetComponent<CP14WorldEdgeComponent>(mapUid, out var worldEdge))
|
||||
{
|
||||
DrawWorldEdge(args, worldEdge, invMatrix);
|
||||
}
|
||||
//CP14 World Edge overlay end
|
||||
//CP14 Overlays end
|
||||
|
||||
args.WorldHandle.UseShader(null);
|
||||
args.WorldHandle.SetTransform(Matrix3x2.Identity);
|
||||
|
||||
65
Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs
Normal file
65
Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Overlays;
|
||||
|
||||
public sealed partial class StencilOverlay
|
||||
{
|
||||
private void DrawCloudShadows(in OverlayDrawArgs args, CP14CloudShadowsComponent cloudComp, Matrix3x2 invMatrix)
|
||||
{
|
||||
var worldHandle = args.WorldHandle;
|
||||
var mapId = args.MapId;
|
||||
var worldAABB = args.WorldAABB;
|
||||
var worldBounds = args.WorldBounds;
|
||||
var position = args.Viewport.Eye?.Position.Position ?? Vector2.Zero;
|
||||
|
||||
// Cut out the irrelevant bits via stencil
|
||||
// This is why we don't just use parallax; we might want specific tiles to get drawn over
|
||||
// particularly for planet maps or stations.
|
||||
worldHandle.RenderInRenderTarget(_blep!, () =>
|
||||
{
|
||||
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||
_grids.Clear();
|
||||
|
||||
// idk if this is safe to cache in a field and clear sloth help
|
||||
_mapManager.FindGridsIntersecting(mapId, worldAABB, ref _grids);
|
||||
|
||||
foreach (var grid in _grids)
|
||||
{
|
||||
var matrix = _transform.GetWorldMatrix(grid, xformQuery);
|
||||
var matty = Matrix3x2.Multiply(matrix, invMatrix);
|
||||
worldHandle.SetTransform(matty);
|
||||
|
||||
foreach (var tile in grid.Comp.GetTilesIntersecting(worldAABB))
|
||||
{
|
||||
// Ignored tiles for stencil
|
||||
if (_weather.CanWeatherAffect(grid.Owner, grid, tile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var gridTile = new Box2(tile.GridIndices * grid.Comp.TileSize,
|
||||
(tile.GridIndices + Vector2i.One) * grid.Comp.TileSize);
|
||||
|
||||
worldHandle.DrawRect(gridTile, Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
}, Color.Transparent);
|
||||
|
||||
worldHandle.SetTransform(Matrix3x2.Identity);
|
||||
worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilMask").Instance());
|
||||
worldHandle.DrawTextureRect(_blep!.Texture, worldBounds);
|
||||
var curTime = _timing.RealTime;
|
||||
var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(new ResPath(cloudComp.ParallaxPath)), curTime);
|
||||
|
||||
// Draw the rain
|
||||
worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilDraw").Instance());
|
||||
_parallax.DrawParallax(worldHandle, worldAABB, sprite, curTime, position, cloudComp.CloudSpeed, modulate: Color.White.WithAlpha(cloudComp.Alpha), scale: cloudComp.Scale);
|
||||
|
||||
worldHandle.SetTransform(Matrix3x2.Identity);
|
||||
worldHandle.UseShader(null);
|
||||
}
|
||||
}
|
||||
24
Content.Server/_CP14/DayCycle/CP14CloudShadowsSystem.cs
Normal file
24
Content.Server/_CP14/DayCycle/CP14CloudShadowsSystem.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
|
||||
public sealed partial class CP14CloudShadowsSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14CloudShadowsComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<CP14CloudShadowsComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.CloudSpeed = new Vector2(
|
||||
_random.NextFloat(-ent.Comp.MaxSpeed, ent.Comp.MaxSpeed),
|
||||
_random.NextFloat(-ent.Comp.MaxSpeed, ent.Comp.MaxSpeed));
|
||||
}
|
||||
}
|
||||
26
Content.Shared/_CP14/DayCycle/CP14CloudShadowsComponent.cs
Normal file
26
Content.Shared/_CP14/DayCycle/CP14CloudShadowsComponent.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
|
||||
/// <summary>
|
||||
/// if added to the map, renders cloud shadows on the map
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class CP14CloudShadowsComponent : Component
|
||||
{
|
||||
[DataField, AutoNetworkedField]
|
||||
public Vector2 CloudSpeed = new Vector2(0.5f, 0f);
|
||||
|
||||
[DataField]
|
||||
public float MaxSpeed = 1.5f;
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public float Alpha = 1f;
|
||||
|
||||
[DataField]
|
||||
public float Scale = 2.5f;
|
||||
|
||||
[DataField]
|
||||
public string ParallaxPath = "/Textures/_CP14/Parallaxes/Shadows.png";
|
||||
}
|
||||
@@ -36,6 +36,7 @@ entities:
|
||||
- type: OccluderTree
|
||||
- type: LoadedMap
|
||||
- type: MapLight
|
||||
- type: CP14CloudShadows
|
||||
- type: CP14WorldEdge
|
||||
range: 30
|
||||
- type: CP14DayCycle
|
||||
|
||||
BIN
Resources/Textures/_CP14/Parallaxes/Shadows.png
Normal file
BIN
Resources/Textures/_CP14/Parallaxes/Shadows.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 629 KiB |
4
Resources/Textures/_CP14/Parallaxes/attributions.yml
Normal file
4
Resources/Textures/_CP14/Parallaxes/attributions.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- files: ["Shadows.png"]
|
||||
license: "CC-BY-SA-3.0"
|
||||
copyright: "Created by TheShuEd for CrystallPunk14"
|
||||
source: "https://github.com/crystallpunk-14/crystall-punk-14"
|
||||
Reference in New Issue
Block a user