Merge branches 'pseudo-classes', 'input-refactor' and '19-08-21-update-submodule'

This commit is contained in:
Pieter-Jan Briers
2019-08-21 17:25:01 +02:00
57 changed files with 301 additions and 374 deletions

View File

@@ -1,2 +1,5 @@
INSTALLED_HOOKS_VERSION INSTALLED_HOOKS_VERSION
DISABLE_SUBMODULE_AUTOUPDATE DISABLE_SUBMODULE_AUTOUPDATE
*.nuget*
project.assets.json
project.packagespec.json

View File

@@ -5,7 +5,10 @@ using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
#endif #endif
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using SysVector4 = System.Numerics.Vector4; using SysVector4 = System.Numerics.Vector4;
namespace Content.Benchmarks namespace Content.Benchmarks

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Input;
namespace Content.Client.Chat namespace Content.Client.Chat
{ {
@@ -82,7 +83,7 @@ namespace Content.Client.Chat
vBox.AddChild(contentMargin); vBox.AddChild(contentMargin);
Input = new LineEdit(); Input = new LineEdit();
Input.OnKeyDown += InputKeyDown; Input.OnKeyBindDown += InputKeyBindDown;
Input.OnTextEntered += Input_OnTextEntered; Input.OnTextEntered += Input_OnTextEntered;
vBox.AddChild(Input); vBox.AddChild(Input);
@@ -119,23 +120,27 @@ namespace Content.Client.Chat
AddChild(outerVBox); 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(); 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(); Input.ReleaseKeyboardFocus();
e.Handle(); args.Handle();
return; return;
} }
else if (args.Function == EngineKeyFunctions.TextHistoryPrev)
if (e.Key == Keyboard.Key.Up)
{ {
if (_inputIndex == -1 && _inputHistory.Count != 0) if (_inputIndex == -1 && _inputHistory.Count != 0)
{ {
@@ -151,12 +156,12 @@ namespace Content.Client.Chat
{ {
Input.Text = _inputHistory[_inputIndex]; Input.Text = _inputHistory[_inputIndex];
} }
Input.CursorPos = Input.Text.Length;
e.Handle(); args.Handle();
return; return;
} }
else if (args.Function == EngineKeyFunctions.TextHistoryNext)
if (e.Key == Keyboard.Key.Down)
{ {
if (_inputIndex == 0) if (_inputIndex == 0)
{ {
@@ -169,8 +174,9 @@ namespace Content.Client.Chat
_inputIndex--; _inputIndex--;
Input.Text = _inputHistory[_inputIndex]; Input.Text = _inputHistory[_inputIndex];
} }
Input.CursorPos = Input.Text.Length;
e.Handle(); args.Handle();
} }
} }

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.Placement; using Robust.Client.Interfaces.Placement;
@@ -49,9 +49,8 @@ namespace Content.Client
_escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false; _escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false;
var escapeMenuCommand = InputCmdHandler.FromDelegate(Enabled); _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu,
InputCmdHandler.FromDelegate(s => Enabled()));
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand);
} }
else if (obj.OldState is GameScreen) else if (obj.OldState is GameScreen)
{ {
@@ -63,7 +62,7 @@ namespace Content.Client
} }
} }
private void Enabled(ICommonSession session) private void Enabled()
{ {
if (_escapeMenu.IsOpen) if (_escapeMenu.IsOpen)
{ {

View File

@@ -127,18 +127,18 @@ namespace Content.Client.GameObjects
_sprite?.LayerSetVisible(slot, false); _sprite?.LayerSetVisible(slot, false);
} }
public void SendUnequipMessage(Slots slot)
{
var unequipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Unequip);
SendNetworkMessage(unequipmessage);
}
public void SendEquipMessage(Slots slot) public void SendEquipMessage(Slots slot)
{ {
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip); var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Equip);
SendNetworkMessage(equipmessage); SendNetworkMessage(equipmessage);
} }
public void SendUseMessage(Slots slot)
{
var equipmessage = new ClientInventoryMessage(slot, ClientInventoryUpdate.Use);
SendNetworkMessage(equipmessage);
}
public void SendOpenStorageUIMessage(Slots slot) public void SendOpenStorageUIMessage(Slots slot)
{ {
SendNetworkMessage(new OpenSlotStorageUIMessage(slot)); SendNetworkMessage(new OpenSlotStorageUIMessage(slot));

View File

@@ -43,7 +43,7 @@ namespace Content.Client.GameObjects
base.Initialize(); base.Initialize();
_window = new HumanInventoryWindow(_loc, _resourceCache); _window = new HumanInventoryWindow(_loc, _resourceCache);
_window.OnClose += () => GameHud.InventoryButtonDown = false;
foreach (var (slot, button) in _window.Buttons) foreach (var (slot, button) in _window.Buttons)
{ {
button.OnPressed = AddToInventory; button.OnPressed = AddToInventory;
@@ -97,7 +97,7 @@ namespace Content.Client.GameObjects
foreach (var button in buttons) foreach (var button in buttons)
{ {
button.SpriteView.Sprite = sprite; button.SpriteView.Sprite = sprite;
button.OnPressed = RemoveFromInventory; button.OnPressed = HandleInventoryKeybind;
button.StorageButton.Visible = hasInventory; button.StorageButton.Visible = hasInventory;
} }
} }

View File

@@ -27,7 +27,8 @@ namespace Content.Client.GameObjects
AddChild(Button = new TextureButton AddChild(Button = new TextureButton
{ {
TextureNormal = texture, TextureNormal = texture,
Scale = (2, 2) Scale = (2, 2),
EnableAllKeybinds = true
}); });
Button.OnPressed += e => OnPressed?.Invoke(e); Button.OnPressed += e => OnPressed?.Invoke(e);
@@ -44,7 +45,8 @@ namespace Content.Client.GameObjects
Scale = (0.75f, 0.75f), Scale = (0.75f, 0.75f),
SizeFlagsHorizontal = SizeFlags.ShrinkEnd, SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
SizeFlagsVertical = SizeFlags.ShrinkEnd, SizeFlagsVertical = SizeFlags.ShrinkEnd,
Visible = false Visible = false,
EnableAllKeybinds = true
}); });
StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e); StorageButton.OnPressed += e => OnStoragePressed?.Invoke(e);

