Exemple #1
0
    public void ReportCollideEvent(Transform self, ColliderEventType colliderEventType)
    {
        switch (self.name)
        {
        case "TopCollider" when colliderEventType == ColliderEventType.enter:
        case "TopCollider" when colliderEventType == ColliderEventType.stay:
            TopColliding = true;
            break;

        case "TopCollider" when colliderEventType == ColliderEventType.exit:
            TopColliding = false;
            break;

        case "MidCollider" when colliderEventType == ColliderEventType.enter:
        case "MidCollider" when colliderEventType == ColliderEventType.stay:
            MidColliding = true;
            break;

        case "MidCollider" when colliderEventType == ColliderEventType.exit:
            MidColliding = false;
            break;

        case "BottomCollider" when colliderEventType == ColliderEventType.enter:
        case "BottomCollider" when colliderEventType == ColliderEventType.stay:
            BottomColliding = true;
            break;

        case "BottomCollider" when colliderEventType == ColliderEventType.exit:
            BottomColliding = false;
            break;

        default:
            break;
        }
    }
Exemple #2
0
        private void SendCollisionEvent(ColliderEventType eventType, UnityCollision collision)
        {
            var otherActor = collision.collider.gameObject.GetComponent <Actor>();

            if (otherActor != null && otherActor.App.InstanceId == _ownerActor.App.InstanceId)
            {
                var sceneRoot = _ownerActor.App.SceneRoot.transform;

                var contacts = collision.contacts.Select((contact) =>
                {
                    return(new MREContactPoint()
                    {
                        Normal = sceneRoot.InverseTransformDirection(contact.normal).ToMWVector3(),
                        Point = sceneRoot.InverseTransformPoint(contact.point).ToMWVector3(),
                        Separation = contact.separation
                    });
                });

                var collisionData = new CollisionData()
                {
                    otherActorId     = otherActor.Id,
                    Contacts         = contacts,
                    Impulse          = sceneRoot.InverseTransformDirection(collision.impulse).ToMWVector3(),
                    RelativeVelocity = collision.relativeVelocity.ToMWVector3()
                };

                _ownerActor.App.EventManager.QueueEvent(
                    new CollisionEvent(_ownerActor.Id, eventType, collisionData));
            }
        }
Exemple #3
0
 void Broadcast <T>(ColliderEventType type, T param)
 {
     if (type == m_type)
     {
         DoEvent();
     }
 }
        public void OnColliderExitEvent(GameObject gameObject)
        {
            if (gameObject.name != "LocalPlayer")
            {
                return;
            }

            curEventType |= ColliderEventType.EXIT;
        }
        public void OnColliderStayEvent(GameObject gameObject)
        {
            if (gameObject.name != "LocalPlayer")
            {
                return;
            }

            curEventType |= ColliderEventType.STAY;
        }
Exemple #6
0
        private void SendTriggerEvent(ColliderEventType eventType, UnityCollider otherCollider)
        {
            var otherActor = otherCollider.gameObject.GetComponent <Actor>();

            if (otherActor != null && otherActor.App.InstanceId == _ownerActor.App.InstanceId)
            {
                _ownerActor.App.EventManager.QueueEvent(
                    new TriggerEvent(_ownerActor.Id, eventType, otherActor.Id));
            }
        }
        protected override bool Check()
        {
            bool bRet = false;

            if ((curEventType & EventType) > 0)
            {
                curEventType = ColliderEventType.NONE;
                bRet         = true;
            }
            return(bRet);
        }
        private void SendTriggerEvent(ColliderEventType eventType, UnityCollider otherCollider)
        {
            if (!_ownerActor.App.IsAuthoritativePeer && !_ownerActor.IsGrabbed)
            {
                return;
            }

            var otherActor = otherCollider.gameObject.GetComponent <Actor>();

            if (otherActor != null && otherActor.App.InstanceId == _ownerActor.App.InstanceId)
            {
                _ownerActor.App.EventManager.QueueEvent(
                    new TriggerEvent(_ownerActor.Id, eventType, otherActor.Id));
            }
        }
