IoC'd random (#302)
* Implemented RobustRandom * update submodule * update submodule * Fix benchmark
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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>();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -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>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user