2021-02-06 06:43:50 +11:00
|
|
|
#nullable enable
|
2021-01-02 12:03:10 -06:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-10-11 16:57:16 -04:00
|
|
|
using System.Linq;
|
2021-01-02 12:03:10 -06:00
|
|
|
using Content.Server.GameObjects.Components.Explosion;
|
2019-10-11 16:57:16 -04:00
|
|
|
using Content.Server.GameObjects.Components.Mobs;
|
2021-02-06 06:43:50 +11:00
|
|
|
using Content.Shared.GameObjects.Components.Tag;
|
Bodysystem and damagesystem rework (#1544)
* Things and stuff with grids, unfinished w/ code debug changes.
* Updated submodule and also lost some progress cause I fucked it up xd
* First unfinished draft of the BodySystem. Doesn't compile.
* More changes to make it compile, but still just a framework. Doesn't do anything at the moment.
* Many cleanup changes.
* Revert "Merge branch 'master' of https://github.com/GlassEclipse/space-station-14 into body_system"
This reverts commit ddd4aebbc76cf2a0b7b102f72b93d55a0816c88c, reversing
changes made to 12d0dd752706bdda8879393bd8191a1199a0c978.
* Commit human.yml
* Updated a lot of things to be more classy, more progress overall, etc. etc.
* Latest update with many changes
* Minor changes
* Fixed Travis build bug
* Adds first draft of Body Scanner console, apparently I also forgot to tie Mechanisms into body parts so now a heart just sits in the Torso like a good boy :)
* Commit rest of stuff
* Latest changes
* Latest changes again
* 14 naked cowboys
* Yay!
* Latest changes (probably doesnt compile)
* Surgery!!!!!!!!!~1116y
* Cleaned some stuff up
* More cleanup
* Refactoring of code. Basic surgery path now done.
* Removed readme, has been added to HackMD
* Fixes typo (and thus test errors)
* WIP changes, committing so I can pull latest master changes
* Still working on that god awful merge
* Latest changes
* Latest changes!!
* Beginning of refactor to BoundUserInterface
* Surgery!
* Latest changes - fixes pr change requests and random fixes
* oops
* Fixes bodypart recursion
* Beginning of work on revamping the damage system.
* More latest changes
* Latest changes
* Finished merge
* Commit before removing old healthcode
* Almost done with removing speciescomponent...
* It compiles!!!
* yahoo more work
* Fixes to make it work
* Merge conflict fixes
* Deleting species visualizer was a mistake
* IDE warnings are VERBOTEN
* makes the server not kill itself on startup, some cleanup (#1)
* Namespaces, comments and exception fixes
* Fix conveyor and conveyor switch serialization
SS14 in reactive when
* Move damage, acts and body to shared
Damage cleanup
Comment cleanup
* Rename SpeciesComponent to RotationComponent and cleanup
Damage cleanup
Comment cleanup
* Fix nullable warnings
* Address old reviews
Fix off welder suicide damage type, deathmatch and suspicion
* Fix new test fail with units being able to accept items when unpowered
* Remove RotationComponent, change references to IBodyManagerComponent
* Add a bloodstream to humans
* More cleanups
* Add body conduits, connections, connectors substances and valves
* Revert "Add body conduits, connections, connectors substances and valves"
This reverts commit 9ab0b50e6b15fe98852d7b0836c0cdbf4bd76d20.
* Implement the heart mechanism behavior with the circulatory network
* Added network property to mechanism behaviors
* Changed human organ sprites and added missing ones
* Fix tests
* Add individual body part sprite rendering
* Fix error where dropped mechanisms are not initialized
* Implement client/server body damage
* Make DamageContainer take care of raising events
* Reimplement medical scanner with the new body system
* Improve the medical scanner ui
* Merge conflict fixes
* Fix crash when colliding with something
* Fix microwave suicides and eyes sprite rendering
* Fix nullable reference error
* Fix up surgery client side
* Fix missing using from merge conflict
* Add breathing
*inhale
* Merge conflict fixes
* Fix accumulatedframetime being reset to 0 instead of decreased by the threshold
https://github.com/space-wizards/space-station-14/pull/1617
* Use and add to the new AtmosHelpers
* Fix feet
* Add proper coloring to dropped body parts
* Fix Urist's lungs being too strong
* Merge conflict fixes
* Merge conflict fixes
* Merge conflict fixes
Co-authored-by: GlassEclipse <tsymall5@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2020-08-17 01:42:42 +02:00
|
|
|
using Content.Shared.GameObjects.EntitySystems;
|
2019-10-11 16:57:16 -04:00
|
|
|
using Content.Shared.Maps;
|
2021-01-02 12:03:10 -06:00
|
|
|
using Content.Shared.Physics;
|
|
|
|
|
using Content.Shared.Utility;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Server.Player;
|
2021-01-02 12:03:10 -06:00
|
|
|
using Robust.Shared.Containers;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2019-10-11 16:57:16 -04:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
using Robust.Shared.Maths;
|
|
|
|
|
using Robust.Shared.Random;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.Timing;
|
2019-10-11 16:57:16 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.Explosions
|
|
|
|
|
{
|
|
|
|
|
public static class ExplosionHelper
|
|
|
|
|
{
|
2020-02-08 14:46:12 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Distance used for camera shake when distance from explosion is (0.0, 0.0).
|
|
|
|
|
/// Avoids getting NaN values down the line from doing math on (0.0, 0.0).
|
|
|
|
|
/// </summary>
|
2020-10-25 12:11:23 +01:00
|
|
|
private static readonly Vector2 EpicenterDistance = (0.1f, 0.1f);
|
2020-02-08 14:46:12 -05:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Chance of a tile breaking if the severity is Light and Heavy
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly float LightBreakChance = 0.3f;
|
|
|
|
|
private static readonly float HeavyBreakChance = 0.8f;
|
|
|
|
|
|
2021-02-06 06:43:50 +11:00
|
|
|
private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable");
|
2021-01-02 12:03:10 -06:00
|
|
|
|
|
|
|
|
private static ExplosionSeverity CalculateSeverity(float distance, float devastationRange, float heaveyRange)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
if (distance < devastationRange)
|
|
|
|
|
{
|
|
|
|
|
return ExplosionSeverity.Destruction;
|
|
|
|
|
}
|
|
|
|
|
else if (distance < heaveyRange)
|
|
|
|
|
{
|
|
|
|
|
return ExplosionSeverity.Heavy;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ExplosionSeverity.Light;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Damage entities inside the range. The damage depends on a discrete
|
|
|
|
|
/// damage bracket [light, heavy, devastation] and the distance from the epicenter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A dictionary of coordinates relative to the parents of every grid of entities that survived the explosion,
|
|
|
|
|
/// have an airtight component and are currently blocking air. Like a wall.
|
|
|
|
|
/// </returns>
|
|
|
|
|
private static void DamageEntitiesInRange(EntityCoordinates epicenter, Box2 boundingBox,
|
|
|
|
|
float devastationRange,
|
|
|
|
|
float heaveyRange,
|
|
|
|
|
float maxRange,
|
|
|
|
|
MapId mapId)
|
|
|
|
|
{
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
2019-10-11 16:57:16 -04:00
|
|
|
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
|
|
|
|
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
|
|
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
var exAct = entitySystemManager.GetEntitySystem<ActSystem>();
|
|
|
|
|
|
|
|
|
|
var entitiesInRange = serverEntityManager.GetEntitiesInRange(mapId, boundingBox, 0).ToList();
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
var impassableEntities = new List<Tuple<IEntity, float>>();
|
|
|
|
|
var nonImpassableEntities = new List<Tuple<IEntity, float>>();
|
|
|
|
|
|
|
|
|
|
// The entities are paired with their distance to the epicenter
|
|
|
|
|
// and splitted into two lists based on if they are Impassable or not
|
|
|
|
|
foreach (var entity in entitiesInRange)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
if (entity.Deleted || !entity.Transform.IsMapTransform)
|
|
|
|
|
{
|
2019-10-11 16:57:16 -04:00
|
|
|
continue;
|
2021-01-02 12:03:10 -06:00
|
|
|
}
|
2020-01-21 12:13:57 -05:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
if (!entity.Transform.Coordinates.TryDistance(entityManager, epicenter, out var distance) || distance > maxRange)
|
2020-09-06 16:11:53 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-06 06:43:50 +11:00
|
|
|
if (!entity.TryGetComponent(out IPhysicsComponent? body) || body.PhysicsShapes.Count < 1)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
continue;
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
|
|
|
|
|
if ((body.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
impassableEntities.Add(Tuple.Create(entity, distance));
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
else
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
nonImpassableEntities.Add(Tuple.Create(entity, distance));
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The Impassable entities are sorted in descending order
|
|
|
|
|
// Entities closer to the epicenter are first
|
|
|
|
|
impassableEntities.Sort((x, y) => x.Item2.CompareTo(y.Item2));
|
|
|
|
|
|
|
|
|
|
// Impassable entities are handled first. If they are damaged enough, they are destroyed and they may
|
|
|
|
|
// be able to spawn a new entity. I.e Wall -> Girder.
|
2021-02-06 06:43:50 +11:00
|
|
|
// Girder has a tag ExplosivePassable, and the predicate make it so the entities with this tag are ignored
|
2021-01-02 12:03:10 -06:00
|
|
|
var epicenterMapPos = epicenter.ToMap(entityManager);
|
|
|
|
|
foreach (var (entity, distance) in impassableEntities)
|
|
|
|
|
{
|
|
|
|
|
if (!entity.InRangeUnobstructed(epicenterMapPos, maxRange, ignoreInsideBlocker: true, predicate: IgnoreExplosivePassable))
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
exAct.HandleExplosion(epicenter, entity, CalculateSeverity(distance, devastationRange, heaveyRange));
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
// Impassable entities were handled first so NonImpassable entities have a bigger chance to get hit. As now
|
|
|
|
|
// there are probably more ExplosivePassable entities around
|
|
|
|
|
foreach (var (entity, distance) in nonImpassableEntities)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
if (!entity.InRangeUnobstructed(epicenterMapPos, maxRange, ignoreInsideBlocker: true, predicate: IgnoreExplosivePassable))
|
2020-02-22 20:30:36 -03:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
continue;
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
exAct.HandleExplosion(epicenter, entity, CalculateSeverity(distance, devastationRange, heaveyRange));
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
}
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Damage tiles inside the range. The type of tile can change depending on a discrete
|
|
|
|
|
/// damage bracket [light, heavy, devastation], the distance from the epicenter and
|
|
|
|
|
/// a probabilty bracket [<see cref="LightBreakChance"/>, <see cref="HeavyBreakChance"/>, 1.0].
|
|
|
|
|
/// </summary>
|
2021-01-24 16:06:03 +01:00
|
|
|
///
|
2021-01-02 12:03:10 -06:00
|
|
|
private static void DamageTilesInRange(EntityCoordinates epicenter,
|
|
|
|
|
GridId gridId,
|
|
|
|
|
Box2 boundingBox,
|
|
|
|
|
float devastationRange,
|
|
|
|
|
float heaveyRange,
|
|
|
|
|
float maxRange)
|
|
|
|
|
{
|
|
|
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
|
|
|
if (!mapManager.TryGetGrid(gridId, out var mapGrid))
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
return;
|
|
|
|
|
}
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entityManager.TryGetEntity(mapGrid.GridEntityId, out var grid))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
|
|
|
|
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
|
|
|
|
|
|
|
|
|
var tilesInGridAndCircle = mapGrid.GetTilesIntersecting(boundingBox);
|
|
|
|
|
|
|
|
|
|
var epicenterMapPos = epicenter.ToMap(entityManager);
|
|
|
|
|
foreach (var tile in tilesInGridAndCircle)
|
|
|
|
|
{
|
|
|
|
|
var tileLoc = mapGrid.GridTileToLocal(tile.GridIndices);
|
|
|
|
|
if (!tileLoc.TryDistance(entityManager, epicenter, out var distance) || distance > maxRange)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-11-13 17:37:46 -05:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
if (tile.IsBlockedTurf(false))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!tileLoc.ToMap(entityManager).InRangeUnobstructed(epicenterMapPos, maxRange, ignoreInsideBlocker: false, predicate: IgnoreExplosivePassable))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
|
|
|
|
var baseTurfs = tileDef.BaseTurfs;
|
|
|
|
|
if (baseTurfs.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId);
|
|
|
|
|
var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId);
|
|
|
|
|
|
|
|
|
|
var severity = CalculateSeverity(distance, devastationRange, heaveyRange);
|
|
|
|
|
|
|
|
|
|
switch (severity)
|
|
|
|
|
{
|
|
|
|
|
case ExplosionSeverity.Light:
|
|
|
|
|
if (!previousTile.IsEmpty && robustRandom.Prob(LightBreakChance))
|
|
|
|
|
{
|
|
|
|
|
mapGrid.SetTile(tileLoc, previousTile);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ExplosionSeverity.Heavy:
|
|
|
|
|
if (!previousTile.IsEmpty && robustRandom.Prob(HeavyBreakChance))
|
|
|
|
|
{
|
|
|
|
|
mapGrid.SetTile(tileLoc, previousTile);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case ExplosionSeverity.Destruction:
|
|
|
|
|
mapGrid.SetTile(tileLoc, zeroTile);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CameraShakeInRange(EntityCoordinates epicenter, float maxRange)
|
|
|
|
|
{
|
2019-10-11 16:57:16 -04:00
|
|
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
2021-01-02 12:03:10 -06:00
|
|
|
var players = playerManager.GetPlayersInRange(epicenter, (int) Math.Ceiling(maxRange));
|
|
|
|
|
foreach (var player in players)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-02-06 06:43:50 +11:00
|
|
|
if (player.AttachedEntity == null || !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent? recoil))
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
2019-10-11 16:57:16 -04:00
|
|
|
var playerPos = player.AttachedEntity.Transform.WorldPosition;
|
2021-01-02 12:03:10 -06:00
|
|
|
var delta = epicenter.ToMapPos(entityManager) - playerPos;
|
|
|
|
|
|
2020-02-08 14:46:12 -05:00
|
|
|
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
|
|
|
|
if (delta.EqualsApprox((0.0f, 0.0f)))
|
2020-10-25 12:11:23 +01:00
|
|
|
delta = EpicenterDistance;
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2020-02-08 14:46:12 -05:00
|
|
|
var distance = delta.LengthSquared;
|
2020-08-09 20:56:02 +02:00
|
|
|
var effect = 10 * (1 / (1 + distance));
|
2019-10-11 16:57:16 -04:00
|
|
|
if (effect > 0.01f)
|
|
|
|
|
{
|
|
|
|
|
var kick = -delta.Normalized * effect;
|
|
|
|
|
recoil.Kick(kick);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-25 12:11:23 +01:00
|
|
|
|
2021-01-02 12:03:10 -06:00
|
|
|
private static void FlashInRange(EntityCoordinates epicenter, float flashrange)
|
2020-10-25 12:11:23 +01:00
|
|
|
{
|
2021-01-02 12:03:10 -06:00
|
|
|
if (flashrange > 0)
|
|
|
|
|
{
|
|
|
|
|
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
|
|
|
|
|
var time = IoCManager.Resolve<IGameTiming>().CurTime;
|
|
|
|
|
var message = new EffectSystemMessage
|
|
|
|
|
{
|
|
|
|
|
EffectSprite = "Effects/explosion.rsi",
|
|
|
|
|
RsiState = "explosionfast",
|
|
|
|
|
Born = time,
|
|
|
|
|
DeathTime = time + TimeSpan.FromSeconds(5),
|
|
|
|
|
Size = new Vector2(flashrange / 2, flashrange / 2),
|
|
|
|
|
Coordinates = epicenter,
|
|
|
|
|
Rotation = 0f,
|
|
|
|
|
ColorDelta = new Vector4(0, 0, 0, -1500f),
|
|
|
|
|
Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), 0.5f),
|
|
|
|
|
Shaded = false
|
|
|
|
|
};
|
|
|
|
|
entitySystemManager.GetEntitySystem<EffectSystem>().CreateParticle(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-24 16:06:03 +01:00
|
|
|
public static void SpawnExplosion(this IEntity entity, int devastationRange = 0, int heavyImpactRange = 0,
|
|
|
|
|
int lightImpactRange = 0, int flashRange = 0)
|
2021-01-02 12:03:10 -06:00
|
|
|
{
|
2021-01-24 16:06:03 +01:00
|
|
|
// If you want to directly set off the explosive
|
2021-02-06 06:43:50 +11:00
|
|
|
if (!entity.Deleted && entity.TryGetComponent(out ExplosiveComponent? explosive) && !explosive.Exploding)
|
2021-01-02 12:03:10 -06:00
|
|
|
{
|
2021-01-24 16:06:03 +01:00
|
|
|
explosive.Explosion();
|
2021-01-02 12:03:10 -06:00
|
|
|
}
|
2021-01-24 16:06:03 +01:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (entity.TryGetContainer(out var cont))
|
|
|
|
|
{
|
|
|
|
|
entity = cont.Owner;
|
|
|
|
|
}
|
2021-01-02 12:03:10 -06:00
|
|
|
|
2021-01-24 16:06:03 +01:00
|
|
|
var epicenter = entity.Transform.Coordinates;
|
2021-01-02 12:03:10 -06:00
|
|
|
|
2021-01-24 16:06:03 +01:00
|
|
|
SpawnExplosion(epicenter, devastationRange, heavyImpactRange, lightImpactRange, flashRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SpawnExplosion(EntityCoordinates epicenter, int devastationRange = 0,
|
|
|
|
|
int heavyImpactRange = 0, int lightImpactRange = 0, int flashRange = 0)
|
|
|
|
|
{
|
|
|
|
|
var mapId = epicenter.GetMapId(IoCManager.Resolve<IEntityManager>());
|
|
|
|
|
if (mapId == MapId.Nullspace)
|
2021-01-02 12:03:10 -06:00
|
|
|
{
|
2021-01-24 16:06:03 +01:00
|
|
|
return;
|
2021-01-02 12:03:10 -06:00
|
|
|
}
|
2021-01-24 16:06:03 +01:00
|
|
|
|
|
|
|
|
var maxRange = MathHelper.Max(devastationRange, heavyImpactRange, lightImpactRange, 0);
|
2021-01-02 12:03:10 -06:00
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
|
|
|
|
|
|
|
|
var epicenterMapPos = epicenter.ToMapPos(entityManager);
|
2021-01-24 16:06:03 +01:00
|
|
|
var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange),
|
|
|
|
|
epicenterMapPos + new Vector2(maxRange, maxRange));
|
2021-01-02 12:03:10 -06:00
|
|
|
|
2021-01-24 16:06:03 +01:00
|
|
|
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Effects/explosion.ogg", epicenter);
|
2021-01-02 12:03:10 -06:00
|
|
|
DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId);
|
|
|
|
|
|
|
|
|
|
var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox);
|
|
|
|
|
|
|
|
|
|
foreach (var gridId in mapGridsNear)
|
|
|
|
|
{
|
|
|
|
|
DamageTilesInRange(epicenter, gridId.Index, boundingBox, devastationRange, heavyImpactRange, maxRange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CameraShakeInRange(epicenter, maxRange);
|
|
|
|
|
FlashInRange(epicenter, flashRange);
|
|
|
|
|
}
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
|
|
|
|
}
|