Flashlight improvements:

1. Sound effects
2. fixed sprite having a hole
This commit is contained in:
Pieter-Jan Briers
2019-07-27 11:56:36 +02:00
parent 2e230c089b
commit 930cb61af8
9 changed files with 77 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Power;
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;
@@ -50,9 +51,20 @@ namespace Content.Server.GameObjects.Components.Interactable
if (Cell != null) return false; if (Cell != null) return false;
eventArgs.User.GetComponent<IHandsComponent>().Drop(eventArgs.AttackWith, _cellContainer); var handsComponent = eventArgs.User.GetComponent<IHandsComponent>();
if (!handsComponent.Drop(eventArgs.AttackWith, _cellContainer))
{
return false;
}
if (Owner.TryGetComponent(out SoundComponent soundComponent))
{
soundComponent.Play("/Audio/items/weapons/pistol_magin.ogg");
}
return true;
return _cellContainer.Insert(eventArgs.AttackWith);
} }
void IExamine.Examine(FormattedMessage message) void IExamine.Examine(FormattedMessage message)
@@ -85,17 +97,14 @@ namespace Content.Server.GameObjects.Components.Interactable
/// <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() public bool ToggleStatus()
{ {
// Update the activation state.
Activated = !Activated;
// Update sprite and light states to match the activation. // Update sprite and light states to match the activation.
if (Activated) if (Activated)
{ {
SetState(LightState.On); TurnOff();
} }
else else
{ {
SetState(LightState.Off); TurnOn();
} }
// Toggle always succeeds. // Toggle always succeeds.
@@ -104,25 +113,57 @@ namespace Content.Server.GameObjects.Components.Interactable
public void TurnOff() public void TurnOff()
{ {
if (!Activated) return; if (!Activated)
{
return;
}
SetState(LightState.Off); SetState(LightState.Off);
Activated = false; Activated = false;
if (Owner.TryGetComponent(out SoundComponent soundComponent))
{
soundComponent.Play("/Audio/items/flashlight_toggle.ogg");
}
} }
public void TurnOn() public void TurnOn()
{ {
if (Activated) return; if (Activated)
{
return;
}
var cell = Cell; var cell = Cell;
if (cell == null) return; SoundComponent soundComponent;
if (cell == null)
{
if (Owner.TryGetComponent(out soundComponent))
{
soundComponent.Play("/Audio/machines/button.ogg");
}
return;
}
// To prevent having to worry about frame time in here. // 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. // Let's just say you need a whole second of charge before you can turn it on.
// Simple enough. // Simple enough.
if (cell.AvailableCharge(1) < Wattage) return; if (cell.AvailableCharge(1) < Wattage)
{
if (Owner.TryGetComponent(out soundComponent))
{
soundComponent.Play("/Audio/machines/button.ogg");
}
return;
}
Activated = true;
SetState(LightState.On); SetState(LightState.On);
if (Owner.TryGetComponent(out soundComponent))
{
soundComponent.Play("/Audio/items/flashlight_toggle.ogg");
}
} }
private void SetState(LightState newState) private void SetState(LightState newState)
@@ -145,15 +186,32 @@ namespace Content.Server.GameObjects.Components.Interactable
private void EjectCell(IEntity user) private void EjectCell(IEntity user)
{ {
if (Cell == null) return; if (Cell == null)
{
return;
}
var cell = Cell; var cell = Cell;
if (!_cellContainer.Remove(cell.Owner)) return; if (!_cellContainer.Remove(cell.Owner))
{
return;
}
if (!user.TryGetComponent(out HandsComponent hands) if (!user.TryGetComponent(out HandsComponent hands))
|| !hands.PutInHand(cell.Owner.GetComponent<ItemComponent>())) {
return;
}
if (!hands.PutInHand(cell.Owner.GetComponent<ItemComponent>()))
{
cell.Owner.Transform.GridPosition = user.Transform.GridPosition; cell.Owner.Transform.GridPosition = user.Transform.GridPosition;
}
if (Owner.TryGetComponent(out SoundComponent soundComponent))
{
soundComponent.Play("/Audio/items/weapons/pistol_magout.ogg");
}
} }
[Verb] [Verb]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -5,3 +5,6 @@ smg_empty_alarm.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a864
casingfall1.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall1.ogg casingfall1.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall1.ogg
casingfall2.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall2.ogg casingfall2.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall2.ogg
casingfall3.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall3.ogg casingfall3.ogg: https://github.com/discordia-space/CEV-Eris/blob/fbde37a8647a82587d363da999a94cf02c2e128c/sound/weapons/guns/misc/casingfall3.ogg
pistol_cock.ogg: https://github.com/discordia-space/CEV-Eris/blob/c0293684320e7b70cbcac932b8dddeee35f3a51f/sound/weapons/guns/interact/pistol_cock.ogg
pistol_magin.ogg: https://github.com/discordia-space/CEV-Eris/blob/c0293684320e7b70cbcac932b8dddeee35f3a51f/sound/weapons/guns/interact/pistol_magin.ogg
pistol_magout.ogg: https://github.com/discordia-space/CEV-Eris/blob/c0293684320e7b70cbcac932b8dddeee35f3a51f/sound/weapons/guns/interact/pistol_magout.ogg

Binary file not shown.

View File

@@ -17,3 +17,4 @@
state: lantern_off state: lantern_off
- type: PointLight - type: PointLight
state: Off state: Off
- type: Sound

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 164 B