Files
tbd-station-14/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs
ZelteHonor b2e2aef78d Rider static analysis (#433)
* Non-accessed local variable

* Merge cast and type checks.

* StringComparison.Ordinal added for better culture support

* Supposed code improvement in launcher. Remove unused code.

* Update ExplosionHelper.cs

Unintentional change.

* Optimized Import

* Add Robust.Shared.Utility import where it was deleted

* Other random suggestion

* Improve my comment
2019-11-13 23:37:46 +01:00

40 lines
1.2 KiB
C#

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.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) ? "GlovesYellow" : "CableStack");
}
}
}