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:
@@ -4,6 +4,7 @@ using Content.Shared.Access.Components;
|
|||||||
using Content.Shared.Clothing;
|
using Content.Shared.Clothing;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Humanoid;
|
using Content.Shared.Humanoid;
|
||||||
|
using Content.Shared.Interaction.Components;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
@@ -23,7 +24,7 @@ public sealed class OutfitSystem : EntitySystem
|
|||||||
[Dependency] private readonly InventorySystem _invSystem = default!;
|
[Dependency] private readonly InventorySystem _invSystem = default!;
|
||||||
[Dependency] private readonly SharedStationSpawningSystem _spawningSystem = 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))
|
if (!EntityManager.TryGetComponent(target, out InventoryComponent? inventoryComponent))
|
||||||
return false;
|
return false;
|
||||||
@@ -60,6 +61,8 @@ public sealed class OutfitSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
_invSystem.TryEquip(target, equipmentEntity, slot.Name, silent: true, force: true, inventory: inventoryComponent);
|
_invSystem.TryEquip(target, equipmentEntity, slot.Name, silent: true, force: true, inventory: inventoryComponent);
|
||||||
|
if (unremovable)
|
||||||
|
EnsureComp<UnremoveableComponent>(equipmentEntity);
|
||||||
|
|
||||||
onEquipped?.Invoke(target, equipmentEntity);
|
onEquipped?.Invoke(target, equipmentEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Content.Server.Clothing.Systems;
|
|||||||
using Content.Shared.Chat.Prototypes;
|
using Content.Shared.Chat.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Content.Shared.Damage.Prototypes;
|
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Content.Server.Emoting.Systems;
|
using Content.Server.Emoting.Systems;
|
||||||
@@ -21,7 +20,6 @@ namespace Content.Server.Cluwne;
|
|||||||
|
|
||||||
public sealed class CluwneSystem : EntitySystem
|
public sealed class CluwneSystem : EntitySystem
|
||||||
{
|
{
|
||||||
private static readonly ProtoId<DamageGroupPrototype> GeneticDamageGroup = "Genetic";
|
|
||||||
|
|
||||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
@@ -48,15 +46,14 @@ public sealed class CluwneSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning.
|
/// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnMobState(EntityUid uid, CluwneComponent component, MobStateChangedEvent args)
|
private void OnMobState(Entity<CluwneComponent> ent, ref MobStateChangedEvent args)
|
||||||
{
|
{
|
||||||
if (args.NewMobState == MobState.Dead)
|
if (args.NewMobState == MobState.Dead)
|
||||||
{
|
{
|
||||||
RemComp<CluwneComponent>(uid);
|
RemComp<CluwneComponent>(ent.Owner);
|
||||||
RemComp<ClumsyComponent>(uid);
|
RemComp<ClumsyComponent>(ent.Owner);
|
||||||
RemComp<AutoEmoteComponent>(uid);
|
RemComp<AutoEmoteComponent>(ent.Owner);
|
||||||
var damageSpec = new DamageSpecifier(_prototypeManager.Index(GeneticDamageGroup), 300);
|
_damageableSystem.TryChangeDamage(ent.Owner, ent.Comp.RevertDamage);
|
||||||
_damageableSystem.TryChangeDamage(uid, damageSpec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,52 +62,65 @@ public sealed class CluwneSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// OnStartup gives the cluwne outfit, ensures clumsy, and makes sure emote sounds are laugh.
|
/// OnStartup gives the cluwne outfit, ensures clumsy, and makes sure emote sounds are laugh.
|
||||||
/// </summary>
|
/// </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;
|
return;
|
||||||
_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds);
|
|
||||||
|
|
||||||
EnsureComp<AutoEmoteComponent>(uid);
|
_prototypeManager.TryIndex(ent.Comp.EmoteSoundsId, out EmoteSounds);
|
||||||
_autoEmote.AddEmote(uid, "CluwneGiggle");
|
|
||||||
EnsureComp<ClumsyComponent>(uid);
|
|
||||||
|
|
||||||
_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>
|
/// <summary>
|
||||||
/// Handles the timing on autoemote as well as falling over and honking.
|
/// Handles the timing on autoemote as well as falling over and honking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnEmote(EntityUid uid, CluwneComponent component, ref EmoteEvent args)
|
private void OnEmote(Entity<CluwneComponent> ent, ref EmoteEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
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);
|
_audio.PlayPvs(ent.Comp.SpawnSound, ent.Owner);
|
||||||
_chat.TrySendInGameICMessage(uid, "honks", InGameICChatType.Emote, ChatTransmitRange.Normal);
|
_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);
|
_audio.PlayPvs(ent.Comp.KnockSound, ent.Owner);
|
||||||
_stunSystem.TryUpdateParalyzeDuration(uid, TimeSpan.FromSeconds(component.ParalyzeTime));
|
_stunSystem.TryUpdateParalyzeDuration(ent.Owner, TimeSpan.FromSeconds(ent.Comp.ParalyzeTime));
|
||||||
_chat.TrySendInGameICMessage(uid, "spasms", InGameICChatType.Emote, ChatTransmitRange.Normal);
|
_chat.TrySendInGameICMessage(ent.Owner, Loc.GetString(ent.Comp.KnockEmote), InGameICChatType.Emote, ChatTransmitRange.Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies "Cluwnified" prefix
|
/// Applies "Cluwnified" prefix
|
||||||
/// </summary>
|
/// </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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Content.Shared.Chat.Prototypes;
|
using Content.Shared.Chat.Prototypes;
|
||||||
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.Roles;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Shared.Cluwne;
|
namespace Content.Shared.Cluwne;
|
||||||
@@ -12,22 +15,74 @@ public sealed partial class CluwneComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// timings for giggles and knocks.
|
/// timings for giggles and knocks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2);
|
public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2);
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
/// <summary>
|
||||||
|
/// Amount of genetic damage dealt when they revert
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public DamageSpecifier RevertDamage = new()
|
||||||
|
{
|
||||||
|
DamageDict = new()
|
||||||
|
{
|
||||||
|
{ "Genetic", 300.0 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chance that the Cluwne will be knocked over and paralyzed.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
public float KnockChance = 0.05f;
|
public float KnockChance = 0.05f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
/// <summary>
|
||||||
|
/// Chance that the Cluwne will randomly giggle
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
public float GiggleRandomChance = 0.1f;
|
public float GiggleRandomChance = 0.1f;
|
||||||
|
|
||||||
[DataField("emoteId", customTypeSerializer: typeof(PrototypeIdSerializer<EmoteSoundsPrototype>))]
|
/// <summary>
|
||||||
public string? EmoteSoundsId = "Cluwne";
|
/// Enable random emoting?
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool RandomEmote = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Emote sound collection that the Cluwne should use.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("emoteId")]
|
||||||
|
public ProtoId<EmoteSoundsPrototype>? EmoteSoundsId = "Cluwne";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Emote to use for the Cluwne Giggling
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public ProtoId<AutoEmotePrototype>? AutoEmoteId = "CluwneGiggle";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Message to popup when the Cluwne is transformed
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public LocId TransformMessage = "cluwne-transform";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name prefix for the Cluwne.
|
||||||
|
/// Example "Urist McHuman" will be "Cluwned Urist McHuman"
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public LocId NamePrefix = "cluwne-name-prefix";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Outfit ID that the cluwne will spawn with.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public ProtoId<StartingGearPrototype> OutfitId = "CluwneGear";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of time cluwne is paralyzed for when falling over.
|
/// Amount of time cluwne is paralyzed for when falling over.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public float ParalyzeTime = 2f;
|
public float ParalyzeTime = 2f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,6 +91,21 @@ public sealed partial class CluwneComponent : Component
|
|||||||
[DataField("spawnsound")]
|
[DataField("spawnsound")]
|
||||||
public SoundSpecifier SpawnSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
|
public SoundSpecifier SpawnSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
|
||||||
|
|
||||||
[DataField("knocksound")]
|
/// <summary>
|
||||||
|
/// Emote to use for the cluwne giggling
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public LocId GiggleEmote = "cluwne-giggle-emote";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sound to play when the Cluwne is knocked over and paralyzed
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
public SoundSpecifier KnockSound = new SoundPathSpecifier("/Audio/Items/airhorn.ogg");
|
public SoundSpecifier KnockSound = new SoundPathSpecifier("/Audio/Items/airhorn.ogg");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Emote thats used when the cluwne getting knocked over
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public LocId KnockEmote = "cluwne-knock-emote";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
cluwne-transform = {CAPITALIZE(THE($target))} turned into a cluwne!
|
cluwne-transform = {CAPITALIZE(THE($target))} turned into a cluwne!
|
||||||
cluwne-name-prefix = cluwnified {$baseName}
|
cluwne-name-prefix = cluwnified {$baseName}
|
||||||
|
cluwne-knock-emote = spasms
|
||||||
|
cluwne-giggle-emote = honks
|
||||||
|
|||||||
Reference in New Issue
Block a user