2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Cargo.Components;
|
2019-11-21 16:37:15 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-02-18 09:09:07 +01:00
|
|
|
using Robust.Shared.Players;
|
2019-11-21 16:37:15 -08:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Cargo.Components
|
2019-11-21 16:37:15 -08:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class CargoOrderDatabaseComponent : SharedCargoOrderDatabaseComponent
|
2019-11-21 16:37:15 -08:00
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
public CargoOrderDatabase? Database { get; set; }
|
2019-11-21 16:37:15 -08:00
|
|
|
public bool ConnectedToDatabase => Database != null;
|
|
|
|
|
|
2021-06-19 19:41:26 -07:00
|
|
|
protected override void Initialize()
|
2019-11-21 16:37:15 -08:00
|
|
|
{
|
2019-12-19 11:35:17 -08:00
|
|
|
base.Initialize();
|
|
|
|
|
|
2022-02-15 15:01:45 +11:00
|
|
|
Database = EntitySystem.Get<CargoSystem>().StationOrderDatabase;
|
2019-11-21 16:37:15 -08:00
|
|
|
}
|
|
|
|
|
|
2021-11-30 15:20:38 +01:00
|
|
|
public override ComponentState GetComponentState()
|
2019-11-21 16:37:15 -08:00
|
|
|
{
|
|
|
|
|
if (!ConnectedToDatabase)
|
|
|
|
|
return new CargoOrderDatabaseState(null);
|
2021-03-16 15:50:20 +01:00
|
|
|
return new CargoOrderDatabaseState(Database?.GetOrders());
|
2019-11-21 16:37:15 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|