Skip to content

Commit

Permalink
Add station announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Sep 14, 2024
1 parent 8aa3090 commit eaeec64
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Content.Server/SS220/SpiderQueen/SpiderQueenRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void OnGetBriefing(Entity<SpiderQueenRoleComponent> ent, ref GetBriefing
var max = spiderQueen.MaxMana;

briefing = string.Format("{0}\n{1}", briefing,
Loc.GetString("spider-queen-mana-information", ("current", current), ("max", max)));
Loc.GetString("spider-queen-role-mana-information", ("current", current), ("max", max)));
}

args.Append(briefing);
Expand Down
31 changes: 31 additions & 0 deletions Content.Server/SS220/SpiderQueen/SpiderQueenSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Server.Chat.Systems;
using Content.Server.Pinpointer;
using Content.Server.Popups;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.FixedPoint;
Expand All @@ -8,10 +10,13 @@
using Content.Shared.SS220.SpiderQueen.Systems;
using Content.Shared.Storage;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Server.SS220.SpiderQueen;

Expand All @@ -24,6 +29,9 @@ public sealed partial class SpiderQueenSystem : SharedSpiderQueenSystem
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly NavMapSystem _navMap = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -114,6 +122,12 @@ private void OnAfterCocooning(Entity<SpiderQueenComponent> entity, ref AfterCoco
spiderCocoon.CocoonOwner = entity.Owner;
Dirty(cocoonUid, spiderCocoon);

if (entity.Comp.CocoonsCountToAnnouncement is { } value &&
entity.Comp.CocoonsList.Count >= value)
{
DoStationAnnouncement(entity);
}

UpdateCocoonsBonus(entity.Owner);
}

Expand Down Expand Up @@ -152,4 +166,21 @@ private void UpdateCocoonsBonus(EntityUid spider, SpiderQueenComponent? componen
component.CocoonsManaBonus = newBonus;
Dirty(spider, component);
}

/// <summary>
/// Do a station announcement if all conditions are met
/// </summary>
private void DoStationAnnouncement(EntityUid uid, SpiderQueenComponent? component = null)
{
if (!Resolve(uid, ref component) ||
component.IsAnnounced ||
!TryComp<TransformComponent>(uid, out var xform))
return;

var msg = Loc.GetString("spider-queen-warning",
("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, xform)))));
_chat.DispatchGlobalAnnouncement(msg, playSound: false, colorOverride: Color.Red);
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true);
component.IsAnnounced = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace Content.Shared.SS220.SpiderQueen.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class SpiderQueenComponent : Component
{
[ViewVariables]
public bool IsAnnounced = false;

/// <summary>
/// Current amount of mana
/// </summary>
Expand Down Expand Up @@ -58,4 +61,10 @@ public sealed partial class SpiderQueenComponent : Component
/// </summary>
[DataField]
public float CocoonsMinDistance = 0.5f;

/// <summary>
/// How many cocoons need to station announcement
/// </summary>
[DataField]
public int? CocoonsCountToAnnouncement;
}
3 changes: 2 additions & 1 deletion Resources/Locale/ru-RU/ss220/spider-queen/spider-queen.ftl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
spider-queen-mana-amount = У вас [color=yellow]{ $current } маны[/color]. Ваш максимум — [color=yellow]{ $max } маны[/color].
spider-queen-not-enough-mana = Недостаточно маны
spider-queen-warning = Замечена аномальная биологическая активность в { $location }. Служба Безопасности должна ликвидировать угрозу до того как активу будет нанесен непоправимый ущерб!
spider-queen-role-greeting = Королева пауков...
spider-queen-mana-information = У вас { $current } маны. Ваш максимум — { $max } маны.
spider-queen-role-mana-information = У вас { $current } маны. Ваш максимум — { $max } маны.
cocooning-too-close = Слишком близко к другому кокону
cocooning-target-not-dead = Цель должна быть мертва
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
maxMana: 200
passiveGeneration: 0.5
cocoonsBonusCoefficient: 0.9
cocoonsCountToAnnouncement: 2
cocoonPrototypes:
- SpiderCocoonHorizontal
- SpiderCocoonVertical
Expand Down

0 comments on commit eaeec64

Please sign in to comment.