Make ExplosionHelper methods extensions (#2373)
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
|
int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
|
||||||
int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
|
int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
|
||||||
int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
|
int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
|
||||||
ExplosionHelper.SpawnExplosion(solutionEntity.Transform.Coordinates, finalDevastationRange,
|
solutionEntity.SpawnExplosion(finalDevastationRange,
|
||||||
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
|
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ namespace Content.Server.Explosions
|
|||||||
/// Distance used for camera shake when distance from explosion is (0.0, 0.0).
|
/// 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).
|
/// Avoids getting NaN values down the line from doing math on (0.0, 0.0).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static Vector2 _epicenterDistance = (0.1f, 0.1f);
|
private static readonly Vector2 EpicenterDistance = (0.1f, 0.1f);
|
||||||
|
|
||||||
public static void SpawnExplosion(EntityCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange)
|
public static void SpawnExplosion(this EntityCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange)
|
||||||
{
|
{
|
||||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||||
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
||||||
@@ -151,7 +151,7 @@ namespace Content.Server.Explosions
|
|||||||
var delta = coords.ToMapPos(entityManager) - playerPos;
|
var delta = coords.ToMapPos(entityManager) - playerPos;
|
||||||
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
||||||
if (delta.EqualsApprox((0.0f, 0.0f)))
|
if (delta.EqualsApprox((0.0f, 0.0f)))
|
||||||
delta = _epicenterDistance;
|
delta = EpicenterDistance;
|
||||||
|
|
||||||
var distance = delta.LengthSquared;
|
var distance = delta.LengthSquared;
|
||||||
var effect = 10 * (1 / (1 + distance));
|
var effect = 10 * (1 / (1 + distance));
|
||||||
@@ -162,5 +162,11 @@ namespace Content.Server.Explosions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SpawnExplosion(this IEntity entity, int devastationRange, int heavyImpactRange,
|
||||||
|
int lightImpactRange, int flashRange)
|
||||||
|
{
|
||||||
|
entity.Transform.Coordinates.SpawnExplosion(devastationRange, heavyImpactRange, lightImpactRange, flashRange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Explosion
|
|||||||
if (_beingExploded) return true;
|
if (_beingExploded) return true;
|
||||||
_beingExploded = true;
|
_beingExploded = true;
|
||||||
|
|
||||||
ExplosionHelper.SpawnExplosion(Owner.Transform.Coordinates, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
|
Owner.SpawnExplosion(DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -143,9 +143,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
|||||||
|
|
||||||
intensity = Math.Min(intensity, 8);
|
intensity = Math.Min(intensity, 8);
|
||||||
|
|
||||||
ExplosionHelper.SpawnExplosion(epicenter.Owner.Transform.Coordinates, intensity / 2, intensity, intensity * 2, intensity * 3);
|
epicenter.Owner.SpawnExplosion(intensity / 2, intensity, intensity * 2, intensity * 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace Content.Server.GameObjects.Components.Pointing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExplosionHelper.SpawnExplosion(Owner.Transform.Coordinates, 0, 2, 1, 1);
|
Owner.SpawnExplosion(0, 2, 1, 1);
|
||||||
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/explosion.ogg", Owner);
|
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/explosion.ogg", Owner);
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
|
|||||||
Reference in New Issue
Block a user