Skip to content

Commit

Permalink
merge moment
Browse files Browse the repository at this point in the history
  • Loading branch information
kanopus952 committed Dec 6, 2024
2 parents a8d4c8f + 6251da1 commit af687ae
Show file tree
Hide file tree
Showing 264 changed files with 203,202 additions and 123,709 deletions.
6 changes: 5 additions & 1 deletion Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public override void FrameUpdate(FrameEventArgs e)
return;
}

Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
string text;

if (_gameTicker.Paused)
Expand All @@ -196,6 +196,10 @@ public override void FrameUpdate(FrameEventArgs e)
{
text = Loc.GetString(seconds < -5 ? "lobby-state-right-now-question" : "lobby-state-right-now-confirmation");
}
else if (difference.TotalHours >= 1)
{
text = $"{Math.Floor(difference.TotalHours)}:{difference.Minutes:D2}:{difference.Seconds:D2}";
}
else
{
text = $"{difference.Minutes}:{difference.Seconds:D2}";
Expand Down
23 changes: 23 additions & 0 deletions Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.Silicons.Laws.Ui;
Expand All @@ -18,8 +19,13 @@ public sealed partial class LawDisplay : Control
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly EntityManager _entityManager = default!;

private static readonly TimeSpan PressCooldown = TimeSpan.FromSeconds(3);

private readonly Dictionary<Button, TimeSpan> _nextAllowedPress = new();

public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
{
RobustXamlLoader.Load(this);
Expand Down Expand Up @@ -47,9 +53,12 @@ public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
MinWidth = 75,
};

_nextAllowedPress[localButton] = TimeSpan.Zero;

localButton.OnPressed += _ =>
{
_chatManager.SendMessage($"{lawIdentifierPlaintext}: {lawDescriptionPlaintext}", ChatSelectChannel.Local);
_nextAllowedPress[localButton] = _timing.CurTime + PressCooldown;
};

LawAnnouncementButtons.AddChild(localButton);
Expand All @@ -71,6 +80,8 @@ public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
MinWidth = 75,
};

_nextAllowedPress[radioChannelButton] = TimeSpan.Zero;

radioChannelButton.OnPressed += _ =>
{
switch (radioChannel)
Expand All @@ -80,9 +91,21 @@ public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
default:
_chatManager.SendMessage($"{SharedChatSystem.RadioChannelPrefix}{radioChannelProto.KeyCode} {lawIdentifierPlaintext}: {lawDescriptionPlaintext}", ChatSelectChannel.Radio); break;
}
_nextAllowedPress[radioChannelButton] = _timing.CurTime + PressCooldown;
};

LawAnnouncementButtons.AddChild(radioChannelButton);
}
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

var curTime = _timing.CurTime;
foreach (var (button, nextPress) in _nextAllowedPress)
{
button.Disabled = curTime < nextPress;
}
}
}
130 changes: 106 additions & 24 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Numerics;
using Content.Client.Animations;
using Content.Client.Gameplay;
Expand All @@ -21,6 +22,7 @@
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using SharedGunSystem = Content.Shared.Weapons.Ranged.Systems.SharedGunSystem;
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
Expand All @@ -42,6 +44,9 @@ public sealed partial class GunSystem : SharedGunSystem
[ValidatePrototypeId<EntityPrototype>]
public const string HitscanProto = "HitscanEffect";

[ValidatePrototypeId<EntityPrototype>]
public const string HitscanTracerProto = "HitscanEffectTracer";

public bool SpreadOverlay
{
get => _spreadOverlay;
Expand Down Expand Up @@ -94,47 +99,124 @@ private void OnMuzzleFlash(MuzzleFlashEvent args)
CreateEffect(gunUid, args, gunUid);
}

private IEnumerable<EntityCoordinates> GenerateTracerPath(EntityCoordinates from, float distance, Angle angle, float stepDistance = 1f)
{
var steps = Math.Max(1, (int)Math.Ceiling(distance / stepDistance));

for (var i = 0; i <= steps; i++)
{
yield return from.Offset(angle.ToVec() * (distance / steps) * i);
}
}

