mass2 = otherPhys.Mass;
}
- // 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);
+ // Get the average of both entity's firestacks * mass
+ // Then for each entity, we divide the average by their mass and set their firestacks to that value
+ // An entity with a higher mass will lose some fire and transfer it to the one with lower mass.
+ var avg = (flammable.FireStacks * mass1 + otherFlammable.FireStacks * mass2) / 2f;
+
+ // bring each entity to the same firestack mass, firestack amount is scaled by the inverse of the entity's mass
+ SetFireStacks(uid, avg / mass1, flammable, ignite: true);
+ SetFireStacks(otherUid, avg / mass2, otherFlammable, ignite: true);
}
private void OnIsHot(EntityUid uid, FlammableComponent flammable, IsHotEvent args)