Skip to content

Commit

Permalink
Merge pull request #58 from Corvax-Frontier/Up050824
Browse files Browse the repository at this point in the history
Up050824
  • Loading branch information
Vonsant authored Aug 5, 2024
2 parents c2e8025 + a033680 commit dae7a54
Show file tree
Hide file tree
Showing 887 changed files with 40,691 additions and 33,946 deletions.
29 changes: 29 additions & 0 deletions Content.Client/IconSmoothing/ClientRandomIconSmoothSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Content.Shared.IconSmoothing;
using Robust.Client.GameObjects;

namespace Content.Client.IconSmoothing;

public sealed class ClientRandomIconSmoothSystem : SharedRandomIconSmoothSystem
{
[Dependency] private readonly IconSmoothSystem _iconSmooth = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RandomIconSmoothComponent, AppearanceChangeEvent>(OnAppearanceChange);
}

private void OnAppearanceChange(Entity<RandomIconSmoothComponent> ent, ref AppearanceChangeEvent args)
{
if (!TryComp<IconSmoothComponent>(ent, out var smooth))
return;

if (!_appearance.TryGetData<string>(ent, RandomIconSmoothState.State, out var state, args.Component))
return;

smooth.StateBase = state;
_iconSmooth.SetStateBase(ent, smooth, state);
}
}
2 changes: 1 addition & 1 deletion Content.Client/IconSmoothing/IconSmoothComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed partial class IconSmoothComponent : Component
/// Prepended to the RSI state.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("base")]
public string StateBase { get; private set; } = string.Empty;
public string StateBase { get; set; } = string.Empty;

[DataField("shader", customTypeSerializer:typeof(PrototypeIdSerializer<ShaderPrototype>))]
public string? Shader;
Expand Down
35 changes: 27 additions & 8 deletions Content.Client/IconSmoothing/IconSmoothSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ private void OnStartup(EntityUid uid, IconSmoothComponent component, ComponentSt
if (component.Mode != IconSmoothingMode.Corners || !TryComp(uid, out SpriteComponent? sprite))
return;

SetCornerLayers(sprite, component);

if (component.Shader != null)
{
sprite.LayerSetShader(CornerLayers.SE, component.Shader);
sprite.LayerSetShader(CornerLayers.NE, component.Shader);
sprite.LayerSetShader(CornerLayers.NW, component.Shader);
sprite.LayerSetShader(CornerLayers.SW, component.Shader);
}
}

public void SetStateBase(EntityUid uid, IconSmoothComponent component, string newState)
{
if (!TryComp<SpriteComponent>(uid, out var sprite))
return;

component.StateBase = newState;
SetCornerLayers(sprite, component);
}

