- fix: Revert flammable changes. (#408)

This commit is contained in:
Aviu00
2024-07-01 13:27:22 +00:00
committed by GitHub
parent ddf9bea8a2
commit b24cff72c9
3 changed files with 65 additions and 73 deletions

View File

@@ -152,7 +152,7 @@ public sealed partial class AdminVerbSystem
Act = () =>
{
// Fuck you. Burn Forever.
flammable.FireStacks = flammable.MaximumFireStacks;
flammable.FireStacks = FlammableSystem.MaximumFireStacks;
_flammableSystem.Ignite(args.Target, args.User);
var xform = Transform(args.Target);
_popupSystem.PopupEntity(Loc.GetString("admin-smite-set-alight-self"), args.Target,

View File

@@ -11,65 +11,49 @@ namespace Content.Server.Atmos.Components
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool OnFire;
public bool OnFire { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float FireStacks;
public float FireStacks { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float MaximumFireStacks = 10f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float MinimumFireStacks = -10f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public string FlammableFixtureID = "flammable";
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float MinIgnitionTemperature = 373.15f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
[DataField("fireSpread")]
public bool FireSpread { get; private set; } = false;
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
[DataField("canResistFire")]
public bool CanResistFire { get; private set; } = false;
[DataField(required: true)]
[DataField("damage", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = new(); // Empty by default, we don't want any funny NREs.
/// <summary>
/// Used for the fixture created to handle passing firestacks when two flammable objects collide.
/// </summary>
[DataField]
[DataField("flammableCollisionShape")]
public IPhysShape FlammableCollisionShape = new PhysShapeCircle(0.35f);
/// <summary>
/// Should the component be set on fire by interactions with isHot entities
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
[DataField("alwaysCombustible")]
public bool AlwaysCombustible = false;
/// <summary>
/// Can the component anyhow lose its FireStacks?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
[DataField("canExtinguish")]
public bool CanExtinguish = true;
/// <summary>
/// How many firestacks should be applied to component when being set on fire?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
[DataField("firestacksOnIgnite")]
public float FirestacksOnIgnite = 2.0f;
/// <summary>

View File

@@ -52,11 +52,13 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SpellBladeSystem _spellBlade = default!; // WD
private EntityQuery<PhysicsComponent> _physicsQuery;
// This should probably be moved to the component, requires a rewrite, all fires tick at the same time
public const float MinimumFireStacks = -10f;
public const float MaximumFireStacks = 20f;
private const float UpdateTime = 1f;
public const float MinIgnitionTemperature = 373.15f;
public const string FlammableFixtureID = "flammable";
private float _timer;
private readonly Dictionary<Entity<FlammableComponent>, float> _fireEvents = new();
@@ -65,8 +67,6 @@ namespace Content.Server.Atmos.EntitySystems
{
UpdatesAfter.Add(typeof(AtmosphereSystem));
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollide);
@@ -141,7 +141,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!TryComp<PhysicsComponent>(uid, out var body))
return;
_fixture.TryCreateFixture(uid, component.FlammableCollisionShape, component.FlammableFixtureID, hard: false,
_fixture.TryCreateFixture(uid, component.FlammableCollisionShape, FlammableFixtureID, hard: false,
collisionMask: (int) CollisionGroup.FullTileLayer, body: body);
}
@@ -199,7 +199,7 @@ namespace Content.Server.Atmos.EntitySystems
// Normal hard collisions, though this isn't generally possible since most flammable things are mobs
// which don't collide with one another, shouldn't work here.
if (args.OtherFixtureId != flammable.FlammableFixtureID && args.OurFixtureId != flammable.FlammableFixtureID)
if (args.OtherFixtureId != FlammableFixtureID && args.OurFixtureId != FlammableFixtureID)
return;
if (!flammable.FireSpread)
@@ -211,30 +211,49 @@ namespace Content.Server.Atmos.EntitySystems
if (!flammable.OnFire && !otherFlammable.OnFire)
return; // Neither are on fire
// Both are on fire -> equalize fire stacks.
// Weight each thing's firestacks by its mass
var mass1 = 1f;
var mass2 = 1f;
if (_physicsQuery.TryComp(uid, out var physics) && _physicsQuery.TryComp(otherUid, out var otherPhys))
// WD START
var weHold = _spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(uid);
var theyHold = _spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(otherUid);
// WD END
if (flammable.OnFire && otherFlammable.OnFire)
{
mass1 = physics.Mass;
mass2 = otherPhys.Mass;
if (weHold && !theyHold || theyHold && !weHold) // WD
return;
// Both are on fire -> equalize fire stacks.
var avg = (flammable.FireStacks + otherFlammable.FireStacks) / 2;
flammable.FireStacks = flammable.CanExtinguish ? avg : Math.Max(flammable.FireStacks, avg);
otherFlammable.FireStacks = otherFlammable.CanExtinguish ? avg : Math.Max(otherFlammable.FireStacks, avg);
UpdateAppearance(uid, flammable);
UpdateAppearance(otherUid, otherFlammable);
return;
}
// when the thing on fire is more massive than the other, the following happens:
// - the thing on fire loses a small number of firestacks
// - the other thing gains a large number of firestacks
// so a person on fire engulfs a mouse, but an engulfed mouse barely does anything to a person
var total = mass1 + mass2;
var avg = (flammable.FireStacks + otherFlammable.FireStacks) / total;
// swap the entity losing stacks depending on whichever has the most firestack kilos
var (src, dest) = flammable.FireStacks * mass1 > otherFlammable.FireStacks * mass2
? (-1f, 1f)
: (1f, -1f);
// bring each entity to the same firestack mass, firestacks being scaled by the other's mass
AdjustFireStacks(uid, src * avg * mass2, flammable, ignite: true);
AdjustFireStacks(otherUid, dest * avg * mass1, otherFlammable, ignite: true);
// Only one is on fire -> attempt to spread the fire.
if (flammable.OnFire)
{
if (theyHold) // WD
return;
otherFlammable.FireStacks += flammable.FireStacks / 2;
Ignite(otherUid, uid, otherFlammable);
if (flammable.CanExtinguish)
{
flammable.FireStacks /= 2;
UpdateAppearance(uid, flammable);
}
}
else
{
if (weHold) // WD
return;
flammable.FireStacks += otherFlammable.FireStacks / 2;
Ignite(uid, otherUid, flammable);
if (otherFlammable.CanExtinguish)
{
otherFlammable.FireStacks /= 2;
UpdateAppearance(otherUid, otherFlammable);
}
}
}
private void OnIsHot(EntityUid uid, FlammableComponent flammable, IsHotEvent args)
@@ -244,7 +263,7 @@ namespace Content.Server.Atmos.EntitySystems
private void OnTileFire(Entity<FlammableComponent> ent, ref TileFireEvent args)
{
var tempDelta = args.Temperature - ent.Comp.MinIgnitionTemperature;
var tempDelta = args.Temperature - MinIgnitionTemperature;
_fireEvents.TryGetValue(ent, out var maxTemp);
@@ -272,30 +291,17 @@ namespace Content.Server.Atmos.EntitySystems
_appearance.SetData(uid, ToggleableLightVisuals.Enabled, flammable.OnFire, appearance);
}
public void AdjustFireStacks(EntityUid uid, float relativeFireStacks, FlammableComponent? flammable = null, bool ignite = false)
public void AdjustFireStacks(EntityUid uid, float relativeFireStacks, FlammableComponent? flammable = null)
{
if (!Resolve(uid, ref flammable))
return;
SetFireStacks(uid, flammable.FireStacks + relativeFireStacks, flammable, ignite);
}
flammable.FireStacks = MathF.Min(MathF.Max(MinimumFireStacks, flammable.FireStacks + relativeFireStacks), MaximumFireStacks);
public void SetFireStacks(EntityUid uid, float stacks, FlammableComponent? flammable = null, bool ignite = false)
{
if (!Resolve(uid, ref flammable))
return;
flammable.FireStacks = MathF.Min(MathF.Max(flammable.MinimumFireStacks, stacks), flammable.MaximumFireStacks);
if (flammable.FireStacks <= 0)
{
if (flammable.OnFire && flammable.FireStacks <= 0)
Extinguish(uid, flammable);
}
else
{
flammable.OnFire = ignite;
UpdateAppearance(uid, flammable);
}
}
public void Extinguish(EntityUid uid, FlammableComponent? flammable = null)
@@ -444,11 +450,13 @@ namespace Content.Server.Atmos.EntitySystems
EnsureComp<IgnitionSourceComponent>(uid);
_ignitionSourceSystem.SetIgnited(uid);
var damageScale = MathF.Min( flammable.FireStacks, 5);
if (TryComp(uid, out TemperatureComponent? temp))
_temperatureSystem.ChangeHeat(uid, 12500 * flammable.FireStacks, false, temp);
_temperatureSystem.ChangeHeat(uid, 12500 * damageScale, false, temp);
if (!_spellBlade.IsHoldingItemWithComponent<FireAspectComponent>(uid)) // WD EDIT
_damageableSystem.TryChangeDamage(uid, flammable.Damage * flammable.FireStacks, interruptsDoAfters: false);
_damageableSystem.TryChangeDamage(uid, flammable.Damage * damageScale, interruptsDoAfters: false);
AdjustFireStacks(uid, flammable.FirestackFade * (flammable.Resisting ? 10f : 1f), flammable);
}