Merge branch 'master' into DecimalReagents

This commit is contained in:
PrPleGoo
2020-04-14 15:41:50 +02:00
16 changed files with 184 additions and 104 deletions

View File

@@ -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<IClientPreferencesManager>().Initialize();
IoCManager.Resolve<IItemSlotManager>().Initialize();
_baseClient.RunLevelChanged += (sender, args) =>
{
if (args.NewLevel == ClientRunLevel.Initialize)
{
_stateManager.RequestStateChange<MainScreen>();
}
};
// Fire off into state dependent on launcher or not.
if (_gameController.LaunchState.FromLauncher)
{

View File

@@ -76,10 +76,6 @@ namespace Content.Client.GameObjects.Components.Mobs
private void PlayerDetached()
{
if (!CurrentlyControlled)
{
return;
}
_ui?.Dispose();
_ui = null;
}

View File

@@ -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))

View File

@@ -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

View File

@@ -43,8 +43,6 @@ namespace Content.Client.State
public override void Shutdown()
{
_playerManager.LocalPlayer.DetachEntity();
_inputManager.KeyBindStateChanged -= OnKeyBindStateChanged;
}

View File

@@ -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);
}
}

View File

@@ -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<VisibilityComponent>().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:

View File

@@ -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.
/// </summary>
[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
/// <summary>
/// Invoked whenever the state of the light bulb changes.
/// </summary>
@@ -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<SoundCollectionPrototype>("glassbreak");
var file = _random.Pick(soundCollection.PickFiles);
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>().Play(file, Owner);
State = LightBulbState.Broken;
}
}
}

View File

@@ -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<IReflectionManager>();
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<StackComponent>(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
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Content.Server.GameObjects
{
[Flags]
public enum VisibilityFlags
{
Ghost = 2,
}
}

View File

@@ -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<IReflectionManager>();
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
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
- type: sound_collection
id: glassbreak
files:
- /Audio/effects/glassbreak1.ogg
- /Audio/effects/glassbreak2.ogg
- /Audio/effects/glassbreak3.ogg