private void OnHitscan(HitscanEvent ev)
{
// ALL I WANT IS AN ANIMATED EFFECT
const float tracerInterval = 0.01f;
var activeTracers = new Dictionary<int, EntityUid>();

foreach (var a in ev.Sprites)
{
if (a.Sprite is not SpriteSpecifier.Rsi rsi)
if (a.sprite is not SpriteSpecifier.Rsi rsi)
continue;

var coords = GetCoordinates(a.coordinates);
var startCoords = GetCoordinates(a.coordinates);

if (Deleted(coords.EntityId))
if (Deleted(startCoords.EntityId))
continue;

var ent = Spawn(HitscanProto, coords);
var sprite = Comp<SpriteComponent>(ent);
var xform = Transform(ent);
xform.LocalRotation = a.angle;
sprite[EffectLayers.Unshaded].AutoAnimated = false;
sprite.LayerSetSprite(EffectLayers.Unshaded, rsi);
sprite.LayerSetState(EffectLayers.Unshaded, rsi.RsiState);
sprite.Scale = new Vector2(a.Distance, 1f);
sprite[EffectLayers.Unshaded].Visible = true;

var anim = new Animation()
if (a.effectType == EffectType.Tracer)
{
Length = TimeSpan.FromSeconds(0.48f),
AnimationTracks =
var tracePath = GenerateTracerPath(startCoords, a.distance, a.angle);
var entityCoordinatesEnumerable = tracePath.ToList();

var stepIndex = 0;
foreach (var stepCoords in entityCoordinatesEnumerable)
{
new AnimationTrackSpriteFlick()
var localIndex = stepIndex;
var delay = localIndex * tracerInterval;

Timer.Spawn(TimeSpan.FromSeconds(delay), () =>
{
LayerKey = EffectLayers.Unshaded,
KeyFrames =
if (activeTracers.TryGetValue(localIndex, out var existingTracer) && EntityManager.EntityExists(existingTracer))
{
new AnimationTrackSpriteFlick.KeyFrame(rsi.RsiState, 0f),
EntityManager.DeleteEntity(existingTracer);
}

var tracerEntity = CreateTracerEffect(stepCoords, a.angle, rsi);
activeTracers[localIndex] = tracerEntity;
});

stepIndex++;
}
}
else if (a.effectType == EffectType.Static)
{
CreateStaticEffect(startCoords, a.angle, rsi, a.distance);
}
}
}

private EntityUid CreateTracerEffect(EntityCoordinates coords, Angle angle, SpriteSpecifier.Rsi rsi)
{
var ent = Spawn(HitscanTracerProto, coords);
var sprite = Comp<SpriteComponent>(ent);
var xform = Transform(ent);
xform.LocalRotation = angle;
sprite[EffectLayers.Unshaded].AutoAnimated = false;
sprite.LayerSetSprite(EffectLayers.Unshaded, rsi);
sprite.LayerSetState(EffectLayers.Unshaded, rsi.RsiState);
sprite.Scale = new Vector2(1f, 1f);
sprite[EffectLayers.Unshaded].Visible = true;

var anim = new Animation()
{
Length = TimeSpan.FromSeconds(0.48f),
AnimationTracks =
{
new AnimationTrackSpriteFlick()
{
LayerKey = EffectLayers.Unshaded,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(rsi.RsiState, 0f),
}
}
};
}
};

_animPlayer.Play(ent, anim, "hitscan-effect");
}
_animPlayer.Play(ent, anim, "hitscan-effect");
return ent;
}

private void CreateStaticEffect(EntityCoordinates coords, Angle angle, SpriteSpecifier.Rsi rsi, float distance)
{
var ent = Spawn(HitscanProto, coords);
var sprite = Comp<SpriteComponent>(ent);
var xform = Transform(ent);
xform.LocalRotation = angle;
sprite[EffectLayers.Unshaded].AutoAnimated = false;
sprite.LayerSetSprite(EffectLayers.Unshaded, rsi);
sprite.LayerSetState(EffectLayers.Unshaded, rsi.RsiState);
sprite.Scale = new Vector2(distance, 1f);
sprite[EffectLayers.Unshaded].Visible = true;

var anim = new Animation()
{
Length = TimeSpan.FromSeconds(0.48f),
AnimationTracks =
{
new AnimationTrackSpriteFlick()
{
LayerKey = EffectLayers.Unshaded,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(rsi.RsiState, 0f),
}
}
}
};

_animPlayer.Play(ent, anim, "hitscan-effect");
}

