Add variables to CluwneComponent, allowing for admeme customizing. Also localized two strings. (#40466)

* Add variables to cluwne component, update to the new style, add unremovable option to setoutfit.

* not nullable, shorthand

* Add comments, address reviews

* why, was i drunk?

* Apply suggestions from code review

---------

Co-authored-by: Jessica M <jessica@maybe.sh>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Jessica M
2025-10-10 13:17:24 -07:00
committed by GitHub
parent cec2fc7021
commit 2ecfb9552a
4 changed files with 122 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ using Content.Shared.Access.Components;
using Content.Shared.Clothing;
using Content.Shared.Hands.Components;
using Content.Shared.Humanoid;
using Content.Shared.Interaction.Components;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using Content.Shared.Preferences;
@@ -23,7 +24,7 @@ public sealed class OutfitSystem : EntitySystem
[Dependency] private readonly InventorySystem _invSystem = default!;
[Dependency] private readonly SharedStationSpawningSystem _spawningSystem = default!;
public bool SetOutfit(EntityUid target, string gear, Action<EntityUid, EntityUid>? onEquipped = null)
public bool SetOutfit(EntityUid target, string gear, Action<EntityUid, EntityUid>? onEquipped = null, bool unremovable = false)
{
if (!EntityManager.TryGetComponent(target, out InventoryComponent? inventoryComponent))
return false;
@@ -60,6 +61,8 @@ public sealed class OutfitSystem : EntitySystem
}
_invSystem.TryEquip(target, equipmentEntity, slot.Name, silent: true, force: true, inventory: inventoryComponent);
if (unremovable)
EnsureComp<UnremoveableComponent>(equipmentEntity);
onEquipped?.Invoke(target, equipmentEntity);
}

View File

@@ -7,7 +7,6 @@ using Content.Server.Clothing.Systems;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Random;
using Content.Shared.Stunnable;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Damage;
using Robust.Shared.Prototypes;
using Content.Server.Emoting.Systems;
@@ -21,7 +20,6 @@ namespace Content.Server.Cluwne;
public sealed class CluwneSystem : EntitySystem
{
private static readonly ProtoId<DamageGroupPrototype> GeneticDamageGroup = "Genetic";
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -48,15 +46,14 @@ public sealed class CluwneSystem : EntitySystem
/// <summary>
/// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning.
/// </summary>
private void OnMobState(EntityUid uid, CluwneComponent component, MobStateChangedEvent args)
private void OnMobState(Entity<CluwneComponent> ent, ref MobStateChangedEvent args)
{
if (args.NewMobState == MobState.Dead)
{
RemComp<CluwneComponent>(uid);
RemComp<ClumsyComponent>(uid);
RemComp<AutoEmoteComponent>(uid);
var damageSpec = new DamageSpecifier(_prototypeManager.Index(GeneticDamageGroup), 300);
_damageableSystem.TryChangeDamage(uid, damageSpec);
RemComp<CluwneComponent>(ent.Owner);
RemComp<ClumsyComponent>(ent.Owner);
RemComp<AutoEmoteComponent>(ent.Owner);
_damageableSystem.TryChangeDamage(ent.Owner, ent.Comp.RevertDamage);
}
}
@@ -65,52 +62,65 @@ public sealed class CluwneSystem : EntitySystem
/// <summary>
/// OnStartup gives the cluwne outfit, ensures clumsy, and makes sure emote sounds are laugh.
/// </summary>
private void OnComponentStartup(EntityUid uid, CluwneComponent component, ComponentStartup args)
private void OnComponentStartup(Entity<CluwneComponent> ent, ref ComponentStartup args)
{
if (component.EmoteSoundsId == null)
if (ent.Comp.EmoteSoundsId == null)
return;
_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds);
EnsureComp<AutoEmoteComponent>(uid);
_autoEmote.AddEmote(uid, "CluwneGiggle");
EnsureComp<ClumsyComponent>(uid);
_prototypeManager.TryIndex(ent.Comp.EmoteSoundsId, out EmoteSounds);
_popupSystem.PopupEntity(Loc.GetString("cluwne-transform", ("target", uid)), uid, PopupType.LargeCaution);
_audio.PlayPvs(component.SpawnSound, uid);
_nameMod.RefreshNameModifiers(uid);
if (ent.Comp.RandomEmote && ent.Comp.AutoEmoteId != null)
{
EnsureComp<AutoEmoteComponent>(ent.Owner);
_autoEmote.AddEmote(ent.Owner, ent.Comp.AutoEmoteId);
}
EnsureComp<ClumsyComponent>(ent.Owner);
_outfitSystem.SetOutfit(uid, "CluwneGear");
var transformMessage = Loc.GetString(ent.Comp.TransformMessage, ("target", ent.Owner));
_popupSystem.PopupEntity(transformMessage, ent.Owner, PopupType.LargeCaution);
_audio.PlayPvs(ent.Comp.SpawnSound, ent.Owner);
_nameMod.RefreshNameModifiers(ent.Owner);
_outfitSystem.SetOutfit(ent.Owner, ent.Comp.OutfitId, unremovable: true);
}
/// <summary>
/// Handles the timing on autoemote as well as falling over and honking.
/// </summary>
private void OnEmote(EntityUid uid, CluwneComponent component, ref EmoteEvent args)
private void OnEmote(Entity<CluwneComponent> ent, ref EmoteEvent args)
{
if (args.Handled)
return;
args.Handled = _chat.TryPlayEmoteSound(uid, EmoteSounds, args.Emote);
if (_robustRandom.Prob(component.GiggleRandomChance))
if (!ent.Comp.RandomEmote)
return;
args.Handled = _chat.TryPlayEmoteSound(ent.Owner, EmoteSounds, args.Emote);
if (_robustRandom.Prob(ent.Comp.GiggleRandomChance))
{
_audio.PlayPvs(component.SpawnSound, uid);
_chat.TrySendInGameICMessage(uid, "honks", InGameICChatType.Emote, ChatTransmitRange.Normal);
_audio.PlayPvs(ent.Comp.SpawnSound, ent.Owner);
_chat.TrySendInGameICMessage(ent.Owner, Loc.GetString(ent.Comp.GiggleEmote), InGameICChatType.Emote, ChatTransmitRange.Normal);
}
else if (_robustRandom.Prob(component.KnockChance))
else if (_robustRandom.Prob(ent.Comp.KnockChance))
{
_audio.PlayPvs(component.KnockSound, uid);
_stunSystem.TryUpdateParalyzeDuration(uid, TimeSpan.FromSeconds(component.ParalyzeTime));
_chat.TrySendInGameICMessage(uid, "spasms", InGameICChatType.Emote, ChatTransmitRange.Normal);
_audio.PlayPvs(ent.Comp.KnockSound, ent.Owner);
_stunSystem.TryUpdateParalyzeDuration(ent.Owner, TimeSpan.FromSeconds(ent.Comp.ParalyzeTime));
_chat.TrySendInGameICMessage(ent.Owner, Loc.GetString(ent.Comp.KnockEmote), InGameICChatType.Emote, ChatTransmitRange.Normal);
}
}
/// <summary>
/// Applies "Cluwnified" prefix
/// </summary>
private void OnRefreshNameModifiers(Entity<CluwneComponent> entity, ref RefreshNameModifiersEvent args)
private void OnRefreshNameModifiers(Entity<CluwneComponent> ent, ref RefreshNameModifiersEvent args)
{
args.AddModifier("cluwne-name-prefix");
args.AddModifier(ent.Comp.NamePrefix);
}
}