Skip to content

Commit

Permalink
Polish explosions somewhat.
Browse files Browse the repository at this point in the history
Just makes them less ugly. Slightly.
  • Loading branch information
PJB3005 committed Jul 6, 2019
1 parent 215885a commit 8ff4c22
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Mobs;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.EntitySystemMessages;
Expand All @@ -15,6 +16,7 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects;
using Content.Shared.Maps;
using Robust.Server.Interfaces.Player;

namespace Content.Server.GameObjects.Components.Explosive
{
Expand Down Expand Up @@ -118,7 +120,8 @@ private bool Explosion()
var time = IoCManager.Resolve<IGameTiming>().CurTime;
var message = new EffectSystemMessage
{
EffectSprite = "Effects/explosion.png",
EffectSprite = "Effects/explosion.rsi",
RsiState = "explosionfast",
Born = time,
DeathTime = time + TimeSpan.FromSeconds(5),
Size = new Vector2(FlashRange / 2, FlashRange / 2),
Expand All @@ -131,6 +134,32 @@ private bool Explosion()
};
_entitySystemManager.GetEntitySystem<EffectSystem>().CreateParticle(message);
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/effects/explosion.ogg", Owner);

// Knock back cameras of all players in the area.

var playerManager = IoCManager.Resolve<IPlayerManager>();
var selfPos = Owner.Transform.WorldPosition;
foreach (var player in playerManager.GetAllPlayers())
{
if (player.AttachedEntity == null
|| player.AttachedEntity.Transform.MapID != mapGrid.ParentMapId
|| !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent recoil))
{
continue;
}

var playerPos = player.AttachedEntity.Transform.WorldPosition;
var delta = selfPos - playerPos;
var distance = delta.LengthSquared;

var effect = 1 / (1 + 0.2f * distance);
if (effect > 0.01f)
{
var kick = -delta.Normalized * effect;
recoil.Kick(kick);
}
}

return true;
}

Expand Down
Binary file modified Resources/Audio/effects/explosion.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Explosives.yml
Expand Up @@ -55,7 +55,7 @@
Size: 5

- type: OnUseTimerTrigger
delay: 5
delay: 3.5

- type: Explosive
devastationRange: 3
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 1 addition & 28 deletions Resources/Textures/Effects/explosion.rsi/meta.json
@@ -1,28 +1 @@
{
"version": 1,
"size": {
"x": 96,
"y": 96
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from https://github.com/vgstation-coders/vgstation13/icons/effects/96x96.dmi at commit 96d69b71a3a0549b4b668c0a095306580bd157c0",
"states": [
{
"name": "explosion",
"select": [],
"flags": {},
"directions": 1,
"delays": [
[
0.2,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1
]
]
}
]
}
{"version": 1, "size": {"x": 96, "y": 96}, "states": [{"name": "explosionfast", "directions": 1, "delays": [[0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06]]}]}

0 comments on commit 8ff4c22

Please sign in to comment.