예제 #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();
            }
        }
        /// <summary>
        /// Limb bleed logic, continues on until isBleedingExternally is false.
        /// </summary>
        private IEnumerator Bleedout()
        {
            while (isBleedingExternally)
            {
                //add 1 bleedstack every 10 seconds until the wound is closed
                yield return(WaitFor.Seconds(10f));

                if (IsBleeding)
                {
                    HealthMaster.ChangeBleedStacks(1f);
                }
            }
        }
예제 #3
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);
                }
            }
        }