Files
wwdpublic/Content.Server/_Goobstation/Blob/Systems/BlobMobSystem.cs
Kyoth25f ed2301f840 Port Blob (#2441)
Ports Blob from https://github.com/Goob-Station/Goob-Station/pull/975
that was ported from https://github.com/Rxup/space-station-14.

Credit to VigersRay for original code, Roudenn and Rxup for maintaining
and jorgun for the Goob port.

---

- [X] Port https://github.com/Goob-Station/Goob-Station/pull/975;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/1209;
- [X] Port Blob related code from
https://github.com/Goob-Station/Goob-Station/pull/1262;
- [X] Port Blob related code from
https://github.com/Goob-Station/Goob-Station/pull/1340;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/1408;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/1419;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/1440;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/1817;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/2077;
- [ ] ~Port https://github.com/Goob-Station/Goob-Station/pull/1916~;
- [ ] ~Port https://github.com/Goob-Station/Goob-Station/pull/1917~;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/2077;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/2092;
- [X] Port https://github.com/Goob-Station/Goob-Station/pull/2546;
- [X] Port https://github.com/Rxup/space-station-14/pull/963;
- [X] Port https://github.com/Rxup/space-station-14/pull/998;
- [ ] ~Port https://github.com/Goob-Station/Goob-Station/pull/2563~.

- [X] Enable Blob and Blob gamemode;
- [X] Add `StationGlobConfig` to all stations;
- [X] Use `AnnouncerSystem` in `BlobRuleSystem.cs`;
- [X] Blob language and Hivemind (from
https://github.com/Rxup/space-station-14/pull/176);
- [x] Change CVars location;
- [X] Add media.

---

<details><summary><h1>Media</h1></summary>
<p>
https://youtu.be/-WtMQwRcmrU?si=su3An6RtiCTZg-DV
</p>
</details>

---

🆑 VigersRay, Roudenn, Rxup, vladospupuos, fishbait and Kyoth25f
- add: Added a new antagonist: Blob

---------

Co-authored-by: fishbait <gnesse@gmail.com>
Co-authored-by: Fishbait <Fishbait@git.ml>
Co-authored-by: Aiden <aiden@djkraz.com>
Co-authored-by: beck-thompson <107373427+beck-thompson@users.noreply.github.com>
Co-authored-by: lanse12 <cloudability.ez@gmail.com>
Co-authored-by: BombasterDS <deniskaporoshok@gmail.com>
Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com>
Co-authored-by: Piras314 <p1r4s@proton.me>
Co-authored-by: shibe <95730644+shibechef@users.noreply.github.com>
Co-authored-by: Ilya246 <57039557+Ilya246@users.noreply.github.com>
Co-authored-by: JohnOakman <sremy2012@hotmail.fr>
Co-authored-by: Fat Engineer Gaming <159075414+Fat-Engineer-Gaming@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Rouden <149893554+Roudenn@users.noreply.github.com>
2025-07-12 12:20:25 +10:00

117 lines
4.2 KiB
C#

using Content.Server.Language;
using Content.Server.Chat.Systems;
using Content.Server.Radio;
using Content.Server.Radio.Components;
using Content.Server.Radio.EntitySystems;
using Content.Shared._Goobstation.Blob;
using Content.Shared._Goobstation.Blob.Components;
using Content.Shared.Chat;
using Content.Shared.Damage;
using Content.Shared.Speech;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Content.Shared.Language.Events;
using Content.Shared.Language.Components;
using Content.Shared._Shitmed.Targeting;
namespace Content.Server._Goobstation.Blob.Systems;
public sealed class BlobMobSystem : SharedBlobMobSystem
{
[Dependency] private readonly LanguageSystem _language = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BlobMobComponent, BlobMobGetPulseEvent>(OnPulsed);
SubscribeLocalEvent<BlobSpeakComponent, DetermineEntityLanguagesEvent>(OnLanguageApply);
SubscribeLocalEvent<BlobSpeakComponent, ComponentStartup>(OnSpokeAdd);
SubscribeLocalEvent<BlobSpeakComponent, ComponentShutdown>(OnSpokeRemove);
SubscribeLocalEvent<BlobSpeakComponent, TransformSpeakerNameEvent>(OnSpokeName);
SubscribeLocalEvent<BlobSpeakComponent, SpeakAttemptEvent>(OnSpokeCan, after: new []{ typeof(SpeechSystem) });
SubscribeLocalEvent<BlobSpeakComponent, EntitySpokeEvent>(OnSpoke, before: new []{ typeof(RadioSystem), typeof(HeadsetSystem) });
SubscribeLocalEvent<BlobSpeakComponent, RadioReceiveEvent>(OnIntrinsicReceive);
}
private void OnIntrinsicReceive(Entity<BlobSpeakComponent> ent, ref RadioReceiveEvent args)
{
if (TryComp(ent, out ActorComponent? actor) && args.Channel.ID == ent.Comp.Channel)
{
var msg = new MsgChatMessage
{
Message = args.OriginalChatMsg
};
_netMan.ServerSendMessage(msg, actor.PlayerSession.Channel);
}
}
private void OnSpoke(Entity<BlobSpeakComponent> ent, ref EntitySpokeEvent args)
{
if (args.Channel == null)
return;
_radioSystem.SendRadioMessage(ent, args.Message, ent.Comp.Channel, ent, language: args.Language);
}
private void OnLanguageApply(Entity<BlobSpeakComponent> ent, ref DetermineEntityLanguagesEvent args)
{
if (ent.Comp.LifeStage is
ComponentLifeStage.Removing
or ComponentLifeStage.Stopping
or ComponentLifeStage.Stopped)
return;
args.SpokenLanguages.Clear();
args.SpokenLanguages.Add(ent.Comp.Language);
args.UnderstoodLanguages.Add(ent.Comp.Language);
}
private void OnSpokeName(Entity<BlobSpeakComponent> ent, ref TransformSpeakerNameEvent args)
{
if (!ent.Comp.OverrideName)
{
return;
}
args.VoiceName = Loc.GetString(ent.Comp.Name);
}
private void OnSpokeCan(Entity<BlobSpeakComponent> ent, ref SpeakAttemptEvent args)
{
if (HasComp<BlobCarrierComponent>(ent))
{
return;
}
args.Uncancel();
}
private void OnSpokeRemove(Entity<BlobSpeakComponent> ent, ref ComponentShutdown args)
{
if (TerminatingOrDeleted(ent))
return;
_language.UpdateEntityLanguages(ent.Owner);
var radio = EnsureComp<ActiveRadioComponent>(ent);
radio.Channels.Remove(ent.Comp.Channel);
}
private void OnSpokeAdd(Entity<BlobSpeakComponent> ent, ref ComponentStartup args)
{
if (TerminatingOrDeleted(ent))
return;
var component = EnsureComp<LanguageSpeakerComponent>(ent);
component.CurrentLanguage = ent.Comp.Language;
_language.UpdateEntityLanguages(ent.Owner);
var radio = EnsureComp<ActiveRadioComponent>(ent);
radio.Channels.Add(ent.Comp.Channel);
}
private void OnPulsed(EntityUid uid, BlobMobComponent component, BlobMobGetPulseEvent args) =>
_damageableSystem.TryChangeDamage(uid, component.HealthOfPulse, targetPart: TargetBodyPart.All);
}