Explosion resistance is now predicted! (#30654)

* First commit

* Added Network and access
This commit is contained in:
beck-thompson
2024-08-04 20:15:07 -07:00
committed by GitHub
parent 84a9253b10
commit 490de1de4e
10 changed files with 53 additions and 30 deletions

View File

@@ -1,46 +0,0 @@
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Explosion;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
namespace Content.Server.Explosion.Components;
/// <summary>
/// Component that provides entities with explosion resistance.
/// By default this is applied when worn, but to solely protect the entity itself and
/// not the wearer use <c>worn: false</c>.
/// </summary>
/// <remarks>
/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
/// significantly reduce the damage, but shouldn't be silly overpowered in regular combat.
/// </remarks>
[RegisterComponent]
[Access(typeof(ExplosionSystem))]
public sealed partial class ExplosionResistanceComponent : Component
{
/// <summary>
/// The explosive resistance coefficient, This fraction is multiplied into the total resistance.
/// </summary>
[DataField("damageCoefficient")]
public float DamageCoefficient = 1;
/// <summary>
/// When true, resistances will be applied to the entity wearing this item.
/// When false, only this entity will get th resistance.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Worn = true;
/// <summary>
/// Examine string for explosion resistance.
/// Passed <c>value</c> from 0 to 100.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public LocId Examine = "explosion-resistance-coefficient-value";
/// <summary>
/// Modifiers specific to each explosion type for more customizability.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("modifiers", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, ExplosionPrototype>))]
public Dictionary<string, float> Modifiers = new();
}

View File

@@ -3,12 +3,12 @@ using Content.Server.Destructible;
using Content.Shared.Atmos;
using Content.Shared.Damage;
using Content.Shared.Explosion;
using Content.Shared.Explosion.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Shared.Map.Components;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
[Dependency] private readonly DestructibleSystem _destructibleSystem = default!;

View File

@@ -1,8 +1,8 @@
using Content.Shared.CCVar;
using Content.Shared.Explosion.EntitySystems;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
public int MaxIterations { get; private set; }
public int MaxArea { get; private set; }

View File

@@ -2,6 +2,7 @@ using System.Numerics;
using Content.Shared.Atmos;
using Content.Shared.Explosion;
using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
@@ -11,7 +12,7 @@ namespace Content.Server.Explosion.EntitySystems;
// A good portion of it is focused around keeping track of what tile-indices on a grid correspond to tiles that border
// space. AFAIK no other system currently needs to track these "edge-tiles". If they do, this should probably be a
// property of the grid itself?
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
/// <summary>
/// Set of tiles of each grid that are directly adjacent to space, along with the directions that face space.

View File

@@ -4,6 +4,7 @@ using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Explosion;
using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Projectiles;
@@ -17,10 +18,9 @@ using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class ExplosionSystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
[Dependency] private readonly FlammableSystem _flammableSystem = default!;

View File

@@ -7,13 +7,13 @@ using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
using Content.Shared.Explosion.EntitySystems;
namespace Content.Server.Explosion.EntitySystems;
// This partial part of the explosion system has all of the functions used to create the actual explosion map.
// I.e, to get the sets of tiles & intensity values that describe an explosion.
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
/// <summary>
/// This is the main explosion generating function.

View File

@@ -1,14 +1,14 @@
using System.Numerics;
using Content.Shared.Explosion;
using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
namespace Content.Server.Explosion.EntitySystems;
// This part of the system handled send visual / overlay data to clients.
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
public void InitVisuals()
{

View File

@@ -16,6 +16,8 @@ using Content.Shared.GameTicking;
using Content.Shared.Inventory;
using Content.Shared.Projectiles;
using Content.Shared.Throwing;
using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems;
using Robust.Server.GameStates;
using Robust.Server.Player;
using Robust.Shared.Audio.Systems;
@@ -29,7 +31,7 @@ using Robust.Shared.Utility;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class ExplosionSystem : EntitySystem
public sealed partial class ExplosionSystem : SharedExplosionSystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@@ -92,8 +94,6 @@ public sealed partial class ExplosionSystem : EntitySystem
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReset);
SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
// Handled by ExplosionSystem.Processing.cs
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
@@ -418,15 +418,4 @@ public sealed partial class ExplosionSystem : EntitySystem
_recoilSystem.KickCamera(uid, -delta.Normalized() * effect);
}
}
private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
{
var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);
if (value == 0)
return;
args.Msg.PushNewline();
args.Msg.AddMarkupOrThrow(Loc.GetString(component.Examine, ("value", value)));
}
}