Give flashlights feedback about dead/missing cell.

This commit is contained in:
Pieter-Jan Briers
2019-10-10 11:50:53 +02:00
parent 963bb28f0f
commit cf97ef7ad1

View File

@@ -3,11 +3,14 @@ using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects; using Content.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.Container;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -19,6 +22,11 @@ namespace Content.Server.GameObjects.Components.Interactable
[RegisterComponent] [RegisterComponent]
internal class HandheldLightComponent : Component, IUse, IExamine, IAttackBy, IMapInit internal class HandheldLightComponent : Component, IUse, IExamine, IAttackBy, IMapInit
{ {
#pragma warning disable 649
[Dependency] private readonly ISharedNotifyManager _notifyManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public const float Wattage = 10; public const float Wattage = 10;
[ViewVariables] private ContainerSlot _cellContainer; [ViewVariables] private ContainerSlot _cellContainer;
private PointLightComponent _pointLight; private PointLightComponent _pointLight;
@@ -77,7 +85,7 @@ namespace Content.Server.GameObjects.Components.Interactable
bool IUse.UseEntity(UseEntityEventArgs eventArgs) bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{ {
return ToggleStatus(); return ToggleStatus(eventArgs.User);
} }
public override void Initialize() public override void Initialize()
@@ -95,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Interactable
/// Illuminates the light if it is not active, extinguishes it if it is active. /// Illuminates the light if it is not active, extinguishes it if it is active.
/// </summary> /// </summary>
/// <returns>True if the light's status was toggled, false otherwise.</returns> /// <returns>True if the light's status was toggled, false otherwise.</returns>
public bool ToggleStatus() private bool ToggleStatus(IEntity user)
{ {
// Update sprite and light states to match the activation. // Update sprite and light states to match the activation.
if (Activated) if (Activated)
@@ -104,14 +112,14 @@ namespace Content.Server.GameObjects.Components.Interactable
} }
else else
{ {
TurnOn(); TurnOn(user);
} }
// Toggle always succeeds. // Toggle always succeeds.
return true; return true;
} }
public void TurnOff() private void TurnOff()
{ {
if (!Activated) if (!Activated)
{ {
@@ -127,7 +135,7 @@ namespace Content.Server.GameObjects.Components.Interactable
} }
} }
public void TurnOn() private void TurnOn(IEntity user)
{ {
if (Activated) if (Activated)
{ {
@@ -142,6 +150,7 @@ namespace Content.Server.GameObjects.Components.Interactable
{ {
soundComponent.Play("/Audio/machines/button.ogg"); soundComponent.Play("/Audio/machines/button.ogg");
} }
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Cell missing..."));
return; return;
} }
@@ -154,6 +163,7 @@ namespace Content.Server.GameObjects.Components.Interactable
{ {
soundComponent.Play("/Audio/machines/button.ogg"); soundComponent.Play("/Audio/machines/button.ogg");
} }
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
return; return;
} }