This commit is contained in:
Aviu00
2024-01-13 12:24:00 +03:00
parent b39320ad30
commit b40f935571
22 changed files with 93 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
using Content.Client.Ghost;
using Content.Shared.Ghost;
using Content.Shared.White.CustomGhostSystem;
using Robust.Client.GameObjects;

View File

@@ -11,16 +11,14 @@ public sealed class JukeboxBUI : BoundUserInterface
private readonly SharedPopupSystem _sharedPopupSystem = default!;
private JukeboxMenu? _window;
public JukeboxBUI(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public JukeboxBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_sharedPopupSystem = _entityManager.System<SharedPopupSystem>();
var uid = owner.Owner;
if (!_entityManager.TryGetComponent<JukeboxComponent>(uid, out var jukeboxComponent))
if (!_entityManager.TryGetComponent(owner, out JukeboxComponent? jukeboxComponent))
{
_sharedPopupSystem.PopupEntity($"Тут нет JukeboxComponent, звоните кодерам", uid);
_sharedPopupSystem.PopupEntity($"Тут нет JukeboxComponent, звоните кодерам", owner);
return;
}

View File

@@ -5,7 +5,6 @@ using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using TerraFX.Interop.Windows;
namespace Content.Client.White.Jukebox;

View File

@@ -10,6 +10,8 @@ using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.GameStates;
@@ -67,18 +69,18 @@ public sealed class JukeboxSystem : EntitySystem
private void OnComponentRemoved(EntityUid uid, JukeboxComponent component, ComponentRemove args)
{
if (!_playingJukeboxes.TryGetValue(component, out var playingData)) return;
playingData.PlayingStream.Stop();
_audioSystem.Stop(playingData.PlayingStream, playingData.Component);
_playingJukeboxes.Remove(component);
}
private void OnStopPlaying(JukeboxStopPlaying ev)
{
if (!ev.JukeboxUid.HasValue) return;
if(!TryComp<JukeboxComponent>(ev.JukeboxUid, out var jukeboxComponent)) return;
if(!TryComp<JukeboxComponent>(GetEntity(ev.JukeboxUid), out var jukeboxComponent)) return;
if(!_playingJukeboxes.TryGetValue(jukeboxComponent, out var jukeboxAudio)) return;
jukeboxAudio.PlayingStream.Stop();
_audioSystem.Stop(jukeboxAudio.PlayingStream, jukeboxAudio.Component);
_playingJukeboxes.Remove(jukeboxComponent);
}
@@ -91,7 +93,7 @@ public sealed class JukeboxSystem : EntitySystem
RaiseNetworkEvent(new JukeboxRequestSongPlay()
{
Jukebox = component.Owner,
Jukebox = GetNetEntity(component.Owner),
SongName = jukeboxSong.SongName,
SongPath = jukeboxSong.SongPath,
SongDuration = (float)songResource.AudioStream.Length.TotalSeconds
@@ -128,11 +130,11 @@ public sealed class JukeboxSystem : EntitySystem
{
if(jukeboxXform.MapID != playerXform.MapID) continue;
if ((jukeboxXform.MapPosition.Position - playerXform.MapPosition.Position).Length > _maxAudioRange) continue;
if ((jukeboxXform.MapPosition.Position - playerXform.MapPosition.Position).Length() > _maxAudioRange) continue;
if (_playingJukeboxes.TryGetValue(jukeboxComponent, out var jukeboxAudio))
{
if (jukeboxAudio.PlayingStream.Done)
if (!jukeboxAudio.Component.Playing)
{
HandleDoneStream(jukeboxAudio, jukeboxComponent);
return;
@@ -167,7 +169,7 @@ public sealed class JukeboxSystem : EntitySystem
private void HandleSongChanged(JukeboxAudio jukeboxAudio, JukeboxComponent jukeboxComponent)
{
jukeboxAudio.PlayingStream.Stop();
_audioSystem.Stop(jukeboxAudio.PlayingStream, jukeboxAudio.Component);
if (jukeboxComponent.PlayingSongData != null && jukeboxComponent.PlayingSongData.SongPath == jukeboxAudio.SongData.SongPath)
{
@@ -188,7 +190,7 @@ public sealed class JukeboxSystem : EntitySystem
{
if (!jukeboxComponent.Repeating)
{
jukeboxAudio.PlayingStream.Stop();
_audioSystem.Stop(jukeboxAudio.PlayingStream, jukeboxAudio.Component);
_playingJukeboxes.Remove(jukeboxComponent);
SetBarsLayerVisible(jukeboxComponent, false);
return;
@@ -234,25 +236,22 @@ public sealed class JukeboxSystem : EntitySystem
MaxDistance = _maxAudioRange
};
AudioSystem.PlayingStream? playingStream = null!;
var playingStream = _audioSystem.PlayEntity(resourcePath.ToString()!, localSession, jukeboxComponent.Owner, audioParams);
playingStream = _audioSystem.PlayEntity(resourcePath.ToString()!, localSession, jukeboxComponent.Owner, audioParams) as AudioSystem.PlayingStream;
if (playingStream == null)
return null!;
return new JukeboxAudio(playingStream, audio!, jukeboxComponent.PlayingSongData);
return new JukeboxAudio(playingStream.Value.Entity, playingStream.Value.Component, audio!, jukeboxComponent.PlayingSongData);
}
private class JukeboxAudio
{
public PlayingSongData SongData { get; }
public AudioSystem.PlayingStream PlayingStream { get; }
public EntityUid PlayingStream { get; }
public AudioComponent Component { get; }
public AudioResource AudioStream { get; }
public JukeboxAudio(AudioSystem.PlayingStream playingStream, AudioResource audioStream, PlayingSongData songData)
public JukeboxAudio(EntityUid playingStream, AudioComponent component, AudioResource audioStream, PlayingSongData songData)
{
PlayingStream = playingStream;
Component = component;
AudioStream = audioStream;
SongData = songData;
}
@@ -269,7 +268,7 @@ public sealed class JukeboxSystem : EntitySystem
{
foreach (var playingJukebox in _playingJukeboxes.Values)
{
playingJukebox.PlayingStream.Stop();
_audioSystem.Stop(playingJukebox.PlayingStream, playingJukebox.Component);
}
_playingJukeboxes.Clear();

View File

@@ -11,16 +11,14 @@ public sealed class TapeCreatorBUI : BoundUserInterface
private TapeCreatorMenu? _window;
public TapeCreatorBUI(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public TapeCreatorBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_sharedPopupSystem = _entityManager.System<SharedPopupSystem>();
var uid = owner.Owner;
if (!_entityManager.TryGetComponent<TapeCreatorComponent>(uid, out var tapeCreatorComponent))
if (!_entityManager.TryGetComponent<TapeCreatorComponent>(owner, out var tapeCreatorComponent))
{
_sharedPopupSystem.PopupEntity($"Тут нет TapeCreatorComponent, звоните кодерам", uid);
_sharedPopupSystem.PopupEntity($"Тут нет TapeCreatorComponent, звоните кодерам", owner);
return;
}

View File

@@ -67,7 +67,7 @@ public sealed partial class TapeCreatorMenu : DefaultWindow
{
SongName = songName,
SongBytes = songBytes,
TapeCreatorUid = _component.Owner
TapeCreatorUid = _entityManager.GetNetEntity(_component.Owner)
};
_huetaSystem.SendNetMessage(msg);

View File

@@ -227,7 +227,7 @@ public sealed partial class StoreSystem
UpdateUserInterface(buyer, uid, component);
}
public void CloseSessionUi(EntityUid user, StoreComponent component)
public void CloseUi(EntityUid user, StoreComponent component)
{
if (!TryComp<ActorComponent>(user, out var actor))
return;

View File

@@ -1,7 +1,9 @@
using Content.Server.Ghost.Components;
using Content.Shared.Ghost;
using Content.Shared.White.CustomGhostSystem;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.White.CustomGhostSpriteSystem;
@@ -11,6 +13,7 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
public override void Initialize()
@@ -45,12 +48,12 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
if (customGhostPrototype.GhostName != string.Empty)
{
MetaData(ghostUid).EntityName = customGhostPrototype.GhostName;
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName);
}
if (customGhostPrototype.GhostDescription != string.Empty)
{
MetaData(ghostUid).EntityDescription = customGhostPrototype.GhostDescription;
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
}
return;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Verbs;
using Content.Shared.White.Jukebox;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Shared.Containers;
@@ -21,7 +22,7 @@ public sealed class JukeboxSystem : EntitySystem
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly PVSOverrideSystem _pvsOverrideSystem = default!;
[Dependency] private readonly PvsOverrideSystem _pvsOverrideSystem = default!;
private readonly List<JukeboxComponent> _playingJukeboxes = new();
@@ -132,7 +133,7 @@ public sealed class JukeboxSystem : EntitySystem
private void OnSongRequestPlay(JukeboxRequestSongPlay msg, EntitySessionEventArgs args)
{
var jukebox = Comp<JukeboxComponent>(msg.Jukebox!.Value);
var jukebox = Comp<JukeboxComponent>(GetEntity(msg.Jukebox!.Value));
jukebox.Repeating = true;
var songData = new PlayingSongData()

View File

@@ -113,7 +113,7 @@ public sealed class TapeCreatorSystem : EntitySystem
component.TapeContainer.Insert(args.Used);
}
component.InsertedTape = tape.Owner;
component.InsertedTape = GetNetEntity(tape.Owner);
Dirty(component);
return;
}
@@ -130,7 +130,7 @@ public sealed class TapeCreatorSystem : EntitySystem
private void OnSongUploaded(JukeboxSongUploadRequest ev)
{
if(!TryComp<TapeCreatorComponent>(ev.TapeCreatorUid, out var tapeCreatorComponent)) return;
if(!TryComp<TapeCreatorComponent>(GetEntity(ev.TapeCreatorUid), out var tapeCreatorComponent)) return;
if (!tapeCreatorComponent.InsertedTape.HasValue || tapeCreatorComponent.CoinBalance <= 0)
{
@@ -141,7 +141,7 @@ public sealed class TapeCreatorSystem : EntitySystem
tapeCreatorComponent.CoinBalance -= 1;
tapeCreatorComponent.Recording = true;
var tapeComponent = Comp<TapeComponent>(tapeCreatorComponent.InsertedTape.Value);
var tapeComponent = Comp<TapeComponent>(GetEntity(tapeCreatorComponent.InsertedTape.Value));
var songData = _songsSyncManager.SyncSongData(ev.SongName, ev.SongBytes);
var song = new JukeboxSong()
@@ -152,7 +152,7 @@ public sealed class TapeCreatorSystem : EntitySystem
tapeComponent.Songs.Add(song);
_popupSystem.PopupEntity($"Запись началась, примерное время ожидания: {_recordTime} секунд", tapeCreatorComponent.Owner);
Dirty(ev.TapeCreatorUid);
DirtyEntity(GetEntity(ev.TapeCreatorUid));
Dirty(tapeComponent);
StartRecordDelayAsync(tapeCreatorComponent, _popupSystem, _containerSystem);
}

View File

@@ -60,7 +60,11 @@ public sealed class LoadoutSystem : EntitySystem
// Automatically search empty slot for clothes to equip
string? firstSlotName = null;
bool isEquiped = false;
foreach (var slot in _inventorySystem.GetSlots(ev.Mob))
if (!_inventorySystem.TryGetSlots(ev.Mob, out var slots))
continue;
foreach (var slot in slots)
{
if (!clothing.Slots.HasFlag(slot.SlotFlags))
continue;
@@ -87,7 +91,7 @@ public sealed class LoadoutSystem : EntitySystem
_inventorySystem.TryGetSlotEntity(ev.Mob, BackpackSlotId, out var backEntity) &&
_storageSystem.CanInsert(backEntity.Value, slotEntity.Value, out _))
{
_storageSystem.Insert(backEntity.Value, slotEntity.Value);
_storageSystem.Insert(backEntity.Value, slotEntity.Value, out _);
}
_inventorySystem.TryEquip(ev.Mob, entity, firstSlotName, true);
}

View File

@@ -107,7 +107,7 @@ public sealed class MeatyOreStoreSystem : EntitySystem
var playerEntity = session.AttachedEntity;
if(!playerEntity.HasValue) continue;
_storeSystem.CloseSessionUi(playerEntity.Value, meatyOreStoreData.Value);
_storeSystem.CloseUi(playerEntity.Value, meatyOreStoreData.Value);
}
}
MeatyOrePanelEnabled = newValue;

View File

@@ -1,6 +1,6 @@
namespace Content.Server.White.Other.EnergySword;
[RegisterComponent]
public sealed class DoubleSwordCraftComponent : Component
public sealed partial class DoubleSwordCraftComponent : Component
{
}

View File

@@ -1,16 +1,13 @@
using Content.Shared.Actions.ActionTypes;
using Robust.Shared.Utility;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.White.Other.Lazy;
[RegisterComponent]
public sealed class EarsSpawnComponent : Component
public sealed partial class EarsSpawnComponent : Component
{
[DataField("summonAction")] public InstantAction SummonAction = new()
{
Icon = new SpriteSpecifier.Texture(new ResPath("Clothing/Head/Hats/witch.rsi/icon.png")),
DisplayName = "summon cat ears",
Description = "meow!",
Event = new SummonActionEarsEvent()
};
[DataField("summonAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SummonAction = "ActionEarsSummon";
[DataField("summonActionEntity")] public EntityUid? SummonActionEntity;
}

View File

@@ -3,7 +3,9 @@ using Content.Shared.Actions;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Content.Shared.White.Events;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
namespace Content.Server.White.Other.Lazy;
@@ -79,10 +81,6 @@ public sealed class EarsSpawnSystem : EntitySystem
private static void GetSummonAction(EntityUid uid, EarsSpawnComponent component, GetItemActionsEvent args)
{
args.Actions.Add(component.SummonAction);
args.AddAction(ref component.SummonActionEntity, component.SummonAction);
}
}
public sealed class SummonActionEarsEvent : InstantActionEvent
{
}

View File

@@ -1,8 +1,10 @@
using Content.Server.Chat.Systems;
using Content.Server.Ghost.Components;
using Content.Shared.Ghost;
using Content.Shared.Humanoid;
using Content.Shared.Mobs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;
namespace Content.Server.White.Other;
@@ -19,7 +21,7 @@ public sealed class OnDeath : EntitySystem
SubscribeLocalEvent<GhostComponent, ComponentInit>(OnGhosted);
}
private readonly Dictionary<EntityUid, IPlayingAudioStream> _playingStreams = new();
private readonly Dictionary<EntityUid, EntityUid> _playingStreams = new();
private static readonly SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds");
private static readonly SoundSpecifier HeartSounds = new SoundCollectionSpecifier("heartSounds");
private static readonly string[] DeathGaspMessages =
@@ -58,14 +60,11 @@ public sealed class OnDeath : EntitySystem
{
if (_playingStreams.TryGetValue(uid, out var currentStream))
{
currentStream.Stop();
_audio.Stop(currentStream);
}
var newStream = _audio.PlayEntity(HeartSounds, uid, uid, AudioParams.Default.WithLoop(true));
if (newStream != null)
{
_playingStreams[uid] = newStream;
}
_playingStreams[uid] = newStream.Value.Entity;
}
@@ -73,7 +72,7 @@ public sealed class OnDeath : EntitySystem
{
if (_playingStreams.TryGetValue(uid, out var currentStream))
{
currentStream.Stop();
_audio.Stop(currentStream);
_playingStreams.Remove(uid);
}
}
@@ -85,7 +84,7 @@ public sealed class OnDeath : EntitySystem
=> Loc.GetString(message);
private void SendDeathGaspMessage(EntityUid uid, string message)
=> _chat.TrySendInGameICMessage(uid, message, InGameICChatType.Emote, false, force: true);
=> _chat.TrySendInGameICMessage(uid, message, InGameICChatType.Emote, ChatTransmitRange.Normal, force: true);
private void PlayDeathSound(EntityUid uid)
=> _audio.PlayEntity(DeathSounds, uid, uid, AudioParams.Default);

View File

@@ -0,0 +1,7 @@
using Content.Shared.Actions;
namespace Content.Shared.White.Events;
public sealed partial class SummonActionEarsEvent : InstantActionEvent
{
}

View File

@@ -22,7 +22,7 @@ public enum TapeCreatorUIKey : byte
}
[NetworkedComponent, RegisterComponent]
public class JukeboxComponent : Component
public sealed partial class JukeboxComponent : Component
{
public static string JukeboxContainerName = "jukebox_tapes";
@@ -46,7 +46,7 @@ public class JukeboxComponent : Component
public PlayingSongData? PlayingSongData { get; set; }
}
public class TapeContainerComponent : Component
public sealed partial class TapeContainerComponent : Component
{
public int MaxTapeCount = 1;
public Container TapeContainer { get; set; } = new();
@@ -71,7 +71,7 @@ public class JukeboxComponentState : ComponentState
}
[Serializable, NetSerializable, DataDefinition]
public class JukeboxSong
public sealed partial class JukeboxSong
{
[DataField("songName")]
public string? SongName;
@@ -84,20 +84,20 @@ public class JukeboxRequestSongPlay : EntityEventArgs
{
public string? SongName { get; set; }
public ResPath? SongPath { get; set; }
public EntityUid? Jukebox { get; set; }
public NetEntity? Jukebox { get; set; }
public float SongDuration { get; set; }
}
[Serializable, NetSerializable]
public class JukeboxRequestStop : EntityEventArgs
{
public EntityUid? JukeboxUid { get; set; }
public NetEntity? JukeboxUid { get; set; }
}
[Serializable, NetSerializable]
public class JukeboxStopPlaying : EntityEventArgs
{
public EntityUid? JukeboxUid { get; set; }
public NetEntity? JukeboxUid { get; set; }
}
[Serializable, NetSerializable]
@@ -105,7 +105,7 @@ public class JukeboxSongUploadRequest : EntityEventArgs
{
public string SongName = string.Empty;
public List<byte> SongBytes = new();
public EntityUid TapeCreatorUid = default!;
public NetEntity TapeCreatorUid = default!;
}
public class JukeboxSongUploadNetMessage : NetMessage

View File

@@ -4,14 +4,14 @@ using Robust.Shared.Serialization;
namespace Content.Shared.White.Jukebox;
[RegisterComponent, NetworkedComponent]
public sealed class TapeComponent : Component
public sealed partial class TapeComponent : Component
{
[DataField("songs")]
public List<JukeboxSong> Songs { get; set; } = new();
}
[Serializable, NetSerializable]
public sealed class TapeComponentState : ComponentState
public sealed partial class TapeComponentState : ComponentState
{
public List<JukeboxSong> Songs { get; set; } = new();
}

View File

@@ -5,7 +5,7 @@ using Robust.Shared.Serialization;
namespace Content.Shared.White.Jukebox;
[RegisterComponent, NetworkedComponent]
public sealed class TapeCreatorComponent : Component
public sealed partial class TapeCreatorComponent : Component
{
[DataField("coins")]
public int CoinBalance { get; set; }
@@ -14,7 +14,7 @@ public sealed class TapeCreatorComponent : Component
public bool Recording { get; set; }
[ViewVariables(VVAccess.ReadOnly)]
public EntityUid? InsertedTape { get; set; }
public NetEntity? InsertedTape { get; set; }
[ViewVariables(VVAccess.ReadOnly)]
public Container TapeContainer { get; set; } = default!;
@@ -25,5 +25,5 @@ public sealed class TapeCreatorComponentState : ComponentState
{
public int CoinBalance { get; set; }
public bool Recording { get; set; }
public EntityUid? InsertedTape { get; set; }
public NetEntity? InsertedTape { get; set; }
}

View File

@@ -25,7 +25,7 @@
underweart: ClothingUnderwearTopBraWhite # White-Underwear
underwearb: ClothingUnderwearBottomPantiesWhite # White-Underwear
inhand:
right hand: BriefcaseBrownFilled
- BriefcaseBrownFilled
innerclothingskirt: ClothingUniformJumpskirtColorLightBrown
satchel: ClothingBackpackSatchelLibrarianFilled
duffelbag: ClothingBackpackDuffelLibrarianFilled

View File

@@ -0,0 +1,10 @@
- type: entity
id: ActionEarsSummon
name: summon cat ears
description: meow!
noSpawn: true
components:
- type: InstantAction
icon: { sprite: Clothing/Head/Hats/witch.rsi, state: icon }
event: !type:SummonActionEarsEvent {}
useDelay: 1