/// <summary> /// Server only - Tries to remove a body part /// </summary> public void TryRemoveFromBody(bool beingGibbed = false) { SetRemovedColor(); foreach (var bodyPart in HealthMaster.BodyPartList) { if (bodyPart.BodyPartType == BodyPartType.Chest) { bodyPart.IsBleeding = true; HealthMaster.ChangeBleedStacks(limbLossBleedingValue); } } DropItemsOnDismemberment(this); HealthMaster.BodyPartStorage.ServerTryRemove(gameObject); var bodyPartUISlot = GetComponent <BodyPartUISlots>(); var dynamicItemStorage = HealthMaster.GetComponent <DynamicItemStorage>(); dynamicItemStorage.Remove(bodyPartUISlot); //Fixes an error where externally bleeding body parts would continue to try bleeding even after their removal. if (IsBleedingExternally) { StopExternalBleeding(); } //this kills the crab if (DeathOnRemoval) { HealthMaster.Death(); } if (gibsEntireBodyOnRemoval && beingGibbed == false) { HealthMaster.Gib(); } }
/// <summary> /// Turns this body part into ash while protecting items inside of that cannot be ashed. /// </summary> private void AshBodyPart() { if (currentBurnDamageLevel >= TraumaDamageLevel.CRITICAL) { IEnumerable <ItemSlot> internalItemList = OrganStorage.GetItemSlots(); foreach (ItemSlot item in internalItemList) { Integrity itemObject = item.ItemObject.OrNull()?.GetComponent <Integrity>(); if (itemObject != null) //Incase this is an empty slot { if (itemObject.CannotBeAshed || itemObject.Resistances.Indestructable) { Inventory.ServerDrop(item); } } var organ = item.ItemObject.OrNull()?.GetComponent <BodyPart>(); if (organ != null) { if (organ.gibsEntireBodyOnRemoval) { HealthMaster.Gib(); return; } if (organ.DeathOnRemoval) { HealthMaster.Death(); } } } if (DeathOnRemoval && HealthMaster != null) { HealthMaster.Death(); } try { _ = Spawn.ServerPrefab(OrganStorage.AshPrefab, HealthMaster.gameObject.RegisterTile().WorldPosition); _ = Despawn.ServerSingle(this.gameObject); } catch (NullReferenceException exception) { Logger.LogError("Caught a NRE in BodyPartTraumaDamage.AshBodyPart() ", Category.Health); } } }
/// <summary> /// Server only - Tries to remove a body part /// </summary> public void TryRemoveFromBody(bool beingGibbed = false) { bool alreadyBleeding = false; SetRemovedColor(); foreach (var bodyPart in HealthMaster.BodyPartList) { if (bodyPart.BodyPartType == BodyPartType.Chest && alreadyBleeding == false) { bodyPart.IsBleeding = true; alreadyBleeding = true; HealthMaster.ChangeBleedStacks(limbLossBleedingValue); } } DropItemsOnDismemberment(this); var bodyPartUISlot = GetComponent <BodyPartUISlots>(); var dynamicItemStorage = HealthMaster.GetComponent <DynamicItemStorage>(); dynamicItemStorage.Remove(bodyPartUISlot); //Fixes an error where externally bleeding body parts would continue to try bleeding even after their removal. if (IsBleedingExternally) { StopExternalBleeding(); } //this kills the crab if (DeathOnRemoval) { HealthMaster.Death(); } if (gibsEntireBodyOnRemoval && beingGibbed == false) { HealthMaster.Gib(); } if (ContainedIn != null) { if (beingGibbed) { ContainedIn.OrganStorage.ServerTryRemove(gameObject, DroppedAtWorldPositionOrThrowVector: ConverterExtensions.GetRandomRotatedVector2(-0.5f, 0.5f), Throw: true); } else { ContainedIn.OrganStorage.ServerTryRemove(gameObject); } } else { if (beingGibbed) { HealthMaster.OrNull()?.BodyPartStorage.OrNull()?.ServerTryRemove(gameObject, DroppedAtWorldPositionOrThrowVector: ConverterExtensions.GetRandomRotatedVector2(-0.5f, 0.5f), Throw: true); } else { HealthMaster.OrNull()?.BodyPartStorage.OrNull()?.ServerTryRemove(gameObject); } } }