Storage system refactor & map init.

* Demonstrated map init working with guns, toolboxes, tool lockers.
* Refactored EntityStorage and ServerStorage to have a common interface.
* EntityStorage no longer uses ServerStorage PURELY for visuals.
  Use an appearance visualizer instead.
This commit is contained in:
Pieter-Jan Briers
2019-05-05 18:52:06 +02:00
parent 030f1f2a57
commit e35d5390db
17 changed files with 384 additions and 950 deletions

View File

@@ -0,0 +1,38 @@
using System;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Server.GameObjects.Components.Items.Storage.Fill
{
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 = new Random(DateTime.Now.GetHashCode() ^ Owner.Uid.GetHashCode());
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");
}
}
}