コード例 #1
0
        public override void LegacyImpact(MaterialThing thing)
        {
            Duck?duck = thing switch
            {
                Duck d when d != BulletSafeDuck => d,
                RagdollPart ragdollPart => ragdollPart.duck,
                _ => null,
            };

            if (duck is not null)
            {
                return;
            }

            base.LegacyImpact(thing);
        }
コード例 #2
0
ファイル: DarkChains.cs プロジェクト: Ebediam/DarkChains
        public static void DarkChainDestroy(Item chain, RagdollPart ragdollPart, RagdollHandle ragdollHandle, Telekinesis telekinesis, bool neck)
        {
            telekinesis.TryRelease();

            DestroySelf.Destroy(chain.gameObject);

            if (ragdollPart.ragdoll.parts.Count > 0)
            {
                foreach (RagdollPart part in ragdollPart.ragdoll.parts)
                {
                    part.rb.isKinematic = false;
                }
            }

            if (ragdollHandle.ragdollPart.ragdoll.parts.Count > 0)
            {
                foreach (RagdollPart part in ragdollHandle.ragdollPart.ragdoll.parts)
                {
                    part.rb.isKinematic = false;
                }
            }


            ragdollPart.ragdoll.SetState(BS.Ragdoll.State.Fallen);
            if (ragdollPart.ragdoll.creature.health.currentHealth <= 0)
            {
                ragdollPart.ragdoll.SetState(BS.Ragdoll.State.Dead);
            }


            if (ragdollHandle.name == "NPC(neck)(chained)")
            {
                ragdollHandle.name = "NPC(neck)";
            }
            else if (ragdollHandle.name == "NPC(chained)")
            {
                ragdollHandle.name = "NPC";
            }
            else
            {
                Debug.Log("The ragdollHandle was neither the neck nor a default part");
            }
            //ragdollPart.ragdoll.RefreshFall();
            ragdollPart.ragdoll.allowStandUp = true;
            ragdollHandle.tag = "Untagged";
        }
コード例 #3
0
        public IEnumerator HeavenlyObjectOnRagdollPart(RagdollPart ragdollPart, float timeout)
        {
            var startTime = Time.time;

            while (Time.time - startTime <= timeout)
            {
                yield return(new WaitForSeconds(1));
            }

            var heaven         = ragdollPart.transform.position + 5 * Vector3.up;
            var objectItemData = _objectItemDatas[_random.Next(0, _objectItemDatas.Count)];

            objectItemData.SpawnAsync(
                objectItem => { GameManager.local.StartCoroutine(FallingObjectItem(objectItem, ragdollPart)); }, heaven,
                Quaternion.identity);

            yield return(null);
        }
コード例 #4
0
        public IEnumerator FallingObjectItem(Item objectItem, RagdollPart ragdollPart)
        {
            var startTime = Time.time;

            objectItem.SetColliderAndMeshLayer(GameManager.GetLayer(LayerName.MovingObject));
            objectItem.rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            objectItem.isThrowed = true;
            objectItem.isFlying  = true;

            var position  = ragdollPart.transform.position;
            var direction = (position - objectItem.transform.position).normalized;

            objectItem.rb.velocity = 100 * direction;

            objectItem.Despawn(10);

            yield return(null);
        }