public override void Update(float frameTime)
Expand Down
8 changes: 5 additions & 3 deletions Content.Client/Wires/UI/WiresMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public WiresMenu()
(_statusContainer = new GridContainer
{
Margin = new Thickness(8, 4),
// TODO: automatically change columns count.
Columns = 3
Rows = 2
})
}
}
Expand All @@ -227,7 +226,8 @@ public WiresMenu()
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#525252ff")}
});
CloseButton.OnPressed += _ => Close();
SetSize = new Vector2(320, 200);
SetHeight = 200;
MinWidth = 320;
}


Expand Down Expand Up @@ -503,6 +503,8 @@ private sealed class StatusLight : Control

public StatusLight(StatusLightData data, IResourceCache resourceCache)
{
HorizontalAlignment = HAlignment.Right;

var hsv = Color.ToHsv(data.Color);
hsv.Z /= 2;
var dimColor = Color.FromHsv(hsv);
Expand Down
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public sealed class PostMapInitTest
"Train",
"Oasis",
"Cog",
"Amber",
"SunriseBox",
"SunriseDelta",
"SunriseFland",
Expand Down
12 changes: 12 additions & 0 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ public void ChooseAntags(Entity<AntagSelectionComponent> ent, IList<ICommonSessi
}

ent.Comp.SelectionsComplete = true;
// Sunrise-Start
var selectionCompleteEv = new AntagSelectionCompleteEvent(ent);
RaiseLocalEvent(ent, ref selectionCompleteEv, true);
// Sunrise-End
}

/// <summary>
Expand Down Expand Up @@ -377,6 +381,10 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi

spawnerComp.Rule = ent;
spawnerComp.Definition = def;
// Sunrise-Start
ent.Comp.UseSpawners = true;
ent.Comp.SpawnersCount += 1;
// Sunrise-End
return;
}

Expand Down Expand Up @@ -560,3 +568,7 @@ public record struct AntagSelectLocationEvent(ICommonSession? Session, Entity<An
/// </summary>
[ByRefEvent]
public readonly record struct AfterAntagEntitySelectedEvent(ICommonSession? Session, EntityUid EntityUid, Entity<AntagSelectionComponent> GameRule, AntagSelectionDefinition Def);
// Sunrise-Start
[ByRefEvent]
public readonly record struct AntagSelectionCompleteEvent(Entity<AntagSelectionComponent> GameRule);
// Sunrise-End
6 changes: 6 additions & 0 deletions Content.Server/Antag/Components/AntagSelectionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public sealed partial class AntagSelectionComponent : Component
/// </summary>
public HashSet<ICommonSession> SelectedSessions = new();

// Sunrise-Start
public bool UseSpawners;

public int SpawnersCount;
// Sunrise-End

/// <summary>
/// Locale id for the name of the antag.
/// If this is set then the antag is listed in the round-end summary.
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/Atmos/Components/IgniteOnAmmoHitComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Server.Atmos.EntitySystems;

namespace Content.Server.Atmos.Components;

[RegisterComponent, Access(typeof(FlammableSystem))]
public sealed partial class IgniteOnAmmoHitComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("fireStacks")]
public float FireStacks;

[ViewVariables(VVAccess.ReadWrite), DataField("fixtureId")]
public string FixtureId = "ignition";

}
13 changes: 13 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Content.Shared.Toggleable;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.FixedPoint;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Server.Audio;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
Expand Down Expand Up @@ -83,8 +84,20 @@ public override void Initialize()
SubscribeLocalEvent<ExtinguishOnInteractComponent, ActivateInWorldEvent>(OnExtinguishActivateInWorld);

SubscribeLocalEvent<IgniteOnHeatDamageComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<IgniteOnAmmoHitComponent, HitscanAmmoShotEvent>(HandleHitscanHit); // Sunrise-Edit
}

// Sunrise-Start
private void HandleHitscanHit(EntityUid uid, IgniteOnAmmoHitComponent component, ref HitscanAmmoShotEvent args)
{
if (!EntityManager.TryGetComponent(args.Target, out FlammableComponent? flammable))
return;

flammable.FireStacks += component.FireStacks;
Ignite(args.Target, uid, flammable);
}
// Sunrise-End

private void OnMeleeHit(EntityUid uid, IgniteOnMeleeHitComponent component, MeleeHitEvent args)
{
foreach (var entity in args.HitEntities)
Expand Down
Loading

0 comments on commit af687ae

Please sign in to comment.