2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Power.Components;
|
|
|
|
|
using Content.Shared.Interaction;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Research.Components
|
2019-09-03 22:51:19 +02:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ResearchPointSourceComponent : ResearchClientComponent
|
2019-09-03 22:51:19 +02:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("pointspersecond")]
|
2019-09-03 22:51:19 +02:00
|
|
|
private int _pointsPerSecond;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("active")]
|
2019-09-03 22:51:19 +02:00
|
|
|
private bool _active;
|
2021-07-04 18:11:52 +02:00
|
|
|
private ApcPowerReceiverComponent? _powerReceiver;
|
2019-09-03 22:51:19 +02:00
|
|
|
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2019-09-03 22:51:19 +02:00
|
|
|
public int PointsPerSecond
|
|
|
|
|
{
|
|
|
|
|
get => _pointsPerSecond;
|
2020-01-17 15:34:40 +01:00
|
|
|
set => _pointsPerSecond = value;
|
2019-09-03 22:51:19 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2019-09-03 22:51:19 +02:00
|
|
|
public bool Active
|
|
|
|
|
{
|
|
|
|
|
get => _active;
|
2020-01-17 15:34:40 +01:00
|
|
|
set => _active = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this can be used to produce research points.
|
|
|
|
|
/// </summary>
|
2021-07-04 18:11:52 +02:00
|
|
|
/// <remarks>If no <see cref="ApcPowerReceiverComponent"/> is found, it's assumed power is not required.</remarks>
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables]
|
2020-06-28 09:23:26 -06:00
|
|
|
public bool CanProduce => Active && (_powerReceiver is null || _powerReceiver.Powered);
|
2020-01-17 15:34:40 +01:00
|
|
|
|
2021-06-19 19:41:26 -07:00
|
|
|
protected override void Initialize()
|
2020-01-17 15:34:40 +01:00
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2021-12-03 15:53:09 +01:00
|
|
|
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out _powerReceiver);
|
2019-09-03 22:51:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|