Skip to content

Commit

Permalink
Merge PR #66 from Tetronamecronicus (singular)
Browse files Browse the repository at this point in the history
Singular
  • Loading branch information
EndrAnimet authored Jul 13, 2024
2 parents 2930f19 + c8815f6 commit 54a6f95
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 15 deletions.
35 changes: 34 additions & 1 deletion Content.Client/Singularity/SingularityOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using System.Numerics;
using Robust.Shared.Timing;


namespace Content.Client.Singularity
{
Expand Down Expand Up @@ -38,6 +40,7 @@ public SingularityOverlay()
private readonly Vector2[] _positions = new Vector2[MaxCount];
private readonly float[] _intensities = new float[MaxCount];
private readonly float[] _falloffPowers = new float[MaxCount];
private readonly float[] _energys = new float[MaxCount];
private int _count = 0;

protected override bool BeforeDraw(in OverlayDrawArgs args)
Expand All @@ -47,7 +50,34 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)
if (_xformSystem is null && !_entMan.TrySystem(out _xformSystem))
return false;

//_count = 0;
//
//var query = _entMan.EntityQueryEnumerator<SingularityComponent, TransformComponent>();
//while (query.MoveNext(out var uid, out var singulo, out var xform))
//{
// if (xform.MapID != args.MapId)
// continue;
//
// var mapPos = _xformSystem.GetWorldPosition(uid);
//
// // is the distortion in range?
// if ((mapPos - args.WorldAABB.ClosestPoint(mapPos)).LengthSquared() > MaxDistance * MaxDistance)
// continue;
//
// // To be clear, this needs to use "inside-viewport" pixels.
// // In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
// var tempCoords = args.Viewport.WorldToLocal(mapPos);
// tempCoords.Y = args.Viewport.Size.Y - tempCoords.Y; // Local space to fragment space.
//
// _energys[_count] = singulo.Energy;
// _count++;
//
// if (_count == MaxCount)
// break;
//}

_count = 0;

var query = _entMan.EntityQueryEnumerator<SingularityDistortionComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var distortion, out var xform))
{
Expand All @@ -65,11 +95,13 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)
var tempCoords = args.Viewport.WorldToLocal(mapPos);
tempCoords.Y = args.Viewport.Size.Y - tempCoords.Y; // Local space to fragment space.


_positions[_count] = tempCoords;
_intensities[_count] = distortion.Intensity;
_falloffPowers[_count] = distortion.FalloffPower;
_energys[_count] = distortion.Energy;
_count++;

//
if (_count == MaxCount)
break;
}
Expand All @@ -84,6 +116,7 @@ protected override void Draw(in OverlayDrawArgs args)

_shader?.SetParameter("renderScale", args.Viewport.RenderScale * args.Viewport.Eye.Scale);
_shader?.SetParameter("count", _count);
_shader?.SetParameter("energy", _energys);//new float[]{250,500,1000,1500,2000});
_shader?.SetParameter("position", _positions);
_shader?.SetParameter("intensity", _intensities);
_shader?.SetParameter("falloffPower", _falloffPowers);
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Singularity/EntitySystems/SingularitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public override void Update(float frameTime)
var curTime = _timing.CurTime;
if (singularity.NextUpdateTime <= curTime)
Update(uid, curTime - singularity.LastUpdateTime, singularity);
if(TryComp(uid, out SingularityDistortionComponent? sinDist)){
sinDist.Energy = singularity.Energy;
Dirty(uid,sinDist);

}
}
}

Expand Down Expand Up @@ -135,6 +140,9 @@ public void SetEnergy(EntityUid uid, float value, SingularityComponent? singular
return;

singularity.Energy = value;



SetLevel(uid, value switch
{
>= 5000 when HasEatenSM => 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public sealed partial class SingularityDistortionComponent : Component
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float Intensity = 31.25f;

[DataField("energy"), AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float Energy = 150f;

[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public float FalloffPower = MathF.Sqrt(2f);
}
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Fun/toys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@
state: singularitytoy
- type: SingularityDistortion
intensity: 2000
energy: 5
falloffPower: 2.6
- type: Item
size: Normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
minSpeed: 1.875
- type: SingularityDistortion
falloffPower: 2.529822
energy: 180
intensity: 3645
- type: RadiationSource
slope: 0.2 # its emit really far away
Expand Down Expand Up @@ -80,23 +81,29 @@
sprite: Structures/Power/Generation/Singularity/singularity_1.rsi
state: singularity_1
scale: 1.0,1.0
visible: false
2:
sprite: Structures/Power/Generation/Singularity/singularity_2.rsi
state: singularity_2
scale: 1.0,1.0
visible: false
3:
sprite: Structures/Power/Generation/Singularity/singularity_3.rsi
state: singularity_3
scale: 1.0,1.0
visible: false
4:
sprite: Structures/Power/Generation/Singularity/singularity_4.rsi
state: singularity_4
scale: 1.0,1.0
visible: false
5:
sprite: Structures/Power/Generation/Singularity/singularity_5.rsi
state: singularity_5
scale: 1.5,1.5
visible: false
6:
sprite: Structures/Power/Generation/Singularity/singularity_6.rsi
state: singularity_6
scale: .9,.9
visible: false
Loading

0 comments on commit 54a6f95

Please sign in to comment.