* 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>
156 lines
6.6 KiB
C#
156 lines
6.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Shared.GameObjects.EntitySystems;
|
|
using Content.Shared.Maps;
|
|
using Robust.Server.GameObjects.EntitySystems;
|
|
using Robust.Server.Interfaces.GameObjects;
|
|
using Robust.Server.Interfaces.Player;
|
|
using Robust.Shared.GameObjects.EntitySystemMessages;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Interfaces.Map;
|
|
using Robust.Shared.Interfaces.Random;
|
|
using Robust.Shared.Interfaces.Timing;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Explosions
|
|
{
|
|
public static class ExplosionHelper
|
|
{
|
|
/// <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>
|
|
private static Vector2 _epicenterDistance = (0.1f, 0.1f);
|
|
|
|
public static void SpawnExplosion(GridCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange)
|
|
{
|
|
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
|
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
|
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
|
|
|
var maxRange = MathHelper.Max(devastationRange, heavyImpactRange, lightImpactRange, 0f);
|
|
//Entity damage calculation
|
|
var entitiesAll = serverEntityManager.GetEntitiesInRange(coords, maxRange).ToList();
|
|
|
|
foreach (var entity in entitiesAll)
|
|
{
|
|
if (entity.Deleted)
|
|
continue;
|
|
if (!entity.Transform.IsMapTransform)
|
|
continue;
|
|
|
|
var distanceFromEntity = (int)entity.Transform.GridPosition.Distance(mapManager, coords);
|
|
ExplosionSeverity severity;
|
|
if (distanceFromEntity < devastationRange)
|
|
{
|
|
severity = ExplosionSeverity.Destruction;
|
|
}
|
|
else if (distanceFromEntity < heavyImpactRange)
|
|
{
|
|
severity = ExplosionSeverity.Heavy;
|
|
}
|
|
else if (distanceFromEntity < lightImpactRange)
|
|
{
|
|
severity = ExplosionSeverity.Light;
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
var exAct = entitySystemManager.GetEntitySystem<ActSystem>();
|
|
//exAct.HandleExplosion(Owner, entity, severity);
|
|
exAct.HandleExplosion(coords, entity, severity);
|
|
}
|
|
|
|
//Tile damage calculation mockup
|
|
//TODO: make it into some sort of actual damage component or whatever the boys think is appropriate
|
|
var mapGrid = mapManager.GetGrid(coords.GridID);
|
|
var circle = new Circle(coords.Position, maxRange);
|
|
var tiles = mapGrid.GetTilesIntersecting(circle);
|
|
foreach (var tile in tiles)
|
|
{
|
|
var tileLoc = mapGrid.GridTileToLocal(tile.GridIndices);
|
|
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
|
var baseTurfs = tileDef.BaseTurfs;
|
|
if (baseTurfs.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
var distanceFromTile = (int) tileLoc.Distance(mapManager, coords);
|
|
|
|
var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId);
|
|
var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId);
|
|
|
|
switch (distanceFromTile)
|
|
{
|
|
case var d when d < devastationRange:
|
|
mapGrid.SetTile(tileLoc, zeroTile);
|
|
break;
|
|
case var d when d < heavyImpactRange
|
|
&& !previousTile.IsEmpty
|
|
&& robustRandom.Prob(0.8f):
|
|
mapGrid.SetTile(tileLoc, previousTile);
|
|
break;
|
|
case var d when d < lightImpactRange
|
|
&& !previousTile.IsEmpty
|
|
&& robustRandom.Prob(0.5f):
|
|
mapGrid.SetTile(tileLoc, previousTile);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//Effects and sounds
|
|
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 = coords,
|
|
//Rotated from east facing
|
|
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);
|
|
entitySystemManager.GetEntitySystem<AudioSystem>().PlayAtCoords("/Audio/Effects/explosion.ogg", coords);
|
|
|
|
// Knock back cameras of all players in the area.
|
|
|
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
|
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 = coords.ToMapPos(mapManager) - playerPos;
|
|
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
|
if (delta.EqualsApprox((0.0f, 0.0f)))
|
|
delta = _epicenterDistance;
|
|
|
|
var distance = delta.LengthSquared;
|
|
var effect = 10 * (1 / (1 + distance));
|
|
if (effect > 0.01f)
|
|
{
|
|
var kick = -delta.Normalized * effect;
|
|
recoil.Kick(kick);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|