@@ -1,8 +1,6 @@
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
@@ -18,6 +16,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
@@ -39,13 +38,13 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
private ClothingComponent _clothingComponent;
|
||||
|
||||
[ViewVariables]
|
||||
private PowerCellComponent Cell
|
||||
private BatteryComponent Cell
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cellContainer.ContainedEntity == null) return null;
|
||||
|
||||
_cellContainer.ContainedEntity.TryGetComponent(out PowerCellComponent cell);
|
||||
_cellContainer.ContainedEntity.TryGetComponent(out BatteryComponent cell);
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +57,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Using.HasComponent<PowerCellComponent>()) return false;
|
||||
if (!eventArgs.Using.HasComponent<BatteryComponent>()) return false;
|
||||
|
||||
if (Cell != null) return false;
|
||||
|
||||
@@ -100,7 +99,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
_spriteComponent = Owner.GetComponent<SpriteComponent>();
|
||||
Owner.TryGetComponent(out _clothingComponent);
|
||||
_cellContainer =
|
||||
ContainerManagerComponent.Ensure<ContainerSlot>("flashlight_cell_container", Owner, out var existed);
|
||||
ContainerManagerComponent.Ensure<ContainerSlot>("flashlight_cell_container", Owner, out _);
|
||||
Dirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -160,7 +160,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
// To prevent having to worry about frame time in here.
|
||||
// Let's just say you need a whole second of charge before you can turn it on.
|
||||
// Simple enough.
|
||||
if (cell.AvailableCharge(1) < Wattage)
|
||||
if (Wattage > cell.CurrentCharge)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/machines/button.ogg", Owner);
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
|
||||
@@ -189,7 +189,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
if (!Activated) return;
|
||||
|
||||
var cell = Cell;
|
||||
if (cell == null || !cell.TryDeductWattage(Wattage, frameTime)) TurnOff();
|
||||
if (cell == null || !cell.TryUseCharge(Wattage * frameTime)) TurnOff();
|
||||
|
||||
Dirty();
|
||||
}
|
||||
@@ -229,14 +229,14 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return new HandheldLightComponentState(null);
|
||||
}
|
||||
|
||||
if (Cell.AvailableCharge(1) < Wattage)
|
||||
if (Wattage > Cell.CurrentCharge)
|
||||
{
|
||||
// Practically zero.
|
||||
// This is so the item status works correctly.
|
||||
return new HandheldLightComponentState(0);
|
||||
}
|
||||
|
||||
return new HandheldLightComponentState(Cell.Charge / Cell.Capacity);
|
||||
return new HandheldLightComponentState(Cell.CurrentCharge / Cell.MaxCharge);
|
||||
}
|
||||
|
||||
[Verb]
|
||||
|
||||
Reference in New Issue
Block a user