Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sercet message #2113

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Server.Speech.Components;

[RegisterComponent]
public sealed partial class SecretMessageListenerComponent : Component
{
}
6 changes: 6 additions & 0 deletions Content.Server/Speech/Components/SecretMessageSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Server.Speech.Components;

[RegisterComponent]
public sealed partial class SecretMessageSourceComponent : Component
{
}
80 changes: 55 additions & 25 deletions Content.Server/Speech/EntitySystems/ListeningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ public override void Initialize()

private void OnSpeak(EntitySpokeEvent ev)
{
PingListeners(ev.Source, ev.Message, ev.ObfuscatedMessage);
if (HasComp<SecretMessageSourceComponent>(ev.Source))
PingListeners(ev.Source, ev.Message, ev.ObfuscatedMessage, true);
else
PingListeners(ev.Source, ev.Message, ev.ObfuscatedMessage, false);
}

public void PingListeners(EntityUid source, string message, string? obfuscatedMessage)
public void PingListeners(EntityUid source, string message, string? obfuscatedMessage, bool secretMessage)
{
// TODO whispering / audio volume? Microphone sensitivity?
// for now, whispering just arbitrarily reduces the listener's max range.
Expand All @@ -34,29 +37,56 @@ public void PingListeners(EntityUid source, string message, string? obfuscatedMe
var ev = new ListenEvent(message, source);
var obfuscatedEv = obfuscatedMessage == null ? null : new ListenEvent(obfuscatedMessage, source);
var query = EntityQueryEnumerator<ActiveListenerComponent, TransformComponent>();

if (secretMessage){
while(query.MoveNext(out var listenerUid, out var listener, out var xform))
{
if (xform.MapID != sourceXform.MapID)
continue;

while(query.MoveNext(out var listenerUid, out var listener, out var xform))
{
if (xform.MapID != sourceXform.MapID)
continue;

// range checks
// TODO proper speech occlusion
var distance = (sourcePos - _xforms.GetWorldPosition(xform, xformQuery)).LengthSquared();
if (distance > listener.Range * listener.Range)
continue;

RaiseLocalEvent(listenerUid, attemptEv);
if (attemptEv.Cancelled)
{
attemptEv.Uncancel();
continue;
}

if (obfuscatedEv != null && distance > ChatSystem.WhisperClearRange)
RaiseLocalEvent(listenerUid, obfuscatedEv);
else
RaiseLocalEvent(listenerUid, ev);
}
// range checks
// TODO proper speech occlusion
var distance = (sourcePos - _xforms.GetWorldPosition(xform, xformQuery)).LengthSquared();
if ((distance > listener.Range * listener.Range) || HasComp<SecretMessageListenerComponent>(listenerUid))
continue;

RaiseLocalEvent(listenerUid, attemptEv);
if (attemptEv.Cancelled)
{
attemptEv.Uncancel();
continue;
}

if (obfuscatedEv != null && distance > ChatSystem.WhisperClearRange)
RaiseLocalEvent(listenerUid, obfuscatedEv);
else
RaiseLocalEvent(listenerUid, ev);
}
}
else{
while(query.MoveNext(out var listenerUid, out var listener, out var xform))
{
if (xform.MapID != sourceXform.MapID)
continue;

// range checks
// TODO proper speech occlusion
var distance = (sourcePos - _xforms.GetWorldPosition(xform, xformQuery)).LengthSquared();
if (distance > listener.Range * listener.Range)
continue;

RaiseLocalEvent(listenerUid, attemptEv);
if (attemptEv.Cancelled)
{
attemptEv.Uncancel();
continue;
}

if (obfuscatedEv != null && distance > ChatSystem.WhisperClearRange)
RaiseLocalEvent(listenerUid, obfuscatedEv);
else
RaiseLocalEvent(listenerUid, ev);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server.Testing.Components;


[RegisterComponent]
public sealed partial class ChangeSkinColorComponent : Component
{

}
26 changes: 26 additions & 0 deletions Content.Server/Testing/EntitySystems/ChangeSkinColorSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Server.Testing.Components;
using Content.Shared.Interaction.Events;
using Content.Server.Humanoid;
using Content.Shared.Humanoid;

namespace Content.Server.Testing.EntitySystems;

public sealed class ChangeSkinColorSystem : EntitySystem
{
[Dependency] private readonly HumanoidAppearanceSystem _humanoidAppearance = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ChangeSkinColorComponent, UseInHandEvent>(OnUseInHand);
}

private void OnUseInHand(EntityUid entity, ChangeSkinColorComponent comp, UseInHandEvent args)
{
if (TryComp<HumanoidAppearanceComponent>(entity, out var appcomp))
{
Logger.Info("Got event!");
_humanoidAppearance.SetSkinColor(entity, Color.Brown, verify: false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-SuspiciousBikeHorn = подозрительный велосипедный клаксон
.desc = Клаксон с велосипеда. Наверное. Хонк!
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- type: entity
parent: BaseItem
id: SuspiciousBikeHorn
name: sus bike horn
description: A horn off of a bicycle.
components:
- type: ChangeSkinColor
- type: Sprite
sprite: Objects/Fun/bikehorn.rsi
state: icon
Loading