Exemple #9
0
        internal void ApplyPatch(ColliderPatch patch)
        {
            _collider.enabled   = _collider.enabled.GetPatchApplied(IsEnabled.ApplyPatch(patch.IsEnabled));
            _collider.isTrigger = _collider.isTrigger.GetPatchApplied(IsTrigger.ApplyPatch(patch.IsTrigger));

            if (patch.EventSubscriptions != null)
            {
                // Clear existing subscription flags and set them to the new values.  We do not patch arrays,
                // and thus we will always send the entire value down for all of the subscriptions.
                _colliderEventSubscriptions = ColliderEventType.None;
                foreach (var sub in patch.EventSubscriptions)
                {
                    _colliderEventSubscriptions |= sub;
                }
            }
        }
        internal void ApplyPatch(ColliderPatch patch)
        {
            _collider.enabled                  = _collider.enabled.GetPatchApplied(IsEnabled.ApplyPatch(patch.Enabled));
            _collider.isTrigger                = _collider.isTrigger.GetPatchApplied(IsTrigger.ApplyPatch(patch.IsTrigger));
            _collider.material.bounciness      = _collider.material.bounciness.GetPatchApplied(Bounciness.ApplyPatch(patch.Bounciness));
            _collider.material.staticFriction  = _collider.material.staticFriction.GetPatchApplied(StaticFriction.ApplyPatch(patch.StaticFriction));
            _collider.material.dynamicFriction = _collider.material.dynamicFriction.GetPatchApplied(DynamicFriction.ApplyPatch(patch.DynamicFriction));

            MREAPI.AppsAPI.LayerApplicator.ApplyLayerToCollider(patch.Layer, _collider);

            if (patch.EventSubscriptions != null)
            {
                // Clear existing subscription flags and set them to the new values.  We do not patch arrays,
                // and thus we will always send the entire value down for all of the subscriptions.
                _colliderEventSubscriptions = ColliderEventType.None;
                foreach (var sub in patch.EventSubscriptions)
                {
                    _colliderEventSubscriptions |= sub;
                }
            }
        }
        public void HandleEnvironmentCollider(Collider _collider, ColliderEventType _type, string _contact = "")
        {
            if (Status.IsDead)
            {
                return;
            }

            if (Environment.CollisionHandler.Enabled)
            {
                List <CollisionDataObject> _collisions = Environment.CollisionHandler.CheckCollider(_collider, _contact);
                foreach (CollisionDataObject _data in _collisions)
                {
                    if (_data != null)
                    {
                        if (_type == ColliderEventType.ENTER)
                        {
                            _data.Influences.Start();
                        }
                        else if (_type == ColliderEventType.EXIT)
                        {
                            _data.Influences.Stop(OwnerComponent);
                        }
                        else if (_type == ColliderEventType.HIT)
                        {
                            UpdateStatusInfluences(_data.Influences);
                        }
                        else if (_data.Influences.Update())
                        {
                            UpdateStatusInfluences(_data.Influences);
                        }


                        if (_data.BehaviourModeKey != "")
                        {
                            SetActiveBehaviourModeByKey(_data.BehaviourModeKey);
                        }
                    }
                }
            }
        }
 internal TriggerEvent(Guid actorId, ColliderEventType eventType, Guid otherActor)
     : base(actorId)
 {
     _eventType  = eventType;
     _otherActor = otherActor;
 }
 internal CollisionEvent(Guid actorId, ColliderEventType eventType, CollisionData collisionData)
     : base(actorId)
 {
     _eventType     = eventType;
     _collisionData = collisionData;
 }
 public ColliderEventCondition()
 {
     curEventType = ColliderEventType.NONE;
     EventType    = ColliderEventType.ENTER;
 }