From 968644c8cf07b2fe088ea490c7182efd33091f3d Mon Sep 17 00:00:00 2001 From: Creatorbot01 Date: Fri, 14 Feb 2025 08:24:54 +0800 Subject: [PATCH] ouiji board added(not work yet) --- .../_Arc/OuijiBoard/AACTabletComponent.cs | 15 ++++++ .../_Arc/OuijiBoard/AACTabletSystem.cs | 52 +++++++++++++++++++ .../Entities/Objects/Devices/ouijiboard.yml | 47 +++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 Content.Server/_Arc/OuijiBoard/AACTabletComponent.cs create mode 100644 Content.Server/_Arc/OuijiBoard/AACTabletSystem.cs create mode 100644 Resources/Prototypes/_Arc/Entities/Objects/Devices/ouijiboard.yml diff --git a/Content.Server/_Arc/OuijiBoard/AACTabletComponent.cs b/Content.Server/_Arc/OuijiBoard/AACTabletComponent.cs new file mode 100644 index 000000000000..59c41181fecd --- /dev/null +++ b/Content.Server/_Arc/OuijiBoard/AACTabletComponent.cs @@ -0,0 +1,15 @@ +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; + +namespace Content.Server._Arc.OuijiBoard; + +[RegisterComponent, AutoGenerateComponentPause] +public sealed partial class OuijiBoardComponent : Component +{ + // Minimum time between each phrase, to prevent spam + [DataField] + public TimeSpan Cooldown = TimeSpan.FromSeconds(10); + + // Time that the next phrase can be sent. + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] + public TimeSpan NextPhrase; +} diff --git a/Content.Server/_Arc/OuijiBoard/AACTabletSystem.cs b/Content.Server/_Arc/OuijiBoard/AACTabletSystem.cs new file mode 100644 index 000000000000..078d77daede2 --- /dev/null +++ b/Content.Server/_Arc/OuijiBoard/AACTabletSystem.cs @@ -0,0 +1,52 @@ +using Content.Server.Abilities.Mime; +using Content.Server.Chat.Systems; +using Content.Server.Speech.Components; +using Content.Shared.Chat; +using Content.Shared.DeltaV.AACTablet; +using Content.Shared.IdentityManagement; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Server._Arc.OuijiBoard; + +public sealed class OuijiBoardSystem : EntitySystem +{ + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly IPrototypeManager _prototype = default!; + [Dependency] private readonly MimePowersSystem _mimePowers = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnSendPhrase); + } + + private void OnSendPhrase(Entity ent, ref AACTabletSendPhraseMessage message) + { + if (ent.Comp.NextPhrase > _timing.CurTime) + return; + + var senderName = Identity.Entity(message.Actor, EntityManager); + var speakerName = Loc.GetString("speech-name-relay", + ("speaker", Name(ent)), + ("originalName", "Ghost")); + + if (!_prototype.TryIndex(message.PhraseId, out var phrase)) + return; + + if (HasComp(message.Actor)) + _mimePowers.BreakVow(message.Actor); + + EnsureComp(ent).NameOverride = speakerName; + + _chat.TrySendInGameICMessage(ent, + Loc.GetString(phrase.Text), + InGameICChatType.Speak, + hideChat: false, + nameOverride: speakerName); + + var curTime = _timing.CurTime; + ent.Comp.NextPhrase = curTime + ent.Comp.Cooldown; + } +} diff --git a/Resources/Prototypes/_Arc/Entities/Objects/Devices/ouijiboard.yml b/Resources/Prototypes/_Arc/Entities/Objects/Devices/ouijiboard.yml new file mode 100644 index 000000000000..d0a4ff7fe745 --- /dev/null +++ b/Resources/Prototypes/_Arc/Entities/Objects/Devices/ouijiboard.yml @@ -0,0 +1,47 @@ +- type: entity + parent: BaseItem + id: ouijiboard + name: ouiji board + description: board where not only human can use it but ghost as well... + components: + - type: Sprite + sprite: DeltaV/Objects/Devices/tablets.rsi + layers: + - state: aac_tablet + - state: aac_screen + shader: unshaded + state: icon + - type: Item + inhandVisuals: + left: + - state: aac-inhand-left + - state: aac_screen-inhand-left + shader: unshaded + right: + - state: aac-inhand-right + - state: aac_screen-inhand-right + shader: unshaded + - type: ActivatableUI + singleUser: false + RequireActiveHand: false + RequiredComplex: false + key: enum.AACTabletKey.Key + - type: Damageable + damageContainer: Inorganic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - type: UserInterface + interfaces: + enum.AACTabletKey.Key: + type: AACBoundUserInterface + RequireInputValidation: false + - type: Speech + speechSounds: Alto + - type: OuijiBoard + - type: VoiceMask \ No newline at end of file