diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index 1cc3c720a0..ff63ab58ad 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -15,6 +15,7 @@ using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Markers; using Content.Shared.GameObjects.Components.Research; using Content.Shared.GameObjects.Components.VendingMachines; +using Robust.Client; using Robust.Client.Interfaces; using Robust.Client.Interfaces.Graphics.Overlays; using Robust.Client.Interfaces.Input; @@ -227,6 +228,14 @@ namespace Content.Client IoCManager.Resolve().Initialize(); IoCManager.Resolve().Initialize(); + _baseClient.RunLevelChanged += (sender, args) => + { + if (args.NewLevel == ClientRunLevel.Initialize) + { + _stateManager.RequestStateChange(); + } + }; + // Fire off into state dependent on launcher or not. if (_gameController.LaunchState.FromLauncher) { diff --git a/Content.Client/GameObjects/Components/Mobs/ClientStatusEffectsComponent.cs b/Content.Client/GameObjects/Components/Mobs/ClientStatusEffectsComponent.cs index 0e915772a4..e3edf3d34b 100644 --- a/Content.Client/GameObjects/Components/Mobs/ClientStatusEffectsComponent.cs +++ b/Content.Client/GameObjects/Components/Mobs/ClientStatusEffectsComponent.cs @@ -76,10 +76,6 @@ namespace Content.Client.GameObjects.Components.Mobs private void PlayerDetached() { - if (!CurrentlyControlled) - { - return; - } _ui?.Dispose(); _ui = null; } diff --git a/Content.Client/GameObjects/Components/Observer/GhostComponent.cs b/Content.Client/GameObjects/Components/Observer/GhostComponent.cs index 67b81a6345..21403b3a76 100644 --- a/Content.Client/GameObjects/Components/Observer/GhostComponent.cs +++ b/Content.Client/GameObjects/Components/Observer/GhostComponent.cs @@ -34,7 +34,6 @@ namespace Content.Client.GameObjects.Components.Observer private void SetGhostVisibility(bool visibility) { - // So, for now this is a client-side hack... Please, PLEASE someone make this work server-side. foreach (var ghost in _componentManager.GetAllComponents(typeof(GhostComponent))) { if (ghost.Owner.TryGetComponent(out SpriteComponent component)) diff --git a/Content.Client/GameObjects/Components/StackComponent.cs b/Content.Client/GameObjects/Components/StackComponent.cs index c24b1787a5..af5dfe3e8d 100644 --- a/Content.Client/GameObjects/Components/StackComponent.cs +++ b/Content.Client/GameObjects/Components/StackComponent.cs @@ -1,5 +1,4 @@ -using Content.Client.UserInterface; -using Content.Client.UserInterface.Stylesheets; +using Content.Client.UserInterface.Stylesheets; using Content.Client.Utility; using Content.Shared.GameObjects.Components; using Robust.Client.UserInterface; @@ -14,21 +13,19 @@ namespace Content.Client.GameObjects.Components [RegisterComponent] public class StackComponent : SharedStackComponent, IItemStatus { - [ViewVariables] public int Count { get; private set; } - [ViewVariables] public int MaxCount { get; private set; } - [ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded; public Control MakeControl() => new StatusControl(this); - public override void HandleComponentState(ComponentState curState, ComponentState nextState) + public override int Count { - if (!(curState is StackComponentState cast)) - return; + get => base.Count; + set + { + base.Count = value; - Count = cast.Count; - MaxCount = cast.MaxCount; - _uiUpdateNeeded = true; + _uiUpdateNeeded = true; + } } private sealed class StatusControl : Control diff --git a/Content.Client/State/GameScreenBase.cs b/Content.Client/State/GameScreenBase.cs index 4cb8896e26..3e277799dd 100644 --- a/Content.Client/State/GameScreenBase.cs +++ b/Content.Client/State/GameScreenBase.cs @@ -43,8 +43,6 @@ namespace Content.Client.State public override void Shutdown() { - _playerManager.LocalPlayer.DetachEntity(); - _inputManager.KeyBindStateChanged -= OnKeyBindStateChanged; } diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs index f7f3b81bbd..be64cfb14f 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs @@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Stack; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces; using Content.Shared.Construction; +using Content.Shared.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; @@ -14,7 +15,6 @@ using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Localization; -using Robust.Shared.Map; using Robust.Shared.ViewVariables; using static Content.Shared.Construction.ConstructionStepMaterial; using static Content.Shared.Construction.ConstructionStepTool; @@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Construction { Sprite.AddLayerWithSprite(prototype.Icon); } - + } diff --git a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs index 4853900fed..6adc21ed33 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.EntitySystems; using Content.Server.Players; using Content.Shared.GameObjects.Components.Observer; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.Components; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; @@ -28,6 +29,13 @@ namespace Content.Server.GameObjects.Components.Observer } } + public override void Initialize() + { + base.Initialize(); + + Owner.EnsureComponent().Layer = (int)VisibilityFlags.Ghost; + } + public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody); public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, @@ -44,10 +52,12 @@ namespace Content.Server.GameObjects.Components.Observer actor.playerSession.ContentData().Mind.UnVisit(); } break; - case PlayerAttachedMsg _: + case PlayerAttachedMsg msg: + msg.NewPlayer.VisibilityMask |= (int)VisibilityFlags.Ghost; Dirty(); break; - case PlayerDetachedMsg _: + case PlayerDetachedMsg msg: + msg.OldPlayer.VisibilityMask &= ~(int)VisibilityFlags.Ghost; Timer.Spawn(100, Owner.Delete); break; default: diff --git a/Content.Server/GameObjects/Components/Power/LightBulbComponent.cs b/Content.Server/GameObjects/Components/Power/LightBulbComponent.cs index 9316dd6be9..f8fde7b236 100644 --- a/Content.Server/GameObjects/Components/Power/LightBulbComponent.cs +++ b/Content.Server/GameObjects/Components/Power/LightBulbComponent.cs @@ -1,7 +1,15 @@ using System; +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.Audio; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; using Robust.Shared.Maths; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -24,9 +32,14 @@ namespace Content.Server.GameObjects.Components.Power /// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless. /// [RegisterComponent] - public class LightBulbComponent : Component + public class LightBulbComponent : Component, ILand { +#pragma warning disable 649 + [Dependency] private readonly IPrototypeManager _prototypeManager; + [Dependency] private readonly IRobustRandom _random; +#pragma warning restore 649 + /// /// Invoked whenever the state of the light bulb changes. /// @@ -104,5 +117,18 @@ namespace Content.Server.GameObjects.Components.Power base.Initialize(); UpdateColor(); } + + public void Land(LandEventArgs eventArgs) + { + if (State == LightBulbState.Broken) + return; + + var soundCollection = _prototypeManager.Index("glassbreak"); + var file = _random.Pick(soundCollection.PickFiles); + + IoCManager.Resolve().GetEntitySystem().Play(file, Owner); + + State = LightBulbState.Broken; + } } } diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs index 9aaa605f1c..3b4bae15c5 100644 --- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs +++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs @@ -3,11 +3,9 @@ using Content.Server.GameObjects.EntitySystems; using Content.Shared.GameObjects.Components; using Content.Shared.Interfaces; using Robust.Shared.GameObjects; -using Robust.Shared.Interfaces.Reflection; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Map; -using Robust.Shared.Serialization; using Robust.Shared.Timers; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -23,34 +21,19 @@ namespace Content.Server.GameObjects.Components.Stack [Dependency] private readonly ISharedNotifyManager _sharedNotifyManager; #pragma warning restore 649 - private const string SerializationCache = "stack"; - private int _count = 50; - private int _maxCount = 50; private bool _throwIndividually = false; - [ViewVariables(VVAccess.ReadWrite)] - public int Count + public override int Count { - get => _count; + get => base.Count; set { - _count = value; - if (_count <= 0) + base.Count = value; + + if (Count <= 0) { Owner.Delete(); } - Dirty(); - } - } - - [ViewVariables] - public int MaxCount - { - get => _maxCount; - private set - { - _maxCount = value; - Dirty(); } } @@ -65,12 +48,6 @@ namespace Content.Server.GameObjects.Components.Stack } } - [ViewVariables] - public int AvailableSpace => MaxCount - Count; - - [ViewVariables] - public object StackType { get; private set; } - public void Add(int amount) { Count += amount; @@ -91,42 +68,6 @@ namespace Content.Server.GameObjects.Components.Stack return false; } - public override void ExposeData(ObjectSerializer serializer) - { - serializer.DataFieldCached(ref _maxCount, "max", 50); - serializer.DataFieldCached(ref _count, "count", MaxCount); - - if (!serializer.Reading) - { - return; - } - - if (serializer.TryGetCacheData(SerializationCache, out object stackType)) - { - StackType = stackType; - return; - } - - if (serializer.TryReadDataFieldCached("stacktype", out string raw)) - { - var refl = IoCManager.Resolve(); - if (refl.TryParseEnumReference(raw, out var @enum)) - { - stackType = @enum; - } - else - { - stackType = raw; - } - } - else - { - stackType = Owner.Prototype.ID; - } - serializer.SetCacheData(SerializationCache, stackType); - StackType = stackType; - } - public bool AttackBy(AttackByEventArgs eventArgs) { if (eventArgs.AttackWith.TryGetComponent(out var stack)) @@ -175,20 +116,5 @@ namespace Content.Server.GameObjects.Components.Stack "There is [color=lightgray]1[/color] thing in the stack", "There are [color=lightgray]{0}[/color] things in the stack.", Count, Count)); } - - public override ComponentState GetComponentState() - { - return new StackComponentState(Count, MaxCount); - } - } - - public enum StackType - { - Metal, - Glass, - Cable, - Ointment, - Brutepack, - FloorTileSteel } } diff --git a/Content.Server/GameObjects/VisibilityFlags.cs b/Content.Server/GameObjects/VisibilityFlags.cs new file mode 100644 index 0000000000..4acb9c988a --- /dev/null +++ b/Content.Server/GameObjects/VisibilityFlags.cs @@ -0,0 +1,10 @@ +using System; + +namespace Content.Server.GameObjects +{ + [Flags] + public enum VisibilityFlags + { + Ghost = 2, + } +} diff --git a/Content.Shared/GameObjects/Components/SharedStackComponent.cs b/Content.Shared/GameObjects/Components/SharedStackComponent.cs index 3a141d4d4d..9ceb2f69b7 100644 --- a/Content.Shared/GameObjects/Components/SharedStackComponent.cs +++ b/Content.Shared/GameObjects/Components/SharedStackComponent.cs @@ -1,16 +1,109 @@ using System; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.Reflection; +using Robust.Shared.IoC; using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; namespace Content.Shared.GameObjects.Components { public abstract class SharedStackComponent : Component { + private const string SerializationCache = "stack"; + public sealed override string Name => "Stack"; public sealed override uint? NetID => ContentNetIDs.STACK; + private int _count; + private int _maxCount; + + [ViewVariables(VVAccess.ReadWrite)] + public virtual int Count + { + get => _count; + set + { + _count = value; + if (_count <= 0) + { + Owner.Delete(); + } + + Dirty(); + } + } + + [ViewVariables] + public int MaxCount + { + get => _maxCount; + private set + { + _maxCount = value; + Dirty(); + } + } + + [ViewVariables] public int AvailableSpace => MaxCount - Count; + + [ViewVariables] public object StackType { get; private set; } + + public override void ExposeData(ObjectSerializer serializer) + { + serializer.DataFieldCached(ref _maxCount, "max", 50); + serializer.DataFieldCached(ref _count, "count", MaxCount); + + if (!serializer.Reading) + { + return; + } + + if (serializer.TryGetCacheData(SerializationCache, out object stackType)) + { + StackType = stackType; + return; + } + + if (serializer.TryReadDataFieldCached("stacktype", out string raw)) + { + var refl = IoCManager.Resolve(); + if (refl.TryParseEnumReference(raw, out var @enum)) + { + stackType = @enum; + } + else + { + stackType = raw; + } + } + else + { + stackType = Owner.Prototype.ID; + } + + serializer.SetCacheData(SerializationCache, stackType); + StackType = stackType; + } + + public override ComponentState GetComponentState() + { + return new StackComponentState(Count, MaxCount); + } + + public override void HandleComponentState(ComponentState curState, ComponentState nextState) + { + if (!(curState is StackComponentState cast)) + { + return; + } + + Count = cast.Count; + MaxCount = cast.MaxCount; + } + + [Serializable, NetSerializable] - protected sealed class StackComponentState : ComponentState + private sealed class StackComponentState : ComponentState { public int Count { get; } public int MaxCount { get; } @@ -22,4 +115,14 @@ namespace Content.Shared.GameObjects.Components } } } + + public enum StackType + { + Metal, + Glass, + Cable, + Ointment, + Brutepack, + FloorTileSteel + } } diff --git a/Resources/Audio/effects/glassbreak1.ogg b/Resources/Audio/effects/glassbreak1.ogg new file mode 100644 index 0000000000..fe14cdeda3 Binary files /dev/null and b/Resources/Audio/effects/glassbreak1.ogg differ diff --git a/Resources/Audio/effects/glassbreak2.ogg b/Resources/Audio/effects/glassbreak2.ogg new file mode 100644 index 0000000000..79163acc19 Binary files /dev/null and b/Resources/Audio/effects/glassbreak2.ogg differ diff --git a/Resources/Audio/effects/glassbreak3.ogg b/Resources/Audio/effects/glassbreak3.ogg new file mode 100644 index 0000000000..bc45ab3332 Binary files /dev/null and b/Resources/Audio/effects/glassbreak3.ogg differ diff --git a/Resources/Prototypes/SoundCollections/glassbreak.yml b/Resources/Prototypes/SoundCollections/glassbreak.yml new file mode 100644 index 0000000000..ee3d9278bb --- /dev/null +++ b/Resources/Prototypes/SoundCollections/glassbreak.yml @@ -0,0 +1,6 @@ +- type: sound_collection + id: glassbreak + files: + - /Audio/effects/glassbreak1.ogg + - /Audio/effects/glassbreak2.ogg + - /Audio/effects/glassbreak3.ogg diff --git a/RobustToolbox b/RobustToolbox index 1cdb279319..3d6a3a6216 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 1cdb279319bdb16efdc9671d0d4e0e5947b0493f +Subproject commit 3d6a3a6216fa752f422a0f1720e02fec8e8e145e