Power Rework (#863)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-06-28 09:23:26 -06:00
committed by GitHub
parent ffe25de723
commit 23cc6b1d4e
154 changed files with 11253 additions and 3913 deletions

View File

@@ -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]