View File

@@ -1,6 +1,7 @@
using System; using System;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Input;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Interfaces.GameObjects; 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; if (args.Event.Function == ContentKeyFunctions.ActivateItemInWorld)
var control = (InventoryButton) args.Button.Parent; {
OpenStorage(args);
Owner.SendUnequipMessage(control.Slot); }
else if (args.Event.CanFocus)
{
UseItemOnInventory(args);
}
} }
protected void AddToInventory(BaseButton.ButtonEventArgs args) protected void AddToInventory(BaseButton.ButtonEventArgs args)
{ {
if (!args.Event.CanFocus)
{
return;
}
args.Button.Pressed = false; args.Button.Pressed = false;
var control = (InventoryButton) args.Button.Parent; var control = (InventoryButton) args.Button.Parent;
Owner.SendEquipMessage(control.Slot); 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) protected void OpenStorage(BaseButton.ButtonEventArgs args)
{ {
if (!args.Event.CanFocus && args.Event.Function != ContentKeyFunctions.ActivateItemInWorld)
{
return;
}
args.Button.Pressed = false; args.Button.Pressed = false;
var control = (InventoryButton)args.Button.Parent; var control = (InventoryButton)args.Button.Parent;

View File

@@ -5,6 +5,7 @@ using Robust.Client.GameObjects.EntitySystems;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Timers; using Robust.Shared.Timers;
@@ -16,7 +17,9 @@ namespace Content.Client.GameObjects.Components.Sound
{ {
private readonly List<ScheduledSound> _schedules = new List<ScheduledSound>(); private readonly List<ScheduledSound> _schedules = new List<ScheduledSound>();
private AudioSystem _audioSystem; private AudioSystem _audioSystem;
private Random Random; #pragma warning disable 649
[Dependency] private readonly IRobustRandom _random;
#pragma warning restore 649
public override void StopAllSounds() public override void StopAllSounds()
{ {
@@ -46,9 +49,8 @@ namespace Content.Client.GameObjects.Components.Sound
public void Play(ScheduledSound schedule) public void Play(ScheduledSound schedule)
{ {
if (!schedule.Play) return; 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 (!schedule.Play) return; // We make sure this hasn't changed.
if (_audioSystem == null) _audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>(); if (_audioSystem == null) _audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();

View File

@@ -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.Client.Interfaces.GameObjects;
using Content.Shared.Input; using Content.Shared.Input;
using Robust.Client.GameObjects.EntitySystems; using Robust.Client.GameObjects.EntitySystems;
@@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.EntitySystems
base.Update(frameTime); base.Update(frameTime);
var canFireSemi = _isFirstShot; var canFireSemi = _isFirstShot;
var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.UseItemInHand); var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use);
if (state != BoundKeyState.Down) if (state != BoundKeyState.Down)
{ {
_isFirstShot = true; _isFirstShot = true;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using Content.Client.Chat; using Content.Client.Chat;
using Content.Client.Interfaces; using Content.Client.Interfaces;
@@ -18,6 +18,7 @@ using Robust.Shared.Input;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -188,11 +189,7 @@ namespace Content.Client.GameTicking
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName; _lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(session => InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat)));
{
_lobby.Chat.Input.IgnoreNext = true;
_lobby.Chat.Input.GrabKeyboardFocus();
}));
_updateLobbyUi(); _updateLobbyUi();
@@ -237,19 +234,25 @@ namespace Content.Client.GameTicking
_lobby = null; _lobby = null;
} }
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(session =>
{
_gameChat.Input.IgnoreNext = true;
_gameChat.Input.GrabKeyboardFocus();
}));
_gameChat = new ChatBox(); _gameChat = new ChatBox();
_userInterfaceManager.StateRoot.AddChild(_gameChat); _userInterfaceManager.StateRoot.AddChild(_gameChat);
_userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl); _userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
_chatManager.SetChatBox(_gameChat); _chatManager.SetChatBox(_gameChat);
_gameChat.DefaultChatFormat = "say \"{0}\""; _gameChat.DefaultChatFormat = "say \"{0}\"";
_gameChat.Input.PlaceHolder = _localization.GetString("Say something! [ for OOC"); _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 private enum TickerState

View File

@@ -21,12 +21,12 @@ namespace Content.Client.Input
human.AddFunction(ContentKeyFunctions.Drop); human.AddFunction(ContentKeyFunctions.Drop);
human.AddFunction(ContentKeyFunctions.ActivateItemInHand); human.AddFunction(ContentKeyFunctions.ActivateItemInHand);
human.AddFunction(ContentKeyFunctions.OpenCharacterMenu); human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
human.AddFunction(ContentKeyFunctions.UseItemInHand);
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld); human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
human.AddFunction(ContentKeyFunctions.ThrowItemInHand); human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
human.AddFunction(ContentKeyFunctions.OpenContextMenu); human.AddFunction(ContentKeyFunctions.OpenContextMenu);
human.AddFunction(ContentKeyFunctions.OpenCraftingMenu); human.AddFunction(ContentKeyFunctions.OpenCraftingMenu);
human.AddFunction(ContentKeyFunctions.OpenInventoryMenu); human.AddFunction(ContentKeyFunctions.OpenInventoryMenu);
human.AddFunction(ContentKeyFunctions.MouseMiddle);
// Disabled until there is feedback, so hitting tab doesn't suddenly break interaction. // Disabled until there is feedback, so hitting tab doesn't suddenly break interaction.
// human.AddFunction(ContentKeyFunctions.ToggleCombatMode); // human.AddFunction(ContentKeyFunctions.ToggleCombatMode);

