Implement machine linking (#1784)
* Implement machine linking * Cleanup and rename Signals * Implement signal button * Add machine linking signal mapping * Fix signallink command help * Add localization to signal linking and allow infinite range * Add feedback for when a transmitter is not connected to any receivers Refactor PopupMessage to use the entity extension Refactor dependencies to not have to disable warnings
This commit is contained in:
@@ -21,6 +21,8 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Content.Server.GameObjects.Components.MachineLinking;
|
||||
using Content.Shared.Interfaces;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerReceiverUsers
|
||||
{
|
||||
@@ -28,21 +30,17 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
/// Component that represents a wall light. It has a light bulb that can be replaced when broken.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit
|
||||
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit, ISignalReceiver
|
||||
{
|
||||
[Dependency] private IServerNotifyManager _notifyManager = default!;
|
||||
|
||||
public override string Name => "PoweredLight";
|
||||
|
||||
private static readonly TimeSpan _thunkDelay = TimeSpan.FromSeconds(2);
|
||||
|
||||
private TimeSpan _lastThunk;
|
||||
|
||||
[ViewVariables] private bool _on;
|
||||
|
||||
private LightBulbType BulbType = LightBulbType.Tube;
|
||||
|
||||
[ViewVariables] private ContainerSlot _lightBulbContainer;
|
||||
|
||||
[ViewVariables]
|
||||
private LightBulbComponent LightBulb
|
||||
{
|
||||
@@ -78,6 +76,23 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
return InsertBulb(eventArgs.Using);
|
||||
}
|
||||
|
||||
public void TriggerSignal(SignalState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SignalState.On:
|
||||
_on = true;
|
||||
break;
|
||||
case SignalState.Off:
|
||||
_on = false;
|
||||
break;
|
||||
case SignalState.Toggle:
|
||||
_on = !_on;
|
||||
break;
|
||||
}
|
||||
UpdateLight();
|
||||
}
|
||||
|
||||
public bool InteractHand(InteractHandEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out IDamageableComponent damageableComponent))
|
||||
@@ -103,7 +118,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
|
||||
void Burn()
|
||||
{
|
||||
_notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You burn your hand!"));
|
||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("You burn your hand!"));
|
||||
damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner);
|
||||
var audioSystem = EntitySystem.Get<AudioSystem>();
|
||||
audioSystem.PlayFromEntity("/Audio/Effects/lightburn.ogg", Owner);
|
||||
@@ -158,6 +173,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
serializer.DataField(ref BulbType, "bulb", LightBulbType.Tube);
|
||||
serializer.DataField(ref _on, "on", true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,9 +205,9 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
switch (LightBulb.State)
|
||||
{
|
||||
case LightBulbState.Normal:
|
||||
powerReceiver.Load = LightBulb.PowerUse;
|
||||
if (powerReceiver.Powered)
|
||||
if (powerReceiver.Powered && _on)
|
||||
{
|
||||
powerReceiver.Load = LightBulb.PowerUse;
|
||||
sprite.LayerSetState(0, "on");
|
||||
light.Enabled = true;
|
||||
light.Color = LightBulb.Color;
|
||||
@@ -204,6 +220,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
}
|
||||
else
|
||||
{
|
||||
powerReceiver.Load = 0;
|
||||
sprite.LayerSetState(0, "off");
|
||||
light.Enabled = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user