private void SetCornerLayers(SpriteComponent sprite, IconSmoothComponent component)
{
sprite.LayerMapRemove(CornerLayers.SE);
sprite.LayerMapRemove(CornerLayers.NE);
sprite.LayerMapRemove(CornerLayers.NW);
sprite.LayerMapRemove(CornerLayers.SW);

var state0 = $"{component.StateBase}0";
sprite.LayerMapSet(CornerLayers.SE, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SE, DirectionOffset.None);
Expand All @@ -64,14 +91,6 @@ private void OnStartup(EntityUid uid, IconSmoothComponent component, ComponentSt
sprite.LayerSetDirOffset(CornerLayers.NW, DirectionOffset.Flip);
sprite.LayerMapSet(CornerLayers.SW, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SW, DirectionOffset.Clockwise);

if (component.Shader != null)
{
sprite.LayerSetShader(CornerLayers.SE, component.Shader);
sprite.LayerSetShader(CornerLayers.NE, component.Shader);
sprite.LayerSetShader(CornerLayers.NW, component.Shader);
sprite.LayerSetShader(CornerLayers.SW, component.Shader);
}
}

private void OnShutdown(EntityUid uid, IconSmoothComponent component, ComponentShutdown args)
Expand Down
41 changes: 23 additions & 18 deletions Content.Client/Movement/Systems/FloorOcclusionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,56 @@ public sealed class FloorOcclusionSystem : SharedFloorOcclusionSystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;

private EntityQuery<SpriteComponent> _spriteQuery;

public override void Initialize()
{
base.Initialize();

_spriteQuery = GetEntityQuery<SpriteComponent>();

SubscribeLocalEvent<FloorOcclusionComponent, ComponentStartup>(OnOcclusionStartup);
SubscribeLocalEvent<FloorOcclusionComponent, ComponentShutdown>(OnOcclusionShutdown);
SubscribeLocalEvent<FloorOcclusionComponent, AfterAutoHandleStateEvent>(OnOcclusionAuto);
}

private void OnOcclusionAuto(EntityUid uid, FloorOcclusionComponent component, ref AfterAutoHandleStateEvent args)
private void OnOcclusionAuto(Entity<FloorOcclusionComponent> ent, ref AfterAutoHandleStateEvent args)
{
SetEnabled(uid, component, component.Enabled);
SetShader(ent.Owner, ent.Comp.Enabled);
}

private void OnOcclusionStartup(EntityUid uid, FloorOcclusionComponent component, ComponentStartup args)
private void OnOcclusionStartup(Entity<FloorOcclusionComponent> ent, ref ComponentStartup args)
{
if (component.Enabled && TryComp<SpriteComponent>(uid, out var sprite))
SetShader(sprite, true);
SetShader(ent.Owner, ent.Comp.Enabled);
}

protected override void SetEnabled(EntityUid uid, FloorOcclusionComponent component, bool enabled)
private void OnOcclusionShutdown(Entity<FloorOcclusionComponent> ent, ref ComponentShutdown args)
{
if (component.Enabled == enabled)
return;

base.SetEnabled(uid, component, enabled);

if (!TryComp<SpriteComponent>(uid, out var sprite))
return;
SetShader(ent.Owner, false);
}

SetShader(sprite, enabled);
protected override void SetEnabled(Entity<FloorOcclusionComponent> entity)
{
SetShader(entity.Owner, entity.Comp.Enabled);
}

private void SetShader(SpriteComponent sprite, bool enabled)
private void SetShader(Entity<SpriteComponent?> sprite, bool enabled)
{
if (!_spriteQuery.Resolve(sprite.Owner, ref sprite.Comp, false))
return;

var shader = _proto.Index<ShaderPrototype>("HorizontalCut").Instance();

if (sprite.PostShader is not null && sprite.PostShader != shader)
if (sprite.Comp.PostShader is not null && sprite.Comp.PostShader != shader)
return;

if (enabled)
{
sprite.PostShader = shader;
sprite.Comp.PostShader = shader;
}
else
{
sprite.PostShader = null;
sprite.Comp.PostShader = null;
}
}
}
6 changes: 3 additions & 3 deletions Content.Client/Weapons/Ranged/GunSpreadOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ protected override void Draw(in OverlayDrawArgs args)
Angle currentAngle;
if (_entManager.TryGetComponent<SpecialComponent>(player, out var special))
{
maxSpread += Angle.FromDegrees((40f - special.TotalPerception * 5));
minSpread += Angle.FromDegrees((10f - special.TotalPerception));
maxSpread += Angle.FromDegrees((10f - special.TotalPerception*2));
minSpread += Angle.FromDegrees((10f - special.TotalPerception*2));
maxSpread *= 1.5 - special.TotalPerception / 10;
minSpread *= 1.5 - special.TotalPerception / 10;
decay += Angle.FromDegrees((special.TotalPerception - 10f) / 5);
decay += Angle.FromDegrees((special.TotalPerception - 5f) / 5);

currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - decay.Theta * timeSinceLastFire,
minSpread.Theta, maxSpread.Theta));
Expand Down
26 changes: 26 additions & 0 deletions Content.Server/IconSmoothing/RandomIconSmoothSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.IconSmoothing;
using Robust.Shared.Random;

namespace Content.Server.IconSmoothing;

public sealed partial class RandomIconSmoothSystem : SharedRandomIconSmoothSystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RandomIconSmoothComponent, MapInitEvent>(OnMapInit);
}