View File

@@ -10,6 +10,7 @@ using Robust.Client.Utility;
using Robust.Shared.Interfaces.Log; using Robust.Shared.Interfaces.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Noise; using Robust.Shared.Noise;
using Robust.Shared.Random;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using BlendFactor = Robust.Shared.Maths.Color.BlendFactor; using BlendFactor = Robust.Shared.Maths.Color.BlendFactor;

View File

@@ -10,6 +10,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timers; using Robust.Shared.Timers;
using Robust.Shared.Utility;
namespace Content.Client.Research namespace Content.Client.Research
{ {

View File

@@ -2,6 +2,7 @@
using Content.Client.GameObjects.EntitySystems; using Content.Client.GameObjects.EntitySystems;
using Content.Client.Interfaces.GameObjects; using Content.Client.Interfaces.GameObjects;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.Input;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Input; using Robust.Client.Input;
using Robust.Client.Interfaces.GameObjects.Components; using Robust.Client.Interfaces.GameObjects.Components;
@@ -9,6 +10,7 @@ using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -199,12 +201,17 @@ namespace Content.Client.UserInterface
return _handL.Contains((Vector2i) point) || _handR.Contains((Vector2i) point); 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); if (!args.CanFocus)
var rightHandContains = _handR.Contains((Vector2i) args.RelativePosition); {
return;
}
var leftHandContains = _handL.Contains((Vector2i)args.RelativePosition);
var rightHandContains = _handR.Contains((Vector2i)args.RelativePosition);
string handIndex; string handIndex;
if (leftHandContains) if (leftHandContains)
@@ -220,7 +227,7 @@ namespace Content.Client.UserInterface
return; return;
} }
if (args.Button == Mouse.Button.Left) if (args.Function == EngineKeyFunctions.Use)
{ {
if (!TryGetHands(out var hands)) if (!TryGetHands(out var hands))
return; return;
@@ -236,12 +243,12 @@ namespace Content.Client.UserInterface
} }
} }
else if (args.Button == Mouse.Button.Middle) else if (args.Function == ContentKeyFunctions.MouseMiddle)
{ {
SendSwitchHandTo(handIndex); SendSwitchHandTo(handIndex);
} }
else if (args.Button == Mouse.Button.Right) else if (args.Function == ContentKeyFunctions.OpenContextMenu)
{ {
if (!TryGetHands(out var hands)) if (!TryGetHands(out var hands))
{ {
@@ -255,7 +262,7 @@ namespace Content.Client.UserInterface
} }
var esm = IoCManager.Resolve<IEntitySystemManager>(); var esm = IoCManager.Resolve<IEntitySystemManager>();
esm.GetEntitySystem<VerbSystem>().OpenContextMenu(entity, new ScreenCoordinates(args.GlobalPosition)); esm.GetEntitySystem<VerbSystem>().OpenContextMenu(entity, new ScreenCoordinates(args.PointerLocation.Position));
} }
} }
} }

View File