コード例 #5
0
            private static void Postfix(HandleRagdoll __instance)
            {
                var ragdollPart = __instance.ragdollPart;

                try
                {
                    Object.Destroy(ragdollPart.gameObject.GetComponent <FrozenRagdollPart>());
                }
                catch (Exception exception)
                {
                    Debug.Log(exception.Message);
                }

                RagdollPart otherPart = null;

                if (ragdollPart.type == RagdollPart.Type.LeftArm)
                {
                    otherPart = ragdollPart.ragdoll.GetPart(RagdollPart.Type.LeftHand);
                }
                if (ragdollPart.type == RagdollPart.Type.RightArm)
                {
                    otherPart = ragdollPart.ragdoll.GetPart(RagdollPart.Type.RightHand);
                }
                if (ragdollPart.type == RagdollPart.Type.LeftLeg)
                {
                    otherPart = ragdollPart.ragdoll.GetPart(RagdollPart.Type.LeftFoot);
                }
                if (ragdollPart.type == RagdollPart.Type.RightLeg)
                {
                    otherPart = ragdollPart.ragdoll.GetPart(RagdollPart.Type.RightFoot);
                }

                if (otherPart != null)
                {
                    try
                    {
                        Object.Destroy(otherPart.gameObject.GetComponent <FrozenRagdollPart>());
                    }
                    catch (Exception exception)
                    {
                        Debug.Log(exception.Message);
                    }
                }
            }
コード例 #6
0
        public void DisarmEveryoneLmao()
        {
            SpellCastData lightningData = Player.currentCreature.mana.casterLeft.spellInstance is SpellCastLightning
                ? Player.currentCreature.mana.casterLeft.spellInstance
                : Player.currentCreature.mana.casterRight.spellInstance;

            if (lightningData is SpellCastLightning cast)
            {
                // modified from ThunderRoad source code for Gravity crystal slam
                List <Creature> pushedCreatures = new List <Creature>();
                foreach (Collider collider in Physics.OverlapSphere(Player.currentCreature.mana.mergePoint.position, radius)
                         .Where(c =>
                                c.attachedRigidbody &&
                                c.attachedRigidbody &&
                                !c.attachedRigidbody.isKinematic))
                {
                    if (collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.NPC) || collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.Ragdoll))
                    {
                        RagdollPart component = collider.attachedRigidbody.gameObject.GetComponent <RagdollPart>();
                        if (component.ragdoll.creature == Player.currentCreature)
                        {
                            continue;
                        }
                        if (component && !pushedCreatures.Contains(component.ragdoll.creature))
                        {
                            // do it again, just in case lmao
                            pushedCreatures.Add(component.ragdoll.creature);
                            component.ragdoll.creature.handLeft.TryRelease();
                            component.ragdoll.creature.handRight.TryRelease();
                            ActionShock action = component.ragdoll.creature.brain.GetAction <ActionShock>();
                            if (action != null)
                            {
                                action.Refresh(0.5f, cast.boltShockDuration);
                            }
                            else
                            {
                                ActionShock actionShock = new ActionShock(0.5f, cast.boltShockDuration, imbueRagdollEffect);
                                component.ragdoll.creature.brain.TryAction(actionShock, true);
                            }
                        }
                    }
                }
            }
        }
        public override bool BulletCanDestory(MaterialThing thing)
        {
            Duck?duck = thing switch
            {
                Duck d when d != BulletSafeDuck => d,
                RagdollPart ragdollPart => ragdollPart.duck,
                _ => null,
            };

            if (duck is null)
            {
                goto notDuck;
            }

            duck.onFire = true;
            return(false);

notDuck:
            return(base.BulletCanDestory(thing));
        }
コード例 #8
0
        public IEnumerator HeavenLightningOnRagdollPart(RagdollPart ragdollPart, float timeout)
        {
            var startTime = Time.time;

            while (Time.time - startTime <= timeout)
            {
                yield return(new WaitForSeconds(1));
            }

            var heaven = ragdollPart.transform.position + 5 * Vector3.up;

            _lightningItemData.SpawnAsync(
                lightningItem =>
            {
                lightningItem.transform.position = heaven;
                GameManager.local.StartCoroutine(FallingLightning(lightningItem, ragdollPart));
            }, heaven,
                Quaternion.identity);

            yield return(null);
        }
