diff --git a/BuildChecker/.gitignore b/BuildChecker/.gitignore index 97fb21bb98..5eeecc18fc 100644 --- a/BuildChecker/.gitignore +++ b/BuildChecker/.gitignore @@ -1,2 +1,5 @@ INSTALLED_HOOKS_VERSION DISABLE_SUBMODULE_AUTOUPDATE +*.nuget* +project.assets.json +project.packagespec.json \ No newline at end of file diff --git a/Content.Benchmarks/ColorInterpolateBenchmark.cs b/Content.Benchmarks/ColorInterpolateBenchmark.cs index aaa172f0aa..f45b91363d 100644 --- a/Content.Benchmarks/ColorInterpolateBenchmark.cs +++ b/Content.Benchmarks/ColorInterpolateBenchmark.cs @@ -5,7 +5,10 @@ using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; #endif using BenchmarkDotNet.Attributes; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; using Robust.Shared.Maths; +using Robust.Shared.Random; using SysVector4 = System.Numerics.Vector4; namespace Content.Benchmarks diff --git a/Content.Client/Chat/ChatBox.cs b/Content.Client/Chat/ChatBox.cs index e38d652284..eef74bf4f9 100644 --- a/Content.Client/Chat/ChatBox.cs +++ b/Content.Client/Chat/ChatBox.cs @@ -8,6 +8,7 @@ using Robust.Shared.Maths; using Robust.Shared.Utility; using Robust.Shared.Localization; using Robust.Shared.IoC; +using Robust.Shared.Input; namespace Content.Client.Chat { @@ -82,7 +83,7 @@ namespace Content.Client.Chat vBox.AddChild(contentMargin); Input = new LineEdit(); - Input.OnKeyDown += InputKeyDown; + Input.OnKeyBindDown += InputKeyBindDown; Input.OnTextEntered += Input_OnTextEntered; vBox.AddChild(Input); @@ -119,23 +120,27 @@ namespace Content.Client.Chat AddChild(outerVBox); } - protected override void MouseDown(GUIMouseButtonEventArgs e) + protected override void KeyBindDown(GUIBoundKeyEventArgs args) { - base.MouseDown(e); + base.KeyBindDown(args); + + if (!args.CanFocus) + { + return; + } Input.GrabKeyboardFocus(); } - private void InputKeyDown(GUIKeyEventArgs e) + private void InputKeyBindDown(GUIBoundKeyEventArgs args) { - if (e.Key == Keyboard.Key.Escape) + if (args.Function == EngineKeyFunctions.TextReleaseFocus) { Input.ReleaseKeyboardFocus(); - e.Handle(); + args.Handle(); return; } - - if (e.Key == Keyboard.Key.Up) + else if (args.Function == EngineKeyFunctions.TextHistoryPrev) { if (_inputIndex == -1 && _inputHistory.Count != 0) { @@ -151,12 +156,12 @@ namespace Content.Client.Chat { Input.Text = _inputHistory[_inputIndex]; } + Input.CursorPos = Input.Text.Length; - e.Handle(); + args.Handle(); return; } - - if (e.Key == Keyboard.Key.Down) + else if (args.Function == EngineKeyFunctions.TextHistoryNext) { if (_inputIndex == 0) { @@ -169,8 +174,9 @@ namespace Content.Client.Chat _inputIndex--; Input.Text = _inputHistory[_inputIndex]; } + Input.CursorPos = Input.Text.Length; - e.Handle(); + args.Handle(); } } diff --git a/Content.Client/EscapeMenuOwner.cs b/Content.Client/EscapeMenuOwner.cs index 914233839d..54c6f53cb5 100644 --- a/Content.Client/EscapeMenuOwner.cs +++ b/Content.Client/EscapeMenuOwner.cs @@ -1,4 +1,4 @@ -using Content.Client.UserInterface; +using Content.Client.UserInterface; using Robust.Client.Console; using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.Placement; @@ -49,9 +49,8 @@ namespace Content.Client _escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false; - var escapeMenuCommand = InputCmdHandler.FromDelegate(Enabled); - - _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand); + _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, + InputCmdHandler.FromDelegate(s => Enabled())); } else if (obj.OldState is GameScreen) { @@ -63,7 +62,7 @@ namespace Content.Client } } - private void Enabled(ICommonSession session) + private void Enabled() { if (_escapeMenu.IsOpen) { diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/ClientInventoryComponent.cs b/Content.Client/GameObjects/Components/HUD/Inventory/ClientInventoryComponent.cs index bc3b6c039b..4a7819589e 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/ClientInventoryComponent.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/ClientInventoryComponent.cs @@ -127,18 +127,18 @@ namespace Content.Client.GameObjects _sprite?.LayerSetVisible(slot, false); } - public void SendUnequipMessage(Slots slot) - { - var unequipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Unequip); - SendNetworkMessage(unequipmessage); - } - public void SendEquipMessage(Slots slot) { var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip); SendNetworkMessage(equipmessage); } + public void SendUseMessage(Slots slot) + { + var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Use); + SendNetworkMessage(equipmessage); + } + public void SendOpenStorageUIMessage(Slots slot) { SendNetworkMessage(new OpenSlotStorageUIMessage(slot)); diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs b/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs index fa59cf6ab9..22098aa13e 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/HumanInventoryInterfaceController.cs @@ -43,7 +43,7 @@ namespace Content.Client.GameObjects base.Initialize(); _window = new HumanInventoryWindow(_loc, _resourceCache); - + _window.OnClose += () => GameHud.InventoryButtonDown = false; foreach (var (slot, button) in _window.Buttons) { button.OnPressed = AddToInventory; @@ -97,7 +97,7 @@ namespace Content.Client.GameObjects foreach (var button in buttons) { button.SpriteView.Sprite = sprite; - button.OnPressed = RemoveFromInventory; + button.OnPressed = HandleInventoryKeybind; button.StorageButton.Visible = hasInventory; } } diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryButton.cs b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryButton.cs index 1bc30aae84..2fd04a6456 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryButton.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryButton.cs @@ -27,7 +27,8 @@ namespace Content.Client.GameObjects AddChild(Button = new TextureButton { TextureNormal = texture, - Scale = (2, 2) + Scale = (2, 2), + EnableAllKeybinds = true }); Button.OnPressed += e => OnPressed?.Invoke(e); @@ -44,7 +45,8 @@ namespace Content.Client.GameObjects Scale = (0.75f, 0.75f), SizeFlagsHorizontal = SizeFlags.ShrinkEnd, SizeFlagsVertical = SizeFlags.ShrinkEnd, - Visible = false + Visible = false, + EnableAllKeybinds = true }); StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e); diff --git a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs index d085df42de..091e1c46db 100644 --- a/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs +++ b/Content.Client/GameObjects/Components/HUD/Inventory/InventoryInterfaceController.cs @@ -1,6 +1,7 @@ -using System; +using System; using Content.Client.UserInterface; using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.Input; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Interfaces.GameObjects; @@ -60,24 +61,44 @@ namespace Content.Client.GameObjects { } - protected void RemoveFromInventory(BaseButton.ButtonEventArgs args) + protected void HandleInventoryKeybind(BaseButton.ButtonEventArgs args) { - args.Button.Pressed = false; - var control = (InventoryButton) args.Button.Parent; - - Owner.SendUnequipMessage(control.Slot); + if (args.Event.Function == ContentKeyFunctions.ActivateItemInWorld) + { + OpenStorage(args); + } + else if (args.Event.CanFocus) + { + UseItemOnInventory(args); + } } protected void AddToInventory(BaseButton.ButtonEventArgs args) { + if (!args.Event.CanFocus) + { + return; + } args.Button.Pressed = false; var control = (InventoryButton) args.Button.Parent; Owner.SendEquipMessage(control.Slot); } + protected void UseItemOnInventory(BaseButton.ButtonEventArgs args) + { + args.Button.Pressed = false; + var control = (InventoryButton)args.Button.Parent; + + Owner.SendUseMessage(control.Slot); + } + protected void OpenStorage(BaseButton.ButtonEventArgs args) { + if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld) + { + return; + } args.Button.Pressed = false; var control = (InventoryButton)args.Button.Parent; diff --git a/Content.Client/GameObjects/Components/Sound/SoundComponent.cs b/Content.Client/GameObjects/Components/Sound/SoundComponent.cs index cfed2998ee..9b46924eb0 100644 --- a/Content.Client/GameObjects/Components/Sound/SoundComponent.cs +++ b/Content.Client/GameObjects/Components/Sound/SoundComponent.cs @@ -5,6 +5,7 @@ using Robust.Client.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Network; +using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.Timers; @@ -16,7 +17,9 @@ namespace Content.Client.GameObjects.Components.Sound { private readonly List _schedules = new List(); private AudioSystem _audioSystem; - private Random Random; + #pragma warning disable 649 + [Dependency] private readonly IRobustRandom _random; + #pragma warning restore 649 public override void StopAllSounds() { @@ -46,9 +49,8 @@ namespace Content.Client.GameObjects.Components.Sound public void Play(ScheduledSound schedule) { if (!schedule.Play) return; - if (Random == null) Random = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); - Timer.Spawn((int) schedule.Delay + (Random.Next((int) schedule.RandomDelay)),() => + Timer.Spawn((int) schedule.Delay + (_random.Next((int) schedule.RandomDelay)),() => { if (!schedule.Play) return; // We make sure this hasn't changed. if (_audioSystem == null) _audioSystem = IoCManager.Resolve().GetEntitySystem(); diff --git a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs index 9071ee8e31..11216aa891 100644 --- a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs @@ -1,4 +1,4 @@ -using Content.Client.GameObjects.Components.Weapons.Ranged; +using Content.Client.GameObjects.Components.Weapons.Ranged; using Content.Client.Interfaces.GameObjects; using Content.Shared.Input; using Robust.Client.GameObjects.EntitySystems; @@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.EntitySystems base.Update(frameTime); var canFireSemi = _isFirstShot; - var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.UseItemInHand); + var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); if (state != BoundKeyState.Down) { _isFirstShot = true; diff --git a/Content.Client/GameTicking/ClientGameTicker.cs b/Content.Client/GameTicking/ClientGameTicker.cs index 59cce13532..a112b66431 100644 --- a/Content.Client/GameTicking/ClientGameTicker.cs +++ b/Content.Client/GameTicking/ClientGameTicker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using Content.Client.Chat; using Content.Client.Interfaces; @@ -18,6 +18,7 @@ using Robust.Shared.Input; using Robust.Shared.Interfaces.Network; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Players; using Robust.Shared.Timing; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -188,11 +189,7 @@ namespace Content.Client.GameTicking _lobby.ServerName.Text = _baseClient.GameInfo.ServerName; _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, - InputCmdHandler.FromDelegate(session => - { - _lobby.Chat.Input.IgnoreNext = true; - _lobby.Chat.Input.GrabKeyboardFocus(); - })); + InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat))); _updateLobbyUi(); @@ -237,19 +234,25 @@ namespace Content.Client.GameTicking _lobby = null; } - _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, - InputCmdHandler.FromDelegate(session => - { - _gameChat.Input.IgnoreNext = true; - _gameChat.Input.GrabKeyboardFocus(); - })); - _gameChat = new ChatBox(); _userInterfaceManager.StateRoot.AddChild(_gameChat); _userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl); _chatManager.SetChatBox(_gameChat); _gameChat.DefaultChatFormat = "say \"{0}\""; _gameChat.Input.PlaceHolder = _localization.GetString("Say something! [ for OOC"); + + _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, + InputCmdHandler.FromDelegate(s => _focusChat(_gameChat))); + } + + private void _focusChat(ChatBox chat) + { + if (_userInterfaceManager.KeyboardFocused != null) + { + return; + } + chat.Input.IgnoreNext = true; + chat.Input.GrabKeyboardFocus(); } private enum TickerState diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index d768e88611..13c5a43518 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -21,12 +21,12 @@ namespace Content.Client.Input human.AddFunction(ContentKeyFunctions.Drop); human.AddFunction(ContentKeyFunctions.ActivateItemInHand); human.AddFunction(ContentKeyFunctions.OpenCharacterMenu); - human.AddFunction(ContentKeyFunctions.UseItemInHand); human.AddFunction(ContentKeyFunctions.ActivateItemInWorld); human.AddFunction(ContentKeyFunctions.ThrowItemInHand); human.AddFunction(ContentKeyFunctions.OpenContextMenu); human.AddFunction(ContentKeyFunctions.OpenCraftingMenu); human.AddFunction(ContentKeyFunctions.OpenInventoryMenu); + human.AddFunction(ContentKeyFunctions.MouseMiddle); // Disabled until there is feedback, so hitting tab doesn't suddenly break interaction. // human.AddFunction(ContentKeyFunctions.ToggleCombatMode); diff --git a/Content.Client/Parallax/ParallaxGenerator.cs b/Content.Client/Parallax/ParallaxGenerator.cs index a42cf44a04..98823fc160 100644 --- a/Content.Client/Parallax/ParallaxGenerator.cs +++ b/Content.Client/Parallax/ParallaxGenerator.cs @@ -10,6 +10,7 @@ using Robust.Client.Utility; using Robust.Shared.Interfaces.Log; using Robust.Shared.Maths; using Robust.Shared.Noise; +using Robust.Shared.Random; using SixLabors.ImageSharp.Advanced; using BlendFactor = Robust.Shared.Maths.Color.BlendFactor; diff --git a/Content.Client/Research/LatheMenu.cs b/Content.Client/Research/LatheMenu.cs index e4f5964325..4a0ffbae6e 100644 --- a/Content.Client/Research/LatheMenu.cs +++ b/Content.Client/Research/LatheMenu.cs @@ -10,6 +10,7 @@ using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Timers; +using Robust.Shared.Utility; namespace Content.Client.Research { diff --git a/Content.Client/UserInterface/HandsGui.cs b/Content.Client/UserInterface/HandsGui.cs index 9ad858b277..d474a87275 100644 --- a/Content.Client/UserInterface/HandsGui.cs +++ b/Content.Client/UserInterface/HandsGui.cs @@ -2,6 +2,7 @@ using Content.Client.GameObjects.EntitySystems; using Content.Client.Interfaces.GameObjects; using Content.Client.Utility; +using Content.Shared.Input; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Interfaces.GameObjects.Components; @@ -9,6 +10,7 @@ using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; +using Robust.Shared.Input; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -199,12 +201,17 @@ namespace Content.Client.UserInterface return _handL.Contains((Vector2i) point) || _handR.Contains((Vector2i) point); } - protected override void MouseDown(GUIMouseButtonEventArgs args) + protected override void KeyBindDown(GUIBoundKeyEventArgs args) { - base.MouseDown(args); + base.KeyBindDown(args); - var leftHandContains = _handL.Contains((Vector2i) args.RelativePosition); - var rightHandContains = _handR.Contains((Vector2i) args.RelativePosition); + if (!args.CanFocus) + { + return; + } + + var leftHandContains = _handL.Contains((Vector2i)args.RelativePosition); + var rightHandContains = _handR.Contains((Vector2i)args.RelativePosition); string handIndex; if (leftHandContains) @@ -220,7 +227,7 @@ namespace Content.Client.UserInterface return; } - if (args.Button == Mouse.Button.Left) + if (args.Function == EngineKeyFunctions.Use) { if (!TryGetHands(out var hands)) return; @@ -236,12 +243,12 @@ namespace Content.Client.UserInterface } } - else if (args.Button == Mouse.Button.Middle) + else if (args.Function == ContentKeyFunctions.MouseMiddle) { SendSwitchHandTo(handIndex); } - else if (args.Button == Mouse.Button.Right) + else if (args.Function == ContentKeyFunctions.OpenContextMenu) { if (!TryGetHands(out var hands)) { @@ -255,7 +262,7 @@ namespace Content.Client.UserInterface } var esm = IoCManager.Resolve(); - esm.GetEntitySystem().OpenContextMenu(entity, new ScreenCoordinates(args.GlobalPosition)); + esm.GetEntitySystem().OpenContextMenu(entity, new ScreenCoordinates(args.PointerLocation.Position)); } } } diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs index 86e64d2b5c..c7783a2c29 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs @@ -10,6 +10,7 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; +using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.ViewVariables; using static Content.Shared.Construction.ConstructionStepMaterial; @@ -29,7 +30,9 @@ namespace Content.Server.GameObjects.Components.Construction SpriteComponent Sprite; ITransformComponent Transform; - Random random; + #pragma warning disable 649 + [Dependency] private IRobustRandom _random; + #pragma warning restore 649 public override void Initialize() { @@ -38,7 +41,6 @@ namespace Content.Server.GameObjects.Components.Construction Sprite = Owner.GetComponent(); Transform = Owner.GetComponent(); var systemman = IoCManager.Resolve(); - random = new Random(); } public bool AttackBy(AttackByEventArgs eventArgs) @@ -127,7 +129,7 @@ namespace Content.Server.GameObjects.Components.Construction case ToolType.Welder: if (slapped.TryGetComponent(out WelderComponent welder) && welder.TryUse(toolStep.Amount)) { - if (random.NextDouble() > 0.5) + if (_random.NextDouble() > 0.5) sound.Play("/Audio/items/welder.ogg", Transform.GridPosition); else sound.Play("/Audio/items/welder2.ogg", Transform.GridPosition); @@ -144,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Construction case ToolType.Screwdriver: if (slapped.HasComponent()) { - if (random.NextDouble() > 0.5) + if (_random.NextDouble() > 0.5) sound.Play("/Audio/items/screwdriver.ogg", Transform.GridPosition); else sound.Play("/Audio/items/screwdriver2.ogg", Transform.GridPosition); diff --git a/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs b/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs index 1f1a87d427..56c44178b8 100644 --- a/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs @@ -5,8 +5,10 @@ using Content.Server.Interfaces; using Content.Shared.GameObjects; 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.Random; using Robust.Shared.Serialization; namespace Content.Server.GameObjects.Components.Damage @@ -59,7 +61,7 @@ namespace Content.Server.GameObjects.Components.Damage public void OnExplosion(ExplosionEventArgs eventArgs) { - var prob = new Random(); + var prob = IoCManager.Resolve(); switch (eventArgs.Severity) { case ExplosionSeverity.Destruction: diff --git a/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs b/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs index d5efd91802..492d4deeb0 100644 --- a/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs @@ -5,8 +5,10 @@ using Content.Server.Interfaces; using Content.Shared.GameObjects; 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.Random; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -74,7 +76,7 @@ namespace Content.Server.GameObjects.Components.Destructible void IExAct.OnExplosion(ExplosionEventArgs eventArgs) { - var prob = new Random(); + var prob = IoCManager.Resolve(); switch (eventArgs.Severity) { case ExplosionSeverity.Destruction: @@ -84,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Destructible _actSystem.HandleDestruction(Owner, true); break; case ExplosionSeverity.Light: - if (RandomExtensions.Prob(prob, 40)) + if (prob.Prob(40)) _actSystem.HandleDestruction(Owner, true); break; } diff --git a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs index 656ccd4c5a..d1f6f0e1f3 100644 --- a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs +++ b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs @@ -10,10 +10,12 @@ using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.EntitySystemMessages; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; +using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Random; using Robust.Shared.Serialization; namespace Content.Server.GameObjects.Components.Explosive @@ -26,6 +28,7 @@ namespace Content.Server.GameObjects.Components.Explosive [Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IServerEntityManager _serverEntityManager; [Dependency] private readonly IEntitySystemManager _entitySystemManager; + [Dependency] private readonly IRobustRandom _robustRandom; #pragma warning restore 649 public override string Name => "Explosive"; @@ -96,7 +99,7 @@ namespace Content.Server.GameObjects.Components.Explosive mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager["space"].TileId)); if (distanceFromTile < HeavyImpactRange) { - if (new Random().Prob(80)) + if (_robustRandom.Prob(80)) { mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId)); } @@ -107,7 +110,7 @@ namespace Content.Server.GameObjects.Components.Explosive } if (distanceFromTile < LightImpactRange) { - if (new Random().Prob(50)) + if (_robustRandom.Prob(50)) { mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId)); } diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index 0f71bd3b92..833f06d54f 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Content.Server.GameObjects.EntitySystems; using Content.Shared.GameObjects; using Robust.Server.GameObjects.Components.Container; using Robust.Server.Interfaces.Player; @@ -19,6 +20,10 @@ namespace Content.Server.GameObjects [RegisterComponent] public class InventoryComponent : SharedInventoryComponent { +#pragma warning disable 649 + [Dependency] private readonly IEntitySystemManager _entitySystemManager; +#pragma warning restore 649 + [ViewVariables] private readonly Dictionary SlotContainers = new Dictionary(); @@ -223,27 +228,41 @@ namespace Content.Server.GameObjects /// private void HandleInventoryMessage(ClientInventoryMessage msg) { - if (msg.Updatetype == ClientInventoryUpdate.Equip) + switch (msg.Updatetype) { - var hands = Owner.GetComponent(); - var activehand = hands.GetActiveHand; - if (activehand != null && activehand.Owner.TryGetComponent(out ClothingComponent clothing)) + case ClientInventoryUpdate.Equip: { - hands.Drop(hands.ActiveIndex); - if (!Equip(msg.Inventoryslot, clothing)) + var hands = Owner.GetComponent(); + var activeHand = hands.GetActiveHand; + if (activeHand != null && activeHand.Owner.TryGetComponent(out ClothingComponent clothing)) { - hands.PutInHand(clothing); + hands.Drop(hands.ActiveIndex); + if (!Equip(msg.Inventoryslot, clothing)) + { + hands.PutInHand(clothing); + } } + break; } - } - else if (msg.Updatetype == ClientInventoryUpdate.Unequip) - { - var hands = Owner.GetComponent(); - var activehand = hands.GetActiveHand; - var itemcontainedinslot = GetSlotItem(msg.Inventoryslot); - if (activehand == null && itemcontainedinslot != null && Unequip(msg.Inventoryslot)) + case ClientInventoryUpdate.Use: { - hands.PutInHand(itemcontainedinslot); + var interactionSystem = _entitySystemManager.GetEntitySystem(); + var hands = Owner.GetComponent(); + var activeHand = hands.GetActiveHand; + var itemContainedInSlot = GetSlotItem(msg.Inventoryslot); + if (itemContainedInSlot != null) + { + if (activeHand != null) + { + interactionSystem.Interaction(Owner, activeHand.Owner, itemContainedInSlot.Owner, + new Robust.Shared.Map.GridCoordinates()); + } + else if (Unequip(msg.Inventoryslot)) + { + hands.PutInHand(itemContainedInSlot); + } + } + break; } } } diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs index 7b42e79451..d38b0efd48 100644 --- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs @@ -472,11 +472,18 @@ namespace Content.Server.GameObjects var playerEntity = session.AttachedEntity; var used = GetActiveHand?.Owner; - if (playerEntity == Owner && used != null && slot.ContainedEntity != null) - { + if (playerEntity == Owner && slot.ContainedEntity != null) + { var interactionSystem = _entitySystemManager.GetEntitySystem(); - interactionSystem.Interaction(Owner, used, slot.ContainedEntity, - GridCoordinates.Nullspace); + if (used != null) + { + interactionSystem.Interaction(Owner, used, slot.ContainedEntity, + GridCoordinates.Nullspace); + } + else + { + interactionSystem.Interaction(Owner, slot.ContainedEntity); + } } break; diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs index a7de418d8f..0168ad739a 100644 --- a/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs @@ -161,6 +161,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools message.AddText("Fuel: "); message.PushColor(Fuel < FuelCapacity / 4f ? Color.DarkOrange : Color.Orange); message.AddText($"{Math.Round(Fuel)}/{FuelCapacity}"); + message.AddText("."); message.Pop(); } } diff --git a/Content.Server/GameObjects/Components/Items/DiceComponent.cs b/Content.Server/GameObjects/Components/Items/DiceComponent.cs index ef9b10afb2..1dc5939f00 100644 --- a/Content.Server/GameObjects/Components/Items/DiceComponent.cs +++ b/Content.Server/GameObjects/Components/Items/DiceComponent.cs @@ -5,9 +5,11 @@ using Content.Shared.Audio; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.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.Utility; using Robust.Shared.ViewVariables; @@ -19,11 +21,11 @@ namespace Content.Server.GameObjects.Components.Items { #pragma warning disable 649 [Dependency] private readonly IPrototypeManager _prototypeManager; + [Dependency] private readonly IRobustRandom _random; #pragma warning restore 649 public override string Name => "Dice"; - private Random _random; private int _step = 1; private int _sides = 20; private int _currentSide = 20; @@ -45,12 +47,6 @@ namespace Content.Server.GameObjects.Components.Items _currentSide = _sides; } - public override void OnAdd() - { - base.OnAdd(); - _random = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); - } - public void Roll() { _currentSide = _random.Next(1, (_sides/_step)+1) * _step; diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs index d84e55d2f8..5fa5e0fa9c 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs @@ -2,8 +2,10 @@ using System; using Robust.Server.Interfaces.GameObjects; 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.Random; namespace Content.Server.GameObjects.Components.Items.Storage.Fill { @@ -19,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void IMapInit.MapInit() { var storage = Owner.GetComponent(); - var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode()); + var random = IoCManager.Resolve(); void Spawn(string prototype) { diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs index 95227b7141..3d42912ea0 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs @@ -2,8 +2,10 @@ using System; using Robust.Server.Interfaces.GameObjects; 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.Random; namespace Content.Server.GameObjects.Components.Items.Storage.Fill { @@ -19,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void IMapInit.MapInit() { var storage = Owner.GetComponent(); - var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode()); + var random = IoCManager.Resolve(); void Spawn(string prototype) { diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 5cf06c5508..695d2fff6c 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -7,7 +7,10 @@ using Robust.Server.GameObjects; using Robust.Server.Interfaces.GameObjects; 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.Random; using Robust.Shared.Serialization; namespace Content.Server.GameObjects @@ -20,6 +23,10 @@ namespace Content.Server.GameObjects public override uint? NetID => ContentNetIDs.ITEM; public override Type StateType => typeof(ItemComponentState); + #pragma warning disable 649 + [Dependency] private readonly IRobustRandom _robustRandom; + #pragma warning restore 649 + private string _equippedPrefix; public string EquippedPrefix @@ -115,7 +122,7 @@ namespace Content.Server.GameObjects float RandomOffset() { var size = 15.0F; - return (new Random().NextFloat() * size) - size / 2; + return (_robustRandom.NextFloat() * size) - size / 2; } } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index b50a8b9ff4..77fe298f07 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -34,7 +34,6 @@ namespace Content.Server.GameObjects [Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IPlayerManager _playerManager; [Dependency] private readonly IEntityManager _entityManager; - [Dependency] private readonly IEntitySystemManager _entitySystemManager; #pragma warning restore 649 private Container storage; diff --git a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs index fca5b45b79..7771bdf05c 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs @@ -8,6 +8,7 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; +using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -24,6 +25,7 @@ namespace Content.Server.GameObjects.Components.Movement #pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IServerEntityManager _serverEntityManager; + [Dependency] private readonly IRobustRandom _spreadRandom; #pragma warning restore 649 // TODO: Look at MapManager.Map for Beacons to get all entities on grid public ItemTeleporterState State => _state; @@ -44,8 +46,6 @@ namespace Content.Server.GameObjects.Components.Movement private AppearanceComponent _appearanceComponent; - private Random _spreadRandom; - public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); @@ -149,7 +149,6 @@ namespace Content.Server.GameObjects.Components.Movement public override void Initialize() { _appearanceComponent = Owner.GetComponent(); - _spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); _state = ItemTeleporterState.Off; base.Initialize(); } diff --git a/Content.Server/GameObjects/Components/Power/PowerDevice.cs b/Content.Server/GameObjects/Components/Power/PowerDevice.cs index f93930cc6c..33d0c5c054 100644 --- a/Content.Server/GameObjects/Components/Power/PowerDevice.cs +++ b/Content.Server/GameObjects/Components/Power/PowerDevice.cs @@ -182,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Power { if (!Powered) { - message.AddText("The device is not powered"); + message.AddText("The device is not powered."); } } diff --git a/Content.Server/GameObjects/Components/Sound/FootstepModifierComponent.cs b/Content.Server/GameObjects/Components/Sound/FootstepModifierComponent.cs index 1cf60c0bc5..eb68beb188 100644 --- a/Content.Server/GameObjects/Components/Sound/FootstepModifierComponent.cs +++ b/Content.Server/GameObjects/Components/Sound/FootstepModifierComponent.cs @@ -2,9 +2,11 @@ using Content.Shared.Audio; using Robust.Shared.Audio; using Robust.Shared.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; namespace Content.Server.GameObjects.Components.Sound @@ -17,10 +19,10 @@ namespace Content.Server.GameObjects.Components.Sound { #pragma warning disable 649 [Dependency] private readonly IPrototypeManager _prototypeManager; + [Dependency] private readonly IRobustRandom _footstepRandom; #pragma warning restore 649 /// /// - private Random _footstepRandom; public override string Name => "FootstepModifier"; @@ -32,12 +34,6 @@ namespace Content.Server.GameObjects.Components.Sound serializer.DataField(ref _soundCollectionName, "footstepSoundCollection", ""); } - public override void Initialize() - { - base.Initialize(); - _footstepRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); - } - public void PlayFootstep() { if (!string.IsNullOrWhiteSpace(_soundCollectionName)) diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs index 7b6dccfe06..4d6053a42b 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/BallisticMagazineWeaponComponent.cs @@ -10,7 +10,10 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.Audio; 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.Random; using Robust.Shared.Serialization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -34,8 +37,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile [ViewVariables] private IEntity Magazine => _magazineSlot.ContainedEntity; - [ViewVariables] - private Random _bulletDropRandom; +#pragma warning disable 649 + [Dependency] private readonly IRobustRandom _bulletDropRandom; +#pragma warning restore 649 [ViewVariables] private string _magInSound; [ViewVariables] @@ -74,7 +78,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile base.Initialize(); _appearance = Owner.GetComponent(); - _bulletDropRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); } public override void Startup() diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs index 9d86c27a94..7481342ead 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs @@ -8,10 +8,12 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; +using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Random; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -23,7 +25,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile private float _spreadStdDev = 3; private bool _spread = true; - private Random _spreadRandom; +#pragma warning disable 649 + [Dependency] private IRobustRandom _spreadRandom; +#pragma warning restore 649 [ViewVariables(VVAccess.ReadWrite)] public bool Spread @@ -45,8 +49,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile var rangedWeapon = Owner.GetComponent(); rangedWeapon.FireHandler = Fire; - - _spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode()); } public override void ExposeData(ObjectSerializer serializer) diff --git a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs index c3b6dd967a..7b0cfd0696 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs @@ -62,20 +62,19 @@ namespace Content.Server.GameObjects.EntitySystems message.PushColor(Color.DarkGray); - var subMessage = new FormattedMessage(); //Add component statuses from components that report one foreach (var examineComponents in entity.GetAllComponents()) { + var subMessage = new FormattedMessage(); examineComponents.Examine(subMessage); if (subMessage.Tags.Count == 0) continue; if (doNewline) - { message.AddText("\n"); - doNewline = false; - } + message.AddMessage(subMessage); + doNewline = true; } message.Pop(); diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 3f851589dc..0c98ead8f5 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -200,7 +200,7 @@ namespace Content.Server.GameObjects.EntitySystems public override void Initialize() { var inputSys = EntitySystemManager.GetEntitySystem(); - inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand, + inputSys.BindMap.BindFunction(EngineKeyFunctions.Use, new PointerInputCmdHandler(HandleUseItemInHand)); inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld, new PointerInputCmdHandler(HandleActivateItemInWorld)); diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index ef0faabec0..7febdefc70 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -23,7 +23,9 @@ using Robust.Shared.Players; using Robust.Shared.Prototypes; using Content.Server.GameObjects.Components.Sound; using Content.Shared.GameObjects.Components.Inventory; +using Robust.Shared.Interfaces.Random; using Robust.Shared.Log; +using Robust.Shared.Random; namespace Content.Server.GameObjects.EntitySystems { @@ -35,10 +37,10 @@ namespace Content.Server.GameObjects.EntitySystems [Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager; [Dependency] private readonly IMapManager _mapManager; + [Dependency] private readonly IRobustRandom _robustRandom; #pragma warning restore 649 private AudioSystem _audioSystem; - private Random _footstepRandom; private const float StepSoundMoveDistanceRunning = 2; private const float StepSoundMoveDistanceWalking = 1.5f; @@ -47,7 +49,7 @@ namespace Content.Server.GameObjects.EntitySystems public override void Initialize() { EntityQuery = new TypeEntityQuery(typeof(IMoverComponent)); - + var moveUpCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.North, true), session => HandleDirChange(session, Direction.North, false)); @@ -75,7 +77,6 @@ namespace Content.Server.GameObjects.EntitySystems SubscribeEvent(PlayerAttached); SubscribeEvent(PlayerDetached); - _footstepRandom = new Random(); _audioSystem = EntitySystemManager.GetEntitySystem(); } @@ -153,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems { mover.StepSoundDistance = 0; if (mover.Owner.TryGetComponent(out var inventory) - && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.SHOES, out var item) + && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.SHOES, out var item) && item.Owner.TryGetComponent(out var modifier)) { modifier.PlayFootstep(); @@ -186,7 +187,7 @@ namespace Content.Server.GameObjects.EntitySystems where T: Component { component = default; - + var ent = session.AttachedEntity; if (ent == null || !ent.IsValid()) @@ -238,7 +239,7 @@ namespace Content.Server.GameObjects.EntitySystems try { var soundCollection = _prototypeManager.Index(soundCollectionName); - var file = _footstepRandom.Pick(soundCollection.PickFiles); + var file = _robustRandom.Pick(soundCollection.PickFiles); _audioSystem.Play(file, coordinates); } catch (UnknownPrototypeException) diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index d9b019129d..76726b6ceb 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -21,12 +21,14 @@ using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Network; +using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Network; +using Robust.Shared.Random; using Robust.Shared.Timers; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -76,8 +78,6 @@ namespace Content.Server.GameTicking [ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers; private DateTime _roundStartTimeUtc; - private readonly Random _spawnRandom = new Random(); - [ViewVariables] private readonly List _gameRules = new List(); [ViewVariables] private Type _presetType; @@ -92,6 +92,7 @@ namespace Content.Server.GameTicking [Dependency] private IChatManager _chatManager; [Dependency] private IServerNetManager _netManager; [Dependency] private IDynamicTypeFactory _dynamicTypeFactory; + [Dependency] private readonly IRobustRandom _robustRandom; #pragma warning restore 649 public void Initialize() @@ -293,7 +294,7 @@ namespace Content.Server.GameTicking if (possiblePoints.Count != 0) { - location = _spawnRandom.Pick(possiblePoints); + location = _robustRandom.Pick(possiblePoints); } return location; diff --git a/Content.Shared/GameObjects/Components/Inventory/SharedInventoryComponent.cs b/Content.Shared/GameObjects/Components/Inventory/SharedInventoryComponent.cs index 6464f2fbe8..7dfb88f4d4 100644 --- a/Content.Shared/GameObjects/Components/Inventory/SharedInventoryComponent.cs +++ b/Content.Shared/GameObjects/Components/Inventory/SharedInventoryComponent.cs @@ -75,7 +75,7 @@ namespace Content.Shared.GameObjects public enum ClientInventoryUpdate { Equip = 0, - Unequip = 1 + Use = 1 } } diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs index 2b63091d36..501e433c97 100644 --- a/Content.Shared/Input/ContentKeyFunctions.cs +++ b/Content.Shared/Input/ContentKeyFunctions.cs @@ -18,6 +18,6 @@ namespace Content.Shared.Input public static readonly BoundKeyFunction SwapHands = "SwapHands"; public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand"; public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode"; - public static readonly BoundKeyFunction UseItemInHand = "UseItemInHand"; // use hand item on world entity + public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle"; } } diff --git a/Resources/Prototypes/Entities/items/clothing/belts.yml b/Resources/Prototypes/Entities/items/clothing/belts.yml index 84cb15b8a0..b023279c80 100644 --- a/Resources/Prototypes/Entities/items/clothing/belts.yml +++ b/Resources/Prototypes/Entities/items/clothing/belts.yml @@ -24,5 +24,3 @@ sprite: Clothing/belt_utility.rsi - type: Storage Capacity: 30 - - diff --git a/Resources/Prototypes/Entities/items/clothing/gloves.yml b/Resources/Prototypes/Entities/items/clothing/gloves.yml index af0b3af5a7..a47c382c76 100644 --- a/Resources/Prototypes/Entities/items/clothing/gloves.yml +++ b/Resources/Prototypes/Entities/items/clothing/gloves.yml @@ -53,19 +53,4 @@ state: leather - type: Clothing sprite: Clothing/gloves_leather.rsi - HeatResistance: 1500 - -- type: entity - parent: GlovesBase - id: WhiteGloves - name: White Gloves - description: These look pretty fancy. - components: - - type: Sprite - sprite: Clothing/gloves_white.rsi - state: white - - type: Icon - sprite: Clothing/gloves_white.rsi - state: white - - type: Clothing - sprite: Clothing/gloves_white.rsi \ No newline at end of file + HeatResistance: 1500 \ No newline at end of file diff --git a/Resources/Prototypes/Entities/items/clothing/hats.yml b/Resources/Prototypes/Entities/items/clothing/hats.yml index 423ed9fde7..26aaed52c0 100644 --- a/Resources/Prototypes/Entities/items/clothing/hats.yml +++ b/Resources/Prototypes/Entities/items/clothing/hats.yml @@ -40,37 +40,3 @@ sprite: Clothing/captain_hat.rsi Slots: - helmet - -- type: entity - parent: HatBase - id: HatHOP - name: Head of Personnel's Hat - description: Papers, please. - components: - - type: Sprite - sprite: Clothing/hop_hat.rsi - state: hop - - type: Icon - sprite: Clothing/hop_hat.rsi - state: hop - - type: Clothing - sprite: Clothing/hop_hat.rsi - Slots: - - helmet - -- type: entity - parent: HatBase - id: HatBeret - name: Beret - description: A beret, an artists favorite headwear. - components: - - type: Sprite - sprite: Clothing/beret.rsi - state: beret - - type: Icon - sprite: Clothing/beret.rsi - state: beret - - type: Clothing - sprite: Clothing/beret.rsi - Slots: - - helmet diff --git a/Resources/Prototypes/Entities/items/clothing/masks.yml b/Resources/Prototypes/Entities/items/clothing/masks.yml index 37ed00bff3..9a0c7d2388 100644 --- a/Resources/Prototypes/Entities/items/clothing/masks.yml +++ b/Resources/Prototypes/Entities/items/clothing/masks.yml @@ -47,19 +47,4 @@ sprite: Clothing/mask_clown.rsi state: icon - type: Clothing - sprite: Clothing/mask_clown.rsi - -- type: entity - parent: MasksBase - id: MaskMime - name: Mime Mask - description: The traditional mime's mask. It has an eerie facial posture. - components: - - type: Sprite - sprite: Clothing/mask_mime.rsi - state: mime - - type: Icon - sprite: Clothing/mask_mime.rsi - state: mime - - type: Clothing - sprite: Clothing/mask_mime.rsi \ No newline at end of file + sprite: Clothing/mask_clown.rsi \ No newline at end of file diff --git a/Resources/Prototypes/Entities/items/clothing/shoes.yml b/Resources/Prototypes/Entities/items/clothing/shoes.yml index a046c1d5c8..1d7d2a03be 100644 --- a/Resources/Prototypes/Entities/items/clothing/shoes.yml +++ b/Resources/Prototypes/Entities/items/clothing/shoes.yml @@ -100,21 +100,4 @@ state: brown - type: Clothing - sprite: Clothing/shoes_brown.rsi - -- type: entity - parent: ShoesBase - id: ShoesMime - name: Mime Shoes - description: Comfortable-looking shoes. - components: - - type: Sprite - sprite: Clothing/shoes_mime.rsi - state: mime - - - type: Icon - sprite: Clothing/shoes_mime.rsi - state: mime - - - type: Clothing - sprite: Clothing/shoes_mime.rsi \ No newline at end of file + sprite: Clothing/shoes_brown.rsi \ No newline at end of file diff --git a/Resources/Prototypes/Entities/items/clothing/suits.yml b/Resources/Prototypes/Entities/items/clothing/suits.yml index 991628dcfd..fa6132001a 100644 --- a/Resources/Prototypes/Entities/items/clothing/suits.yml +++ b/Resources/Prototypes/Entities/items/clothing/suits.yml @@ -58,18 +58,3 @@ - type: Clothing sprite: Clothing/chef_apron.rsi - -- type: entity - parent: SuitBase - id: BeltSuspenders - name: Suspenders - description: They suspend the illusion of the mime's play. - components: - - type: Sprite - sprite: Clothing/suspenders.rsi - state: suspenders - - type: Icon - sprite: Clothing/suspenders.rsi - state: suspenders - - type: Clothing - sprite: Clothing/suspenders.rsi \ No newline at end of file diff --git a/Resources/Prototypes/Entities/items/clothing/uniforms.yml b/Resources/Prototypes/Entities/items/clothing/uniforms.yml index d5986f3ef1..fa65553d34 100644 --- a/Resources/Prototypes/Entities/items/clothing/uniforms.yml +++ b/Resources/Prototypes/Entities/items/clothing/uniforms.yml @@ -141,38 +141,4 @@ state: captain - type: Clothing - sprite: Clothing/captain_uniform.rsi - -- type: entity - parent: UniformBase - id: UniformHOP - name: Head of Personnel's Jumpsuit - description: It's a jumpsuit worn by someone who works in the position of "Head of Personnel". - components: - - type: Sprite - sprite: Clothing/hop_jumpsuit.rsi - state: hop - - - type: Icon - sprite: Clothing/hop_jumpsuit.rsi - state: hop - - - type: Clothing - sprite: Clothing/hop_jumpsuit.rsi - -- type: entity - parent: UniformBase - id: UniformMime - name: Mime's Outfit - description: It's not very colourful. - components: - - type: Sprite - sprite: Clothing/mime_outfit.rsi - state: mime - - - type: Icon - sprite: Clothing/mime_outfit.rsi - state: mime - - - type: Clothing - sprite: Clothing/mime_outfit.rsi \ No newline at end of file + sprite: Clothing/captain_uniform.rsi diff --git a/Resources/Textures/Clothing/beret.rsi/beret.png b/Resources/Textures/Clothing/beret.rsi/beret.png deleted file mode 100644 index feac165f6d..0000000000 Binary files a/Resources/Textures/Clothing/beret.rsi/beret.png and /dev/null differ diff --git a/Resources/Textures/Clothing/beret.rsi/equipped-HELMET.png b/Resources/Textures/Clothing/beret.rsi/equipped-HELMET.png deleted file mode 100644 index 2918a7d0b3..0000000000 Binary files a/Resources/Textures/Clothing/beret.rsi/equipped-HELMET.png and /dev/null differ diff --git a/Resources/Textures/Clothing/beret.rsi/meta.json b/Resources/Textures/Clothing/beret.rsi/meta.json deleted file mode 100644 index 831fc7e571..0000000000 --- a/Resources/Textures/Clothing/beret.rsi/meta.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": 1, - "size": { - "x": 32, - "y": 32 - }, - "license": "CC-BY-SA-3.0", - "copyright": "Taken from https://github.com/vgstation-coders/vgstation13/tree/Bleeding-Edge/icons", - "states": [ - { - "name": "equipped-HELMET", - "directions": 4, - "delays": [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - }, - { - "name": "beret", - "directions": 1, - "delays": [ [ 1.0 ] ] - } - ] -} diff --git a/Resources/Textures/Clothing/gloves_white.rsi/equipped-HAND.png b/Resources/Textures/Clothing/gloves_white.rsi/equipped-HAND.png deleted file mode 100644 index db6ccef964..0000000000 Binary files a/Resources/Textures/Clothing/gloves_white.rsi/equipped-HAND.png and /dev/null differ diff --git a/Resources/Textures/Clothing/gloves_white.rsi/meta.json b/Resources/Textures/Clothing/gloves_white.rsi/meta.json deleted file mode 100644 index 2a3252cfc8..0000000000 --- a/Resources/Textures/Clothing/gloves_white.rsi/meta.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": 1, - "size": { - "x": 32, - "y": 32 - }, - "license": "CC-BY-SA-3.0", - "copyright": "Taken from https://github.com/discordia-space/CEV-Eris at commit 9a3a3a180344460263e8df7ea2565128e07b86b5", - "states": [ - { - "name": "white", - "directions": 1, - "delays": [ [ 1.0 ] ] - }, - { - "name": "equipped-HAND", - "directions": 4, - "delays": [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - } - ] -} diff --git a/Resources/Textures/Clothing/gloves_white.rsi/white.png b/Resources/Textures/Clothing/gloves_white.rsi/white.png deleted file mode 100644 index 4732b24b5b..0000000000 Binary files a/Resources/Textures/Clothing/gloves_white.rsi/white.png and /dev/null differ diff --git a/Resources/Textures/Clothing/hop_coat.rsi/equipped-OUTER.png b/Resources/Textures/Clothing/hop_coat.rsi/equipped-OUTER.png deleted file mode 100644 index 823f77efb1..0000000000 Binary files a/Resources/Textures/Clothing/hop_coat.rsi/equipped-OUTER.png and /dev/null differ diff --git a/Resources/Textures/Clothing/hop_hat.rsi/equipped-HELMET.png b/Resources/Textures/Clothing/hop_hat.rsi/equipped-HELMET.png deleted file mode 100644 index 866e91981a..0000000000 Binary files a/Resources/Textures/Clothing/hop_hat.rsi/equipped-HELMET.png and /dev/null differ diff --git a/Resources/Textures/Clothing/hop_hat.rsi/hop.png b/Resources/Textures/Clothing/hop_hat.rsi/hop.png deleted file mode 100644 index 55e5a58f11..0000000000 Binary files a/Resources/Textures/Clothing/hop_hat.rsi/hop.png and /dev/null differ diff --git a/Resources/Textures/Clothing/hop_hat.rsi/meta.json b/Resources/Textures/Clothing/hop_hat.rsi/meta.json deleted file mode 100644 index 8eb2d55846..0000000000 --- a/Resources/Textures/Clothing/hop_hat.rsi/meta.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": 1, - "size": { - "x": 32, - "y": 32 - }, - "license": "CC-BY-SA-3.0", - "copyright": "Taken from https://github.com/vgstation-coders/vgstation13/tree/Bleeding-Edge/icons", - "states": [ - { - "name": "equipped-HELMET", - "directions": 4, - "delays": [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - }, - { - "name": "hop", - "directions": 1, - "delays": [ [ 1.0 ] ] - } - ] -} diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index d21fbb314c..a7b5a94466 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -1,78 +1,86 @@ version: 1 # Not used right now, whatever. binds: +- function: Use + type: state + key: MouseLeft + canFocus: true - function: ShowDebugMonitors + type: Toggle key: F3 - type: Toggle - function: HideUI - key: F4 type: Toggle + key: F4 - function: MoveUp + type: State key: W - type: State - function: MoveLeft + type: State key: A - type: State - function: MoveRight + type: State key: D - type: State - function: MoveDown + type: State key: S - type: State - function: Run + type: State key: Shift - type: State - function: ShowEscapeMenu + type: State key: Escape - type: State - function: FocusChatWindow + type: State key: T - type: State - function: EditorLinePlace - key: MouseLeft - mod1: Shift type: State + key: MouseLeft + canFocus: true + mod1: Shift - function: EditorGridPlace - key: MouseLeft - mod1: Control type: State + key: MouseLeft + canFocus: true + mod1: Control - function: EditorPlaceObject - key: MouseLeft type: State + key: MouseLeft + canFocus: true - function: EditorCancelPlace - key: MouseRight type: State + key: MouseRight + canFocus: true - function: EditorRotateObject + type: State key: MouseMiddle - type: State - function: SwapHands + type: State key: X - type: State - function: Drop + type: State key: Q - type: State - function: ActivateItemInHand + type: State key: Z - type: State - function: OpenCharacterMenu + type: State key: C - type: State - function: ExamineEntity - key: MouseLeft - mod1: Shift type: State -- function: UseItemInHand key: MouseLeft - type: state + canFocus: true + mod1: Shift - function: ActivateItemInWorld + type: state key: E - type: state - function: ThrowItemInHand + type: state key: MouseLeft + canFocus: true mod1: Control - type: state - function: OpenContextMenu - key: MouseRight type: state + key: MouseRight + canFocus: true - function: ToggleCombatMode type: Toggle key: Tab @@ -85,3 +93,41 @@ binds: - function: OpenInventoryMenu type: state key: I +- function: ShowDebugConsole + type: state + key: Tilde +- function: MouseMiddle + type: state + key: MouseMiddle + canFocus: true +- function: TextCursorLeft + type: state + key: Left +- function: TextCursorRight + type: state + key: Right +- function: TextBackspace + type: state + key: BackSpace +- function: TextSubmit + type: state + key: Return +- function: TextSubmit + type: state + key: NumpadEnter +- function: TextPaste + type: state + key: V + mod1: Control +- function: TextHistoryPrev + type: state + key: Up +- function: TextHistoryNext + type: state + key: Down +- function: TextReleaseFocus + type: state + key: Escape +- function: TextScrollToBottom + type: state + key: PageDown \ No newline at end of file diff --git a/RobustToolbox b/RobustToolbox index cb5f2ffae1..a8d6c294ab 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit cb5f2ffae1994e0a3f0f6be5697896ab7eaafe50 +Subproject commit a8d6c294abca40b47dcf3da45359130b9151252a