private void OnMapInit(Entity<RandomIconSmoothComponent> ent, ref MapInitEvent args)
{
if (ent.Comp.RandomStates.Count == 0)
return;

var state = _random.Pick(ent.Comp.RandomStates);
_appearance.SetData(ent, RandomIconSmoothState.State, state);
}
}
6 changes: 3 additions & 3 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ private Angle GetRecoilAngle(TimeSpan curTime, GunComponent component, Angle dir
Angle newTheta;
if (TryComp<SpecialComponent>(shooter, out var special))
{
maxAngle += Angle.FromDegrees((40f - special.TotalPerception * 5));
minAngle += Angle.FromDegrees((10f - special.TotalPerception));
maxAngle += Angle.FromDegrees((10f - special.TotalPerception*2));
minAngle += Angle.FromDegrees((10f - special.TotalPerception*2));
maxAngle *= 1.5 - special.TotalPerception / 10;
minAngle *= 1.5 - special.TotalPerception / 10;
decay += Angle.FromDegrees((special.TotalPerception - 10f) / 5);
decay += Angle.FromDegrees((special.TotalPerception - 5f) / 10);

newTheta = MathHelper.Clamp(component.CurrentAngle.Theta + component.AngleIncreaseModified.Theta - decay.Theta * timeSinceLastFire, minAngle.Theta, maxAngle.Theta);
}
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/IconSmoothing/RandomIconSmoothComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Robust.Shared.GameStates;

namespace Content.Shared.IconSmoothing;

/// <summary>
/// Allow randomize StateBase of IconSmoothComponent for random visual variation
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class RandomIconSmoothComponent : Component
{
/// <summary>
/// StateBase will be randomly selected from this list. Allows to randomize the visual.
/// </summary>
[DataField(required: true)]
public List<string> RandomStates = new();
}
12 changes: 12 additions & 0 deletions Content.Shared/IconSmoothing/SharedRandomIconSmoothSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.Serialization;

namespace Content.Shared.IconSmoothing;

public abstract class SharedRandomIconSmoothSystem : EntitySystem
{
}
[Serializable, NetSerializable]
public enum RandomIconSmoothState : byte
{
State
}
9 changes: 3 additions & 6 deletions Content.Shared/Movement/Components/FloorOcclusionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ namespace Content.Shared.Movement.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class FloorOcclusionComponent : Component
{
/// <summary>
/// Is the shader currently enabled.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("enabled"), AutoNetworkedField]
public bool Enabled;
[ViewVariables]
public bool Enabled => Colliding.Count > 0;

[DataField("colliding")]
[DataField, AutoNetworkedField]
public List<EntityUid> Colliding = new();
}
24 changes: 11 additions & 13 deletions Content.Shared/Movement/Systems/SharedFloorOcclusionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,37 @@ public override void Initialize()
SubscribeLocalEvent<FloorOccluderComponent, EndCollideEvent>(OnEndCollide);
}

private void OnStartCollide(EntityUid uid, FloorOccluderComponent component, ref StartCollideEvent args)
private void OnStartCollide(Entity<FloorOccluderComponent> entity, ref StartCollideEvent args)
{
var other = args.OtherEntity;

if (!TryComp<FloorOcclusionComponent>(other, out var occlusion) ||
occlusion.Colliding.Contains(uid))
occlusion.Colliding.Contains(entity.Owner))
{
return;
}

SetEnabled(other, occlusion, true);
occlusion.Colliding.Add(uid);
occlusion.Colliding.Add(entity.Owner);
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}

private void OnEndCollide(EntityUid uid, FloorOccluderComponent component, ref EndCollideEvent args)
private void OnEndCollide(Entity<FloorOccluderComponent> entity, ref EndCollideEvent args)
{
var other = args.OtherEntity;

if (!TryComp<FloorOcclusionComponent>(other, out var occlusion))
return;

occlusion.Colliding.Remove(uid);
if (!occlusion.Colliding.Remove(entity.Owner))
return;

if (occlusion.Colliding.Count == 0)
SetEnabled(other, occlusion, false);
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}

protected virtual void SetEnabled(EntityUid uid, FloorOcclusionComponent component, bool enabled)
protected virtual void SetEnabled(Entity<FloorOcclusionComponent> entity)
{
if (component.Enabled == enabled)
return;

component.Enabled = enabled;
Dirty(uid, component);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/Audio/_Nuclear14/Effects/Doors/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["DRS_Junk_Wall_Gate_B_Close_01.ogg", "DRS_Junk_Wall_Gate_B_Open_01.ogg", "DRS_Metal_Bay_Door_Close_01.ogg", "DRS_Metal_Bay_Door_Open_01.ogg", "DRS_Metal_Jail_Swing_Close_01.ogg", "DRS_Metal_Jail_Swing_Open_01.ogg", "DRS_PodProtectron_Close_01.ogg", "DRS_PodProtectron_Open_01.ogg", "DRS_Vault_Door_Vertical_Close_A_01.ogg", "DRS_Vault_Door_Vertical_Open_A_01.ogg", "DRS_Vault_Gear_Door_Open_2D_01.ogg", "DRS_Vault_Gear_Door_Open_3D_01.ogg"]
license: "CC-BY-NC-SA-3.0"
copyright: "Bethesda Softworks, from fallout 4. Converted from WAV to OGG. License unconfirmed Fair use?"
source: "https://www.youtube.com/watch?v=xTvducynPKQ"
Loading

0 comments on commit dae7a54

Please sign in to comment.