Skip to content

Commit

Permalink
Adapt holopad (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
stalengd authored Dec 22, 2024
1 parent 1f62a4b commit aebc4c3
Show file tree
Hide file tree
Showing 8 changed files with 507 additions and 7 deletions.
23 changes: 20 additions & 3 deletions Content.Client/Holopad/HolopadSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using System.Linq;
using System.Numerics;
using Vector3 = Robust.Shared.Maths.Vector3;

namespace Content.Client.Holopad;

Expand Down Expand Up @@ -112,16 +114,27 @@ private void OnPlayerSpriteStateRequest(PlayerSpriteStateRequest ev)
}

// Return the recorded data to the server
var evResponse = new PlayerSpriteStateMessage(ev.TargetPlayer, spriteLayerData.ToArray());
var evResponse = new PlayerSpriteStateMessage(ev.TargetPlayer, spriteLayerData.ToArray())
// SS220 Holopad adapt begin
{
Scale = playerSprite.Scale,
};
// SS220 Holopad adapt end
RaiseNetworkEvent(evResponse);
}

private void OnPlayerSpriteStateMessage(PlayerSpriteStateMessage ev)
{
UpdateHologramSprite(GetEntity(ev.SpriteEntity), ev.SpriteLayerData);
// SS220 Holopad adapt begin
//UpdateHologramSprite(GetEntity(ev.SpriteEntity), ev.SpriteLayerData);
UpdateHologramSprite(GetEntity(ev.SpriteEntity), ev.SpriteLayerData, ev.Scale);
// SS220 Holopad adapt end
}

private void UpdateHologramSprite(EntityUid uid, PrototypeLayerData[]? layerData = null)
// SS220 Holopad adapt begin
//private void UpdateHologramSprite(EntityUid uid, PrototypeLayerData[]? layerData = null)
private void UpdateHologramSprite(EntityUid uid, PrototypeLayerData[]? layerData = null, Vector2? scale = null)
// SS220 Holopad adapt end
{
if (!TryComp<SpriteComponent>(uid, out var hologramSprite))
return;
Expand Down Expand Up @@ -150,6 +163,10 @@ private void UpdateHologramSprite(EntityUid uid, PrototypeLayerData[]? layerData
hologramSprite.AddLayer(layerData[i], i);
}

// SS220 Holopad adapt begin
hologramSprite.Scale = scale.GetValueOrDefault(Vector2.One);
// SS220 Holopad adapt end

UpdateHologramShader(uid, hologramSprite, holopadhologram);
}

Expand Down
23 changes: 19 additions & 4 deletions Content.Server/Holopad/HolopadSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;

namespace Content.Server.Holopad;

Expand Down Expand Up @@ -331,7 +332,10 @@ private void OnPlayerSpriteStateMessage(PlayerSpriteStateMessage ev, EntitySessi
if (!TryComp<HolopadUserComponent>(uid, out var holopadUser))
return;

SyncHolopadUserWithLinkedHolograms((uid.Value, holopadUser), ev.SpriteLayerData);
// SS220 Holopad adapt begin
//SyncHolopadUserWithLinkedHolograms((uid.Value, holopadUser), ev.SpriteLayerData);
SyncHolopadUserWithLinkedHolograms((uid.Value, holopadUser), ev.SpriteLayerData, ev.Scale);
// SS220 Holopad adapt end
}

#endregion
Expand Down Expand Up @@ -557,7 +561,10 @@ private void LinkHolopadToUser(Entity<HolopadComponent> entity, EntityUid user)

if (TryComp<HolographicAvatarComponent>(user, out var avatar))
{
SyncHolopadUserWithLinkedHolograms((user, holopadUser), avatar.LayerData);
// SS220 Holopad adapt begin
//SyncHolopadUserWithLinkedHolograms((user, holopadUser), avatar.LayerData);
SyncHolopadUserWithLinkedHolograms((user, holopadUser), avatar.LayerData, Vector2.One);
// SS220 Holopad adapt end
return;
}

Expand Down Expand Up @@ -625,7 +632,10 @@ private void RequestHolopadUserSpriteUpdate(Entity<HolopadUserComponent> user)
RaiseNetworkEvent(ev);
}

private void SyncHolopadUserWithLinkedHolograms(Entity<HolopadUserComponent> entity, PrototypeLayerData[]? spriteLayerData)
// SS220 Holopad adapt begin
//private void SyncHolopadUserWithLinkedHolograms(Entity<HolopadUserComponent> entity, PrototypeLayerData[]? spriteLayerData)
private void SyncHolopadUserWithLinkedHolograms(Entity<HolopadUserComponent> entity, PrototypeLayerData[]? spriteLayerData, Vector2 scale)
// SS220 Holopad adapt end
{
foreach (var linkedHolopad in entity.Comp.LinkedHolopads)
{
Expand All @@ -635,7 +645,12 @@ private void SyncHolopadUserWithLinkedHolograms(Entity<HolopadUserComponent> ent
continue;

var netHologram = GetNetEntity(receivingHolopad.Comp.Hologram.Value);
var ev = new PlayerSpriteStateMessage(netHologram, spriteLayerData);
var ev = new PlayerSpriteStateMessage(netHologram, spriteLayerData)
// SS220 Holopad adapt begin
{
Scale = scale
};
// SS220 Holopad adapt end
RaiseNetworkEvent(ev);
}
}
Expand Down
9 changes: 9 additions & 0 deletions Content.Server/Telephone/TelephoneSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Linq;
using Content.Shared.Silicons.StationAi;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.SS220.TTS;

namespace Content.Server.Telephone;

Expand Down Expand Up @@ -108,6 +109,14 @@ private void OnTelephoneMessageReceived(Entity<TelephoneComponent> entity, ref T
("speaker", Name(entity)),
("originalName", nameEv.VoiceName));

// SS220 Holopad adapt begin
if (TryComp<TTSComponent>(args.MessageSource, out var sourceTts))
{
var ttsComponent = EnsureComp<TTSComponent>(entity);
ttsComponent.VoicePrototypeId = sourceTts.VoicePrototypeId;
}
// SS220 Holopad adapt end

var volume = entity.Comp.SpeakerVolume == TelephoneVolume.Speak ? InGameICChatType.Speak : InGameICChatType.Whisper;
_chat.TrySendInGameICMessage(entity, args.Message, volume, ChatTransmitRange.GhostRangeLimit, nameOverride: name, checkRadioPrefix: false);
}
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Holopad/HolopadUserComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

Expand Down Expand Up @@ -96,6 +97,13 @@ public sealed class PlayerSpriteStateMessage : EntityEventArgs
/// </summary>
public readonly PrototypeLayerData[]? SpriteLayerData;

// SS220 Holopad adapt begin
/// <summary>
/// Sprite scale
/// </summary>
public Vector2 Scale { get; init; } = Vector2.One;
// SS220 Holopad adapt end

public PlayerSpriteStateMessage(NetEntity spriteEntity, PrototypeLayerData[]? spriteLayerData = null)
{
SpriteEntity = spriteEntity;
Expand Down
Loading

0 comments on commit aebc4c3

Please sign in to comment.