public void MakeAllDisconnectedPartsGhosty() { if (currCraft == null) { return; } //update structure currCraft.UpdatePhysParts(true); List <PhysPart> connectedParts = new List <PhysPart>(PartConnection.GetConnectedParts(currCraft.originPart)); foreach (PhysPart part in currCraft.Parts) { if (connectedParts.Contains(part)) { if (currPart == null || PartConnection.IsConnectedToPartIgnoringInvalidParts(part, currCraft.originPart, new PhysPart[1] { currPart })) //Check if part is connected to origin, IGNORING held part. { MakePartGhosty(part, false); } } else { MakePartGhosty(part, true); } } }
public void ApplyStress(float stress) { if (enabled == false) { return; } if (stress > GetEffectiveStrength(internalStrength)) //destroy part if impact too strong { DestroyPart(GetStressToCarry(stress)); //destroy and carry stress } else //just break connections if impact not strong enough to destroy this part { List <PartConnection> brokenConnections = new List <PartConnection>(); foreach (PartConnection c in connections) { if (stress > c.GetTrueConnectionStrength()) { if (PartConnection.IsConnectedToPartIgnoringInvalidParts(c.toPart, GetBodyOrigin(), new PhysPart[1] { this }, true)) { brokenConnections.Add(c); } } } while (brokenConnections.Count > 0) { DisconnectPart(brokenConnections[0].toPart, GetStressToCarry(stress)); //disconenct and carry stress brokenConnections.RemoveAt(0); } } }