@@ -10,6 +10,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Construction.ConstructionStepMaterial; using static Content.Shared.Construction.ConstructionStepMaterial;
@@ -29,7 +30,9 @@ namespace Content.Server.GameObjects.Components.Construction
SpriteComponent Sprite; SpriteComponent Sprite;
ITransformComponent Transform; ITransformComponent Transform;
Random random; #pragma warning disable 649
[Dependency] private IRobustRandom _random;
#pragma warning restore 649
public override void Initialize() public override void Initialize()
{ {
@@ -38,7 +41,6 @@ namespace Content.Server.GameObjects.Components.Construction
Sprite = Owner.GetComponent<SpriteComponent>(); Sprite = Owner.GetComponent<SpriteComponent>();
Transform = Owner.GetComponent<ITransformComponent>(); Transform = Owner.GetComponent<ITransformComponent>();
var systemman = IoCManager.Resolve<IEntitySystemManager>(); var systemman = IoCManager.Resolve<IEntitySystemManager>();
random = new Random();
} }
public bool AttackBy(AttackByEventArgs eventArgs) public bool AttackBy(AttackByEventArgs eventArgs)
@@ -127,7 +129,7 @@ namespace Content.Server.GameObjects.Components.Construction
case ToolType.Welder: case ToolType.Welder:
if (slapped.TryGetComponent(out WelderComponent welder) && welder.TryUse(toolStep.Amount)) 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); sound.Play("/Audio/items/welder.ogg", Transform.GridPosition);
else else
sound.Play("/Audio/items/welder2.ogg", Transform.GridPosition); sound.Play("/Audio/items/welder2.ogg", Transform.GridPosition);
@@ -144,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Construction
case ToolType.Screwdriver: case ToolType.Screwdriver:
if (slapped.HasComponent<ScrewdriverComponent>()) if (slapped.HasComponent<ScrewdriverComponent>())
{ {
if (random.NextDouble() > 0.5) if (_random.NextDouble() > 0.5)
sound.Play("/Audio/items/screwdriver.ogg", Transform.GridPosition); sound.Play("/Audio/items/screwdriver.ogg", Transform.GridPosition);
else else
sound.Play("/Audio/items/screwdriver2.ogg", Transform.GridPosition); sound.Play("/Audio/items/screwdriver2.ogg", Transform.GridPosition);

View File

@@ -5,8 +5,10 @@ using Content.Server.Interfaces;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Damage namespace Content.Server.GameObjects.Components.Damage
@@ -59,7 +61,7 @@ namespace Content.Server.GameObjects.Components.Damage
public void OnExplosion(ExplosionEventArgs eventArgs) public void OnExplosion(ExplosionEventArgs eventArgs)
{ {
var prob = new Random(); var prob = IoCManager.Resolve<IRobustRandom>();
switch (eventArgs.Severity) switch (eventArgs.Severity)
{ {
case ExplosionSeverity.Destruction: case ExplosionSeverity.Destruction:

View File

@@ -5,8 +5,10 @@ using Content.Server.Interfaces;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -74,7 +76,7 @@ namespace Content.Server.GameObjects.Components.Destructible
void IExAct.OnExplosion(ExplosionEventArgs eventArgs) void IExAct.OnExplosion(ExplosionEventArgs eventArgs)
{ {
var prob = new Random(); var prob = IoCManager.Resolve<IRobustRandom>();
switch (eventArgs.Severity) switch (eventArgs.Severity)
{ {
case ExplosionSeverity.Destruction: case ExplosionSeverity.Destruction:
@@ -84,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Destructible
_actSystem.HandleDestruction(Owner, true); _actSystem.HandleDestruction(Owner, true);
break; break;
case ExplosionSeverity.Light: case ExplosionSeverity.Light:
if (RandomExtensions.Prob(prob, 40)) if (prob.Prob(40))
_actSystem.HandleDestruction(Owner, true); _actSystem.HandleDestruction(Owner, true);
break; break;
} }

View File

@@ -10,10 +10,12 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.EntitySystemMessages; using Robust.Shared.GameObjects.EntitySystemMessages;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Explosive namespace Content.Server.GameObjects.Components.Explosive
@@ -26,6 +28,7 @@ namespace Content.Server.GameObjects.Components.Explosive
[Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IServerEntityManager _serverEntityManager; [Dependency] private readonly IServerEntityManager _serverEntityManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager; [Dependency] private readonly IEntitySystemManager _entitySystemManager;
[Dependency] private readonly IRobustRandom _robustRandom;
#pragma warning restore 649 #pragma warning restore 649
public override string Name => "Explosive"; public override string Name => "Explosive";
@@ -96,7 +99,7 @@ namespace Content.Server.GameObjects.Components.Explosive
mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager["space"].TileId)); mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager["space"].TileId));
if (distanceFromTile < HeavyImpactRange) if (distanceFromTile < HeavyImpactRange)
{ {
if (new Random().Prob(80)) if (_robustRandom.Prob(80))
{ {
mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId)); mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId));
} }
@@ -107,7 +110,7 @@ namespace Content.Server.GameObjects.Components.Explosive
} }
if (distanceFromTile < LightImpactRange) if (distanceFromTile < LightImpactRange)
{ {
if (new Random().Prob(50)) if (_robustRandom.Prob(50))
{ {
mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId)); mapGrid.SetTile(tileLoc, new Tile(_tileDefinitionManager[tileDef.SubFloor].TileId));
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.Container;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
@@ -19,6 +20,10 @@ namespace Content.Server.GameObjects
[RegisterComponent] [RegisterComponent]
public class InventoryComponent : SharedInventoryComponent public class InventoryComponent : SharedInventoryComponent
{ {
#pragma warning disable 649
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
[ViewVariables] [ViewVariables]
private readonly Dictionary<Slots, ContainerSlot> SlotContainers = new Dictionary<Slots, ContainerSlot>(); private readonly Dictionary<Slots, ContainerSlot> SlotContainers = new Dictionary<Slots, ContainerSlot>();
@@ -223,27 +228,41 @@ namespace Content.Server.GameObjects
/// <param name="msg"></param> /// <param name="msg"></param>
private void HandleInventoryMessage(ClientInventoryMessage msg) private void HandleInventoryMessage(ClientInventoryMessage msg)
{ {
if (msg.Updatetype == ClientInventoryUpdate.Equip) switch (msg.Updatetype)
{ {
var hands = Owner.GetComponent<HandsComponent>(); case ClientInventoryUpdate.Equip:
var activehand = hands.GetActiveHand;
if (activehand != null && activehand.Owner.TryGetComponent(out ClothingComponent clothing))
{ {
hands.Drop(hands.ActiveIndex); var hands = Owner.GetComponent<HandsComponent>();
if (!Equip(msg.Inventoryslot, clothing)) 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;
} }
} case ClientInventoryUpdate.Use:
else if (msg.Updatetype == ClientInventoryUpdate.Unequip)
{
var hands = Owner.GetComponent<HandsComponent>();
var activehand = hands.GetActiveHand;
var itemcontainedinslot = GetSlotItem(msg.Inventoryslot);
if (activehand == null && itemcontainedinslot != null && Unequip(msg.Inventoryslot))
{ {
hands.PutInHand(itemcontainedinslot); var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
var hands = Owner.GetComponent<HandsComponent>();
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;
} }
} }
} }

View File

@@ -472,11 +472,18 @@ namespace Content.Server.GameObjects
var playerEntity = session.AttachedEntity; var playerEntity = session.AttachedEntity;
var used = GetActiveHand?.Owner; var used = GetActiveHand?.Owner;
if (playerEntity == Owner && used != null && slot.ContainedEntity != null) if (playerEntity == Owner && slot.ContainedEntity != null)
{ {
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>(); var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
interactionSystem.Interaction(Owner, used, slot.ContainedEntity, if (used != null)
GridCoordinates.Nullspace); {
interactionSystem.Interaction(Owner, used, slot.ContainedEntity,
GridCoordinates.Nullspace);
}
else
{
interactionSystem.Interaction(Owner, slot.ContainedEntity);
}
} }
break; break;

View File

@@ -161,6 +161,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
message.AddText("Fuel: "); message.AddText("Fuel: ");
message.PushColor(Fuel < FuelCapacity / 4f ? Color.DarkOrange : Color.Orange); message.PushColor(Fuel < FuelCapacity / 4f ? Color.DarkOrange : Color.Orange);
message.AddText($"{Math.Round(Fuel)}/{FuelCapacity}"); message.AddText($"{Math.Round(Fuel)}/{FuelCapacity}");
message.AddText(".");
message.Pop(); message.Pop();
} }
} }

View File

@@ -5,9 +5,11 @@ using Content.Shared.Audio;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -19,11 +21,11 @@ namespace Content.Server.GameObjects.Components.Items
{ {
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IRobustRandom _random;
#pragma warning restore 649 #pragma warning restore 649
public override string Name => "Dice"; public override string Name => "Dice";
private Random _random;
private int _step = 1; private int _step = 1;
private int _sides = 20; private int _sides = 20;
private int _currentSide = 20; private int _currentSide = 20;
@@ -45,12 +47,6 @@ namespace Content.Server.GameObjects.Components.Items
_currentSide = _sides; _currentSide = _sides;
} }
public override void OnAdd()
{
base.OnAdd();
_random = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
}
public void Roll() public void Roll()
{ {
_currentSide = _random.Next(1, (_sides/_step)+1) * _step; _currentSide = _random.Next(1, (_sides/_step)+1) * _step;

View File

@@ -2,8 +2,10 @@ using System;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
namespace Content.Server.GameObjects.Components.Items.Storage.Fill namespace Content.Server.GameObjects.Components.Items.Storage.Fill
{ {
@@ -19,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void IMapInit.MapInit() void IMapInit.MapInit()
{ {
var storage = Owner.GetComponent<IStorageComponent>(); var storage = Owner.GetComponent<IStorageComponent>();
var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode()); var random = IoCManager.Resolve<IRobustRandom>();
void Spawn(string prototype) void Spawn(string prototype)
{ {

View File

@@ -2,8 +2,10 @@ using System;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
namespace Content.Server.GameObjects.Components.Items.Storage.Fill namespace Content.Server.GameObjects.Components.Items.Storage.Fill
{ {
@@ -19,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void IMapInit.MapInit() void IMapInit.MapInit()
{ {
var storage = Owner.GetComponent<IStorageComponent>(); var storage = Owner.GetComponent<IStorageComponent>();
var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode()); var random = IoCManager.Resolve<IRobustRandom>();
void Spawn(string prototype) void Spawn(string prototype)
{ {

View File

@@ -7,7 +7,10 @@ using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects namespace Content.Server.GameObjects
@@ -20,6 +23,10 @@ namespace Content.Server.GameObjects
public override uint? NetID => ContentNetIDs.ITEM; public override uint? NetID => ContentNetIDs.ITEM;
public override Type StateType => typeof(ItemComponentState); public override Type StateType => typeof(ItemComponentState);
#pragma warning disable 649
[Dependency] private readonly IRobustRandom _robustRandom;
#pragma warning restore 649
private string _equippedPrefix; private string _equippedPrefix;
public string EquippedPrefix public string EquippedPrefix
@@ -115,7 +122,7 @@ namespace Content.Server.GameObjects
float RandomOffset() float RandomOffset()
{ {
var size = 15.0F; var size = 15.0F;
return (new Random().NextFloat() * size) - size / 2; return (_robustRandom.NextFloat() * size) - size / 2;
} }
} }
} }

View File

@@ -34,7 +34,6 @@ namespace Content.Server.GameObjects
[Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IPlayerManager _playerManager; [Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IEntityManager _entityManager; [Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649 #pragma warning restore 649
private Container storage; private Container storage;

View File

@@ -8,6 +8,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
@@ -24,6 +25,7 @@ namespace Content.Server.GameObjects.Components.Movement
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IServerEntityManager _serverEntityManager; [Dependency] private readonly IServerEntityManager _serverEntityManager;
[Dependency] private readonly IRobustRandom _spreadRandom;
#pragma warning restore 649 #pragma warning restore 649
// TODO: Look at MapManager.Map for Beacons to get all entities on grid // TODO: Look at MapManager.Map for Beacons to get all entities on grid
public ItemTeleporterState State => _state; public ItemTeleporterState State => _state;
@@ -44,8 +46,6 @@ namespace Content.Server.GameObjects.Components.Movement
private AppearanceComponent _appearanceComponent; private AppearanceComponent _appearanceComponent;
private Random _spreadRandom;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
@@ -149,7 +149,6 @@ namespace Content.Server.GameObjects.Components.Movement
public override void Initialize() public override void Initialize()
{ {
_appearanceComponent = Owner.GetComponent<AppearanceComponent>(); _appearanceComponent = Owner.GetComponent<AppearanceComponent>();
_spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
_state = ItemTeleporterState.Off; _state = ItemTeleporterState.Off;
base.Initialize(); base.Initialize();
} }

View File

@@ -182,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Power
{ {
if (!Powered) if (!Powered)
{ {
message.AddText("The device is not powered"); message.AddText("The device is not powered.");
} }
} }

View File

@@ -2,9 +2,11 @@
using Content.Shared.Audio; using Content.Shared.Audio;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Sound namespace Content.Server.GameObjects.Components.Sound
@@ -17,10 +19,10 @@ namespace Content.Server.GameObjects.Components.Sound
{ {
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IRobustRandom _footstepRandom;
#pragma warning restore 649 #pragma warning restore 649
/// <inheritdoc /> /// <inheritdoc />
/// ///
private Random _footstepRandom;
public override string Name => "FootstepModifier"; public override string Name => "FootstepModifier";
@@ -32,12 +34,6 @@ namespace Content.Server.GameObjects.Components.Sound
serializer.DataField(ref _soundCollectionName, "footstepSoundCollection", ""); serializer.DataField(ref _soundCollectionName, "footstepSoundCollection", "");
} }
public override void Initialize()
{
base.Initialize();
_footstepRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
}
public void PlayFootstep() public void PlayFootstep()
{ {
if (!string.IsNullOrWhiteSpace(_soundCollectionName)) if (!string.IsNullOrWhiteSpace(_soundCollectionName))

View File

@@ -10,7 +10,10 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -34,8 +37,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
[ViewVariables] [ViewVariables]
private IEntity Magazine => _magazineSlot.ContainedEntity; private IEntity Magazine => _magazineSlot.ContainedEntity;
[ViewVariables] #pragma warning disable 649
private Random _bulletDropRandom; [Dependency] private readonly IRobustRandom _bulletDropRandom;
#pragma warning restore 649
[ViewVariables] [ViewVariables]
private string _magInSound; private string _magInSound;
[ViewVariables] [ViewVariables]
@@ -74,7 +78,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
base.Initialize(); base.Initialize();
_appearance = Owner.GetComponent<AppearanceComponent>(); _appearance = Owner.GetComponent<AppearanceComponent>();
_bulletDropRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
} }
public override void Startup() public override void Startup()

View File

@@ -8,10 +8,12 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -23,7 +25,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
private float _spreadStdDev = 3; private float _spreadStdDev = 3;
private bool _spread = true; private bool _spread = true;
private Random _spreadRandom; #pragma warning disable 649
[Dependency] private IRobustRandom _spreadRandom;
#pragma warning restore 649
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public bool Spread public bool Spread
@@ -45,8 +49,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
var rangedWeapon = Owner.GetComponent<RangedWeaponComponent>(); var rangedWeapon = Owner.GetComponent<RangedWeaponComponent>();
rangedWeapon.FireHandler = Fire; rangedWeapon.FireHandler = Fire;
_spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
} }
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)

View File

@@ -62,20 +62,19 @@ namespace Content.Server.GameObjects.EntitySystems
message.PushColor(Color.DarkGray); message.PushColor(Color.DarkGray);
var subMessage = new FormattedMessage();
//Add component statuses from components that report one //Add component statuses from components that report one
foreach (var examineComponents in entity.GetAllComponents<IExamine>()) foreach (var examineComponents in entity.GetAllComponents<IExamine>())
{ {
var subMessage = new FormattedMessage();
examineComponents.Examine(subMessage); examineComponents.Examine(subMessage);
if (subMessage.Tags.Count == 0) if (subMessage.Tags.Count == 0)
continue; continue;
if (doNewline) if (doNewline)
{
message.AddText("\n"); message.AddText("\n");
doNewline = false;
}
message.AddMessage(subMessage); message.AddMessage(subMessage);
doNewline = true;
} }
message.Pop(); message.Pop();

View File

@@ -200,7 +200,7 @@ namespace Content.Server.GameObjects.EntitySystems
public override void Initialize() public override void Initialize()
{ {
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>(); var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand, inputSys.BindMap.BindFunction(EngineKeyFunctions.Use,
new PointerInputCmdHandler(HandleUseItemInHand)); new PointerInputCmdHandler(HandleUseItemInHand));
inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld, inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld,
new PointerInputCmdHandler(HandleActivateItemInWorld)); new PointerInputCmdHandler(HandleActivateItemInWorld));

View File

@@ -23,7 +23,9 @@ using Robust.Shared.Players;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Content.Server.GameObjects.Components.Sound; using Content.Server.GameObjects.Components.Sound;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Random;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
@@ -35,10 +37,10 @@ namespace Content.Server.GameObjects.EntitySystems
[Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IRobustRandom _robustRandom;
#pragma warning restore 649 #pragma warning restore 649
private AudioSystem _audioSystem; private AudioSystem _audioSystem;
private Random _footstepRandom;
private const float StepSoundMoveDistanceRunning = 2; private const float StepSoundMoveDistanceRunning = 2;
private const float StepSoundMoveDistanceWalking = 1.5f; private const float StepSoundMoveDistanceWalking = 1.5f;
@@ -47,7 +49,7 @@ namespace Content.Server.GameObjects.EntitySystems
public override void Initialize() public override void Initialize()
{ {
EntityQuery = new TypeEntityQuery(typeof(IMoverComponent)); EntityQuery = new TypeEntityQuery(typeof(IMoverComponent));
var moveUpCmdHandler = InputCmdHandler.FromDelegate( var moveUpCmdHandler = InputCmdHandler.FromDelegate(
session => HandleDirChange(session, Direction.North, true), session => HandleDirChange(session, Direction.North, true),
session => HandleDirChange(session, Direction.North, false)); session => HandleDirChange(session, Direction.North, false));
@@ -75,7 +77,6 @@ namespace Content.Server.GameObjects.EntitySystems
SubscribeEvent<PlayerAttachSystemMessage>(PlayerAttached); SubscribeEvent<PlayerAttachSystemMessage>(PlayerAttached);
SubscribeEvent<PlayerDetachedSystemMessage>(PlayerDetached); SubscribeEvent<PlayerDetachedSystemMessage>(PlayerDetached);
_footstepRandom = new Random();
_audioSystem = EntitySystemManager.GetEntitySystem<AudioSystem>(); _audioSystem = EntitySystemManager.GetEntitySystem<AudioSystem>();
} }
@@ -153,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems
{ {
mover.StepSoundDistance = 0; mover.StepSoundDistance = 0;
if (mover.Owner.TryGetComponent<InventoryComponent>(out var inventory) if (mover.Owner.TryGetComponent<InventoryComponent>(out var inventory)
&& inventory.TryGetSlotItem<ItemComponent>(EquipmentSlotDefines.Slots.SHOES, out var item) && inventory.TryGetSlotItem<ItemComponent>(EquipmentSlotDefines.Slots.SHOES, out var item)
&& item.Owner.TryGetComponent<FootstepModifierComponent>(out var modifier)) && item.Owner.TryGetComponent<FootstepModifierComponent>(out var modifier))
{ {
modifier.PlayFootstep(); modifier.PlayFootstep();
@@ -186,7 +187,7 @@ namespace Content.Server.GameObjects.EntitySystems
where T: Component where T: Component
{ {
component = default; component = default;
var ent = session.AttachedEntity; var ent = session.AttachedEntity;
if (ent == null || !ent.IsValid()) if (ent == null || !ent.IsValid())
@@ -238,7 +239,7 @@ namespace Content.Server.GameObjects.EntitySystems
try try
{ {
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(soundCollectionName); var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(soundCollectionName);
var file = _footstepRandom.Pick(soundCollection.PickFiles); var file = _robustRandom.Pick(soundCollection.PickFiles);
_audioSystem.Play(file, coordinates); _audioSystem.Play(file, coordinates);
} }
catch (UnknownPrototypeException) catch (UnknownPrototypeException)

View File

@@ -21,12 +21,14 @@ using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Random;
using Robust.Shared.Timers; using Robust.Shared.Timers;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -76,8 +78,6 @@ namespace Content.Server.GameTicking
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers; [ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
private DateTime _roundStartTimeUtc; private DateTime _roundStartTimeUtc;
private readonly Random _spawnRandom = new Random();
[ViewVariables] private readonly List<GameRule> _gameRules = new List<GameRule>(); [ViewVariables] private readonly List<GameRule> _gameRules = new List<GameRule>();
[ViewVariables] private Type _presetType; [ViewVariables] private Type _presetType;
@@ -92,6 +92,7 @@ namespace Content.Server.GameTicking
[Dependency] private IChatManager _chatManager; [Dependency] private IChatManager _chatManager;
[Dependency] private IServerNetManager _netManager; [Dependency] private IServerNetManager _netManager;
[Dependency] private IDynamicTypeFactory _dynamicTypeFactory; [Dependency] private IDynamicTypeFactory _dynamicTypeFactory;
[Dependency] private readonly IRobustRandom _robustRandom;
#pragma warning restore 649 #pragma warning restore 649
public void Initialize() public void Initialize()
@@ -293,7 +294,7 @@ namespace Content.Server.GameTicking
if (possiblePoints.Count != 0) if (possiblePoints.Count != 0)
{ {
location = _spawnRandom.Pick(possiblePoints); location = _robustRandom.Pick(possiblePoints);
} }
return location; return location;

View File

@@ -75,7 +75,7 @@ namespace Content.Shared.GameObjects
public enum ClientInventoryUpdate public enum ClientInventoryUpdate
{ {
Equip = 0, Equip = 0,
Unequip = 1 Use = 1
} }
} }

View File

@@ -18,6 +18,6 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction SwapHands = "SwapHands"; public static readonly BoundKeyFunction SwapHands = "SwapHands";
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand"; public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode"; public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode";
public static readonly BoundKeyFunction UseItemInHand = "UseItemInHand"; // use hand item on world entity public static readonly BoundKeyFunction MouseMiddle = "MouseMiddle";
} }
} }

View File

@@ -24,5 +24,3 @@
sprite: Clothing/belt_utility.rsi sprite: Clothing/belt_utility.rsi
- type: Storage - type: Storage
Capacity: 30 Capacity: 30

View File

@@ -53,19 +53,4 @@
state: leather state: leather
- type: Clothing - type: Clothing
sprite: Clothing/gloves_leather.rsi sprite: Clothing/gloves_leather.rsi
HeatResistance: 1500 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

View File

@@ -40,37 +40,3 @@
sprite: Clothing/captain_hat.rsi sprite: Clothing/captain_hat.rsi
Slots: Slots:
- helmet - 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

View File

@@ -47,19 +47,4 @@
sprite: Clothing/mask_clown.rsi sprite: Clothing/mask_clown.rsi
state: icon state: icon
- type: Clothing - type: Clothing
sprite: Clothing/mask_clown.rsi 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

View File

@@ -100,21 +100,4 @@
state: brown state: brown
- type: Clothing - type: Clothing
sprite: Clothing/shoes_brown.rsi 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

View File

@@ -58,18 +58,3 @@
- type: Clothing - type: Clothing
sprite: Clothing/chef_apron.rsi 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

View File

@@ -141,38 +141,4 @@
state: captain state: captain
- type: Clothing - type: Clothing
sprite: Clothing/captain_uniform.rsi 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

View File

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

View File

@@ -1,78 +1,86 @@
version: 1 # Not used right now, whatever. version: 1 # Not used right now, whatever.
binds: binds:
- function: Use
type: state
key: MouseLeft
canFocus: true
- function: ShowDebugMonitors - function: ShowDebugMonitors
type: Toggle
key: F3 key: F3
type: Toggle
- function: HideUI - function: HideUI
key: F4
type: Toggle type: Toggle
key: F4
- function: MoveUp - function: MoveUp
type: State
key: W key: W
type: State
- function: MoveLeft - function: MoveLeft
type: State
key: A key: A
type: State
- function: MoveRight - function: MoveRight
type: State
key: D key: D
type: State
- function: MoveDown - function: MoveDown
type: State
key: S key: S
type: State
- function: Run - function: Run
type: State
key: Shift key: Shift
type: State
- function: ShowEscapeMenu - function: ShowEscapeMenu
type: State
key: Escape key: Escape
type: State
- function: FocusChatWindow - function: FocusChatWindow
type: State
key: T key: T
type: State
- function: EditorLinePlace - function: EditorLinePlace
key: MouseLeft
mod1: Shift
type: State type: State
key: MouseLeft
canFocus: true
mod1: Shift
- function: EditorGridPlace - function: EditorGridPlace
key: MouseLeft
mod1: Control
type: State type: State
key: MouseLeft
canFocus: true
mod1: Control
- function: EditorPlaceObject - function: EditorPlaceObject
key: MouseLeft
type: State type: State
key: MouseLeft
canFocus: true
- function: EditorCancelPlace - function: EditorCancelPlace
key: MouseRight
type: State type: State
key: MouseRight
canFocus: true
- function: EditorRotateObject - function: EditorRotateObject
type: State
key: MouseMiddle key: MouseMiddle
type: State
- function: SwapHands - function: SwapHands
type: State
key: X key: X
type: State
- function: Drop - function: Drop
type: State
key: Q key: Q
type: State
- function: ActivateItemInHand - function: ActivateItemInHand
type: State
key: Z key: Z
type: State
- function: OpenCharacterMenu - function: OpenCharacterMenu
type: State
key: C key: C
type: State
- function: ExamineEntity - function: ExamineEntity
key: MouseLeft
mod1: Shift
type: State type: State
- function: UseItemInHand
key: MouseLeft key: MouseLeft
type: state canFocus: true
mod1: Shift
- function: ActivateItemInWorld - function: ActivateItemInWorld
type: state
key: E key: E
type: state
- function: ThrowItemInHand - function: ThrowItemInHand
type: state
key: MouseLeft key: MouseLeft
canFocus: true
mod1: Control mod1: Control
type: state
- function: OpenContextMenu - function: OpenContextMenu
key: MouseRight
type: state type: state
key: MouseRight
canFocus: true
- function: ToggleCombatMode - function: ToggleCombatMode
type: Toggle type: Toggle
key: Tab key: Tab
@@ -85,3 +93,41 @@ binds:
- function: OpenInventoryMenu - function: OpenInventoryMenu
type: state type: state
key: I 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