This commit is contained in:
ShadowCommander
2019-08-20 18:27:12 -07:00
20 changed files with 76 additions and 52 deletions

View File

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

View File

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

View File

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

View File

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