Merge branch 'master' of https://github.com/space-wizards/space-station-14
This commit is contained in:
@@ -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<SpriteComponent>();
|
||||
Transform = Owner.GetComponent<ITransformComponent>();
|
||||
var systemman = IoCManager.Resolve<IEntitySystemManager>();
|
||||
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<ScrewdriverComponent>())
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -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<IRobustRandom>();
|
||||
switch (eventArgs.Severity)
|
||||
{
|
||||
case ExplosionSeverity.Destruction:
|
||||
|
||||
@@ -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<IRobustRandom>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<IStorageComponent>();
|
||||
var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode());
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
void Spawn(string prototype)
|
||||
{
|
||||
|
||||
@@ -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<IStorageComponent>();
|
||||
var random = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode());
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
void Spawn(string prototype)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AppearanceComponent>();
|
||||
_spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
|
||||
_state = ItemTeleporterState.Off;
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
/// <inheritdoc />
|
||||
///
|
||||
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))
|
||||
|
||||
@@ -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<AppearanceComponent>();
|
||||
_bulletDropRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
|
||||
}
|
||||
|
||||
public override void Startup()
|
||||
|
||||
@@ -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<RangedWeaponComponent>();
|
||||
rangedWeapon.FireHandler = Fire;
|
||||
|
||||
_spreadRandom = new Random(Owner.Uid.GetHashCode() ^ DateTime.Now.GetHashCode());
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
|
||||
Reference in New Issue
Block a user