Add Flashlight Visualizer/states (#1861)

* Add art assets for cloning

* Added a 'Scan DNA' button to the medical scanner

* Made the UI update unconditional for the medical scanner until checks for power changes are in place

* Update Medical scanner to reflect powered status and fix #1774

* added a 'scan dna' button the the medical scanner that will add the contained bodies Uid to a list in CloningSystem, fixed an issue with the menu not populating if the scanner starts in an unpowered state

* Add disabling logic to 'Scan DNA' button on medical scanner

* Removed un-used libraries

* Added playing parameter to radiatingLightComponent, changed it's animation key to radiatingLight

* refactored RadiatingLight into a visualizer

* Added different light animations for differnt power states of a flashlight

* split out the radiating light visualizer into two seperate visualizers

* further refactored and tweaked handheldlight animations

* further lantern light tweaks

* removed un-used attributes in flashlight and lantern prototypes

* fix null check in handheldlightcomponent
This commit is contained in:
SoulSloth
2020-08-24 06:32:18 -04:00
committed by GitHub
parent 769a371be6
commit df823d2245
9 changed files with 243 additions and 80 deletions

View File

@@ -28,7 +28,8 @@ namespace Content.Server.GameObjects.Components.Interactable
/// Component that represents a handheld lightsource which can be toggled on and off.
/// </summary>
[RegisterComponent]
internal sealed class HandheldLightComponent : SharedHandheldLightComponent, IUse, IExamine, IInteractUsing, IMapInit
internal sealed class HandheldLightComponent : SharedHandheldLightComponent, IUse, IExamine, IInteractUsing,
IMapInit
{
[Dependency] private readonly ISharedNotifyManager _notifyManager = default!;
@@ -41,9 +42,12 @@ namespace Content.Server.GameObjects.Components.Interactable
get
{
if (_cellContainer.ContainedEntity == null) return null;
if (_cellContainer.ContainedEntity.TryGetComponent(out BatteryComponent? cell))
{
return cell;
}
_cellContainer.ContainedEntity.TryGetComponent(out BatteryComponent? cell);
return cell;
return null;
}
}
@@ -134,7 +138,6 @@ namespace Content.Server.GameObjects.Components.Interactable
Activated = false;
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Items/flashlight_toggle.ogg", Owner);
}
private void TurnOn(IEntity user)
@@ -147,7 +150,6 @@ namespace Content.Server.GameObjects.Components.Interactable
var cell = Cell;
if (cell == null)
{
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Machines/button.ogg", Owner);
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Cell missing..."));
@@ -168,7 +170,6 @@ namespace Content.Server.GameObjects.Components.Interactable
SetState(true);
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Items/flashlight_toggle.ogg", Owner);
}
private void SetState(bool on)
@@ -191,10 +192,24 @@ namespace Content.Server.GameObjects.Components.Interactable
public void OnUpdate(float frameTime)
{
if (!Activated) return;
if (!Activated || Cell == null) return;
var cell = Cell;
if (cell == null || !cell.TryUseCharge(Wattage * frameTime)) TurnOff();
var appearanceComponent = Owner.GetComponent<AppearanceComponent>();
if (Cell.MaxCharge - Cell.CurrentCharge < Cell.MaxCharge * 0.70)
{
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.FullPower);
}
else if (Cell.MaxCharge - Cell.CurrentCharge < Cell.MaxCharge * 0.90)
{
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.LowPower);
}
else
{
appearanceComponent.SetData(HandheldLightVisuals.Power, HandheldLightPowerStates.Dying);
}
if (Cell == null || !Cell.TryUseCharge(Wattage * frameTime)) TurnOff();
Dirty();
}
@@ -226,7 +241,6 @@ namespace Content.Server.GameObjects.Components.Interactable
}
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Items/pistol_magout.ogg", Owner);
}
public override ComponentState GetComponentState()