Exemplo n.º 1
0
        void OnRbTouchStay(Collision collision, BoneModel bone)
        {
            stayedContact = model.contacts.Find(c => c.contactable.pheasy.rb == collision.rigidbody);

            if (stayedContact == null || stayedContact.contactable == null)
            {
                return;
            }

            stayedContactable = stayedContact.contactable;

            if (stayedContactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == stayedContactable);

                if (contact != null)
                {
                    BoneCollisionModel boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision != null)
                    {
                        collision.GetContacts(boneCollision.points);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void OnRbTouchStart(Collision collision, BoneModel bone)
        {
            ContactableView contactable = collision.rigidbody.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                BoneCollisionModel boneCollision;

                if (contact != null)
                {
                    // Existing contact

                    boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision == null)
                    {
                        boneCollision = new BoneCollisionModel(bone);
                        collision.GetContacts(boneCollision.points);
                        contact.bonesTouching.Add(boneCollision);
                    }
                }
                else
                {
                    // New valid contact
                    contact      = AddContact(contactable);
                    contact.type = ContactType.None;

                    boneCollision = new BoneCollisionModel(bone);
                    collision.GetContacts(boneCollision.points);
                    contact.bonesTouching.Add(boneCollision);
                }
            }
        }
Exemplo n.º 3
0
        void OnRbEnter(Rigidbody enteredRb, BoneModel bone)
        {
            ContactableView contactable = enteredRb.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                if (contact != null)
                {
                    // Existing contact
                    if (!contact.bonesEntered.Contains(bone))
                    {
                        contact.bonesEntered.Add(bone);
                    }
                }
                else
                {
                    // New valid contact
                    contact      = AddContact(contactable);
                    contact.type = ContactType.None;
                    contact.bonesEntered.Add(bone);
                }
            }
        }
Exemplo n.º 4
0
        Contact AddContact(ContactableView contactable)
        {
            Contact contact = new Contact();

            contact.detector    = model;
            contact.contactable = contactable;

            contact.name = contact.contactable.name;

            model.contacts.Add(contact);
            contactable.AddContact(contact);

            return(contact);
        }
Exemplo n.º 5
0
        void OnRbTouchEnd(Collision collision, BoneModel bone)
        {
            ContactableView contactable = collision.rigidbody.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                if (contact != null)
                {
                    BoneCollisionModel boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision != null)
                    {
                        contact.bonesTouching.Remove(boneCollision);
                    }
                }
            }
        }
Exemplo n.º 6
0
        void OnRbExit(Rigidbody exitedRb, BoneModel bone)
        {
            ContactableView contactable = exitedRb.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                if (contact != null)
                {
                    // Existing contact
                    if (contact.bonesEntered.Contains(bone))
                    {
                        bool stillEntered = false;

                        /*
                         * PuppetReprModel slave = bone.reprs.FirstOrDefault(r => r.Value is PuppetReprModel).Value as PuppetReprModel;
                         * PuppetReprModel slave = BasicHelpers.Get<ReprModel, PuppetReprModel>(bone.reprs);
                         */

                        PuppetReprModel slave = bone.reprs[PuppetModel.key] as PuppetReprModel;

                        // Remove bone only if exitedRb is not in any bone.pheasy.triggerNotifiers
                        for (int tn = 0; tn < slave.pheasy.triggerNotifiers.Length; tn++)
                        {
                            if (slave.pheasy.triggerNotifiers[tn].enteredRbs.Contains(exitedRb))
                            {
                                stillEntered = true;
                                break;
                            }
                        }

                        if (!stillEntered)
                        {
                            contact.bonesEntered.Remove(bone);
                        }
                    }
                }
            }
        }