Files
tbd-station-14/Content.Client/GameObjects/Components/Cargo/GalacticMarketComponent.cs
DrSmugleaf 4a8ed41e3a Fix namespaces and optimize imports (#1651)
* Fix namespaces and optimize imports

* Cleanup fixes

* Merge conflict fixes

* Merge conflict fixes

* Merge conflict fixes
2020-08-13 14:40:27 +02:00

39 lines
1.2 KiB
C#

using System;
using Content.Shared.GameObjects.Components.Cargo;
using Content.Shared.Prototypes.Cargo;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.GameObjects.Components.Cargo
{
[RegisterComponent]
public class GalacticMarketComponent : SharedGalacticMarketComponent
{
#pragma warning disable CS0649
[Dependency] private IPrototypeManager _prototypeManager;
#pragma warning restore
/// <summary>
/// Event called when the database is updated.
/// </summary>
public event Action OnDatabaseUpdated;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is GalacticMarketState state))
return;
_products.Clear();
foreach (var productId in state.Products)
{
if (!_prototypeManager.TryIndex(productId, out CargoProductPrototype product))
continue;
_products.Add(product);
}
OnDatabaseUpdated?.Invoke();
}
}
}