コード例 #9
0
    private void Awake()
    {
        if (this.generateRagdollPartComponenets)
        {
            // Add RagdollPart components to all of the pieces.
            foreach (Rigidbody rb in this.GetComponentsInChildren <Rigidbody>())
            {
                if (rb.transform != this.transform)  // Ignore if there is a RB on this object, only look at children.
                {
                    RagdollPart part = rb.gameObject.GetComponent <RagdollPart>();
                    if (part == null)
                    {
                        // Add a script
                        if (this.script != null)
                        {
                            // Add the user defined component.
                            rb.gameObject.AddComponent(Type.GetType(this.script));
                        }
                        else
                        {
                            // Add the basic component.
                            rb.gameObject.AddComponent <RagdollPart>();
                        }
                    }
                }
            }
        }

        this.parts = this.GetComponentsInChildren <RagdollPart>();

        if (this.hasGeneralCollider)
        {
            // Disable all of the more specific colliders.
            foreach (RagdollPart part in this.parts)
            {
                part.colliderComponent.enabled = false;
            }
        }
    }
コード例 #10
0
            internal static bool Prefix(Damager __instance, Collider targetCollider, Vector3 impulseVelocity, Vector3 contactPoint, BS.Ragdoll ragdoll)
            {
                if (TimeController.Instance.IsTimeFrozen)
                {
                    if (ragdoll != null)
                    {
                        Vector3 localContactPoint = targetCollider.attachedRigidbody.transform.InverseTransformPoint(contactPoint);
                        Vector3 velocity          = __instance.data.addForceNormalize ? impulseVelocity.normalized : impulseVelocity;
                        using (List <RagdollPart> .Enumerator enumerator = ragdoll.parts.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                RagdollPart ragdollPart = enumerator.Current;
                                if (ragdollPart.HasCollider(targetCollider) && __instance.data.addForceRagdollPartMultiplier > 0f)
                                {
                                    Vector3 force = velocity * __instance.data.addForce * __instance.data.addForceRagdollPartMultiplier * Time.fixedDeltaTime;
                                    var     store = ragdollPart.rb.gameObject.GetComponent <StoredPhysicsData>();
                                    if (store)
                                    {
                                        store.velocity += force / ragdollPart.rb.mass;
                                    }
                                }
                                else if (__instance.data.addForceRagdollOtherMultiplier > 0f)
                                {
                                    Vector3 force = velocity * __instance.data.addForce * __instance.data.addForceRagdollOtherMultiplier * Time.fixedDeltaTime;
                                    var     store = ragdollPart.rb.gameObject.GetComponent <StoredPhysicsData>();
                                    if (store)
                                    {
                                        store.velocity += force / ragdollPart.rb.mass;
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }
コード例 #11
0
ファイル: DarkChains.cs プロジェクト: Ebediam/DarkChains
        public static void DarkChainDestroy(Item chain, RagdollPart ragdollPart, RagdollHandle ragdollHandle, bool neck)
        {
            DestroySelf.Destroy(chain.gameObject);

            if (ragdollPart.ragdoll.parts.Count > 0)
            {
                foreach (RagdollPart part in ragdollPart.ragdoll.parts)
                {
                    part.rb.isKinematic = false;
                }
            }

            if (ragdollHandle.ragdollPart.ragdoll.parts.Count > 0)
            {
                foreach (RagdollPart part in ragdollHandle.ragdollPart.ragdoll.parts)
                {
                    part.rb.isKinematic = false;
                }
            }


            if (ragdollHandle.name == "NPC(neck)(chained)")
            {
                ragdollHandle.name = "NPC(neck)";
            }
            else if (ragdollHandle.name == "NPC(chained)")
            {
                ragdollHandle.name = "NPC";
            }
            else
            {
                Debug.Log("The ragdollHandle was neither the neck nor a default part");
            }

            //ragdollPart.ragdoll.RefreshFall();
            ragdollPart.ragdoll.allowStandUp = true;
            ragdollHandle.tag = "Untagged";
        }
コード例 #12
0
        public IEnumerator FallingLightning(Item lightningItem, RagdollPart ragdollPart)
        {
            lightningItem.Hide(true);
            lightningItem.SetColliderAndMeshLayer(GameManager.GetLayer(LayerName.MovingObject));
            lightningItem.rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            lightningItem.isThrowed = true;
            lightningItem.isFlying  = true;

            while (lightningItem.imbues.Count == 0)
            {
                yield return(new WaitForFixedUpdate());
            }

            lightningItem.imbues[0].Transfer(Catalog.GetData <SpellCastCharge>("Lightning"),
                                             lightningItem.imbues[0].maxEnergy);

            var startTime = Time.time;

            while (!lightningItem.isPenetrating)
            {
                if (Time.time - startTime <= 30)
                {
                    var position  = ragdollPart.transform.position;
                    var direction = (position - lightningItem.transform.position).normalized;
                    lightningItem.rb.velocity         = 30 * direction;
                    lightningItem.transform.rotation *=
                        Quaternion.FromToRotation(lightningItem.flyDirRef.forward, direction);

                    yield return(new WaitForFixedUpdate());
                }
            }

            lightningItem.Despawn(10);

            yield return(null);
        }
コード例 #13
0
 public static bool ShouldAffectRigidbody(Rigidbody rb)
 {
     if (rb == null)
     {
         return(false);
     }
     try {
         bool rigidbodyConditions = (rb.gameObject.layer != GameManager.GetLayer(LayerName.NPC)) &&
                                    !rb.isKinematic;
         Item item           = rb.gameObject.GetComponent <Item>();
         bool itemConditions = item != null && (!item.isTelekinesisGrabbed &&
                                                item.handlers.Count == 0 &&
                                                !item.isGripped &&
                                                item.itemId != "BlackHoleSphere" &&
                                                item.itemId != "WhiteHoleSphere"
                                                );
         RagdollPart ragdoll           = rb.gameObject.GetComponent <RagdollPart>();
         bool        ragdollConditions = ragdoll == null;
         return(rigidbodyConditions && itemConditions && ragdollConditions);
     } catch (NullReferenceException e) {
         Debug.LogError(e.Data);
         return(false);
     }
 }
コード例 #14
0
        IEnumerator Burn(RagdollPart ragdollPart, CollisionStruct collisionStruct)
        {
            Burning burning = ragdollPart.gameObject.AddComponent <Burning>();

            Creature   creature         = ragdollPart.ragdoll.creature;
            float      duration         = UnityEngine.Random.Range(burnDuration.x, burnDuration.y);
            float      startTime        = Time.time;
            GameObject burningParticles = GameObject.Instantiate(onFireFX, ragdollPart.transform);

            burningParticles.transform.localPosition = new Vector3(0, 0, 0);

            FXPlayer.StartAllFxOnObject(burningParticles);



            int i = 0;

            while ((Time.time - startTime) < duration)
            {
                if (i >= 4)
                {
                    i = 0;
                }
                CollisionStruct collisionStruct1 = new CollisionStruct(new DamageStruct(Damager.DamageType.Poison, fireDamage), null, null, null, null, null, null, null);
                creature.health.Damage(ref collisionStruct1);
                i++;
                yield return(new WaitForSeconds(0.5f));
            }

            FXPlayer.StopAllFxOnObject(burningParticles);

            yield return(new WaitUntil(() => !burningParticles.GetComponentInChildren <ParticleSystem>().isPlaying));

            Destroy(burning);
            Destroy(burningParticles);
        }
コード例 #15
0
 private void Start()
 {
     _ragdollPart = GetComponent <RagdollPart>();
     _ragdollPart.rb.isKinematic = true;
 }
        private void OnCollisionEnter(Collision hit)
        {
            hitCreature = hit.transform.root.GetComponentInChildren <Creature>();
            if (hitCreature != null)
            {
                Debug.Log("Hit Creature: " + hitCreature.name);
                Debug.Log("Hit Collider: " + hit.collider.name);
                Debug.Log("Hit Transform: " + hit.transform.name);
                Debug.Log("Hit GameObject: " + hit.gameObject.name);
                Debug.Log(string.Format("[ON HIT] Creature Health:{0} isKilled:{1} isPooled:{2}", hitCreature.currentHealth, hitCreature.isKilled, hitCreature.pooled));
                hitPart = hit.transform.GetComponentInChildren <RagdollPart>();

                if (hitPart != null)
                {
                    Debug.Log("Hit Part: " + hitPart.name);

                    thisCollision = new CollisionInstance(new DamageStruct(DamageType.Pierce, 99999f), (MaterialData)bladeMaterial, (MaterialData)fleshMaterial)
                    {
                        contactPoint  = hit.collider.transform.position,
                        contactNormal = Quaternion.LookRotation(Player.local.head.transform.position).eulerAngles
                    };

                    foreach (CollisionHandler collisionHandler in item.collisionHandlers)
                    {
                        foreach (Damager damager1 in collisionHandler.damagers)
                        {
                            Debug.Log("Sending Penetrate on damager: " + damager1.name);
                            damager1.Penetrate(thisCollision, false);
                        }
                    }
                    Debug.Log(string.Format("[AFTER PENETRATE] Creature Health:{0} isKilled:{1} isPooled:{2}", hitCreature.currentHealth, hitCreature.isKilled, hitCreature.pooled));

                    Debug.Log("Removing Creature Pool Status");
                    hitCreature.pooled = false;

                    Debug.Log("Damaging Creature with collision....");
                    hitCreature.Damage(thisCollision);
                    Debug.Log(string.Format("[AFTER DAMAGE] Creature Health:{0} isKilled:{1} isPooled:{2}", hitCreature.currentHealth, hitCreature.isKilled, hitCreature.pooled));

                    //if (SplatterEffect != null)
                    //{
                    //    Debug.Log("Playing Splatter Effect");
                    //    SplatterEffect.transform.parent = hitPart.transform;
                    //    SplatterEffect.Play();
                    //}
                    //hitCreature.pooled = false;
                    //hitCreature.Kill();
                    //hitCreature.Despawn(5.0f);
                    //item.Despawn(0.5f);
                    //hitCreature.locomotion.rb.AddExplosionForce(10.0f, hitCreature.transform.position, 1.5f, 1.0f, ForceMode.Impulse);
                    //hitPart.rb.AddExplosionForce(10.0f, hitCreature.transform.position, 1.5f, 1.0f, ForceMode.Impulse);
                    //if ((hitPart.name.Contains("Arm") || hitPart.name.Contains("Hand") || hitPart.name.Contains("Leg"))) hitPart.Slice();
                    //thisCollision = new CollisionInstance(new DamageStruct(DamageType.Pierce, 99999f), (MaterialData)bladeMaterial, (MaterialData)fleshMaterial)
                    //{
                    //    contactPoint = hit.collider.transform.position
                    //};
                    //thisCollision.SpawnEffect(bladeMaterial, fleshMaterial, false, out thisEffect);
                    //thisCollision.NewHit(item.colliderGroups[0].colliders[0], hit.collider, hit.collider.transform.GetComponent<ColliderGroup>(), item.colliderGroups[0], item.transform.forward * 25.0f, hit.contacts[0].point, hit.contacts[0].normal, 2.0f, bladeMaterial, fleshMaterial);
                    //hitCreature.Damage(thisCollision);

                    ////hitCreature.ragdoll.SetState(Ragdoll.State.Inert);
                    ////hitCreature.isKilled = true;
                }
            }

            if (item.rb.useGravity)
            {
                return;
            }
            else
            {
                item.rb.useGravity = true; isFlying = false;
                // Debug.Log("[PROJECTILE] Collsion with: " + hit.collider.name);
            }
        }