예제 #1
0
        public override void SetupController(TraitController controller)
        {
            base.SetupController(controller);
            var hitboxFilter = HitboxController.GenerateHitboxFilter(_hitbox, _collisionLayer);

            _controller.gameObject.SendMessageWithFilterTo(new HitboxCheckMessage {
                DoAfter = hitboxController =>
                {
                    _hitboxController = hitboxController;
                }
            }, _controller.transform.parent.gameObject, hitboxFilter);
            if (!_hitboxController)
            {
                _hitboxController = Instantiate(_hitbox.Controller, _controller.transform.parent);
                _hitboxController.Setup(_hitbox, _collisionLayer);
            }
            _register = _applyToTargetOnEnter.Length > 0 || _applyToTargetOnExit.Length > 0 || _applyToSelfOnEnter.Length > 0 || _applyToSelfOnExit.Length > 0;
            if (_register)
            {
                _traitCheckMsg.TraitsToCheck = _requiredTraits;
                _controller.gameObject.SendMessageTo(new RegisterCollisionMessage {
                    Object = _controller.gameObject
                }, _hitboxController.gameObject);
                SubscribeToMessages();
            }
        }
예제 #2
0
        public override void SetupController(TraitController controller)
        {
            base.SetupController(controller);
            var hitboxFilter = HitboxController.GenerateHitboxFilter(_hitbox, CollisionLayerFactory.AGGRO);

            _controller.gameObject.SendMessageWithFilterTo(new HitboxCheckMessage {
                DoAfter = hitboxController =>
                {
                    _hitboxController = hitboxController;
                }
            }, _controller.transform.parent.gameObject, hitboxFilter);
            if (!_hitboxController)
            {
                _hitboxController = Instantiate(_hitbox.Controller, _controller.transform.parent);
                _hitboxController.Setup(_hitbox, CollisionLayerFactory.AGGRO);
            }
            _controller.gameObject.SendMessageTo(new RegisterCollisionMessage {
                Object = _controller.gameObject
            }, _hitboxController.gameObject);
            SubscribeToMessages();
        }