Husk infection state can be decreased after the infection reaches the active state (causing the husk appendage to be removed). Calyxanide still has a conditional preventing the decrease, but now it's possible for modders to revert huskification without code modifications. Closes #258

This commit is contained in:
Joonas Rikkonen
2018-02-21 11:12:49 +02:00
parent d414e8e103
commit 24cb7a3659
4 changed files with 79 additions and 18 deletions
@@ -426,6 +426,46 @@ namespace Barotrauma
Mass += limb.Mass;
if (!limbDictionary.ContainsKey(limb.type)) limbDictionary.Add(limb.type, limb);
}
public void RemoveLimb(Limb limb)
{
if (!Limbs.Contains(limb)) return;
Limb[] newLimbs = new Limb[Limbs.Length - 1];
int i = 0;
foreach (Limb existingLimb in Limbs)
{
if (existingLimb == limb) continue;
newLimbs[i] = existingLimb;
i++;
}
Limbs = newLimbs;
if (limbDictionary.ContainsKey(limb.type)) limbDictionary.Remove(limb.type);
//remove all joints that were attached to the removed limb
LimbJoint[] attachedJoints = Array.FindAll(LimbJoints, lj => lj.LimbA == limb || lj.LimbB == limb);
if (attachedJoints.Length > 0)
{
LimbJoint[] newJoints = new LimbJoint[LimbJoints.Length - attachedJoints.Length];
i = 0;
foreach (LimbJoint limbJoint in LimbJoints)
{
if (attachedJoints.Contains(limbJoint)) continue;
newJoints[i] = limbJoint;
i++;
}
LimbJoints = newJoints;
}
limb.Remove();
foreach (LimbJoint limbJoint in attachedJoints)
{
GameMain.World.RemoveJoint(limbJoint);
}
}
public bool OnLimbCollision(Fixture f1, Fixture f2, Contact contact)
{