コード例 #1
0
        /// <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();
            }
        }
コード例 #2
0
        /// <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);
                }
            }
        }