Files
tbd-station-14/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs
DamianX 4dcbf28714 IoC'd random (#302)
* Implemented RobustRandom

* update submodule

* update submodule

* Fix benchmark
2019-08-17 12:09:09 -07:00

42 lines
1.3 KiB
C#

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
{
[RegisterComponent]
internal sealed class ToolboxElectricalFillComponent : Component, IMapInit
{
public override string Name => "ToolboxElectricalFill";
#pragma warning disable 649
[Dependency] private readonly IEntityManager _entityManager;
#pragma warning restore 649
void IMapInit.MapInit()
{
var storage = Owner.GetComponent<IStorageComponent>();
var random = IoCManager.Resolve<IRobustRandom>();
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype));
}
Spawn("Screwdriver");
Spawn("Crowbar");
Spawn("Wirecutter");
Spawn("CableStack");
Spawn("CableStack");
// 5% chance for a pair of fancy insulated gloves, else just a third cable coil.
Spawn(random.Prob(0.05f) ? "YellowGloves" : "CableStack");
}
}
}