Example #1
0
        /// <summary>
        /// mutates an item in the eviction condition store, and returns true if it's not flagged for eviction
        /// </summary>
        /// <param name="soId"></param>
        /// <returns></returns>
        protected bool TouchExpirable(StoredObjectId soId)
        {
            if (soId == null)
            {
                return(false);
            }

            bool isExpired = false;
            //get the item's condition from the condition store
            var record = this.ExpirableStore.Get <ContextualId <StoredObjectId, IExpirable> >(soId);

            //if the eviction condition is touchable, touch it
            if (record != null && record.Context != null)
            {
                isExpired = record.Context.IsExpired();

                //if the expirable is touchable, touch it
                if (record.Context is ITouchable)
                {
                    ITouchable touch = (ITouchable)record.Context;
                    touch.Touch();
                }
                else if (record.Context is IPolyfacing) //or if it's polyfacing with a touchable face
                {
                    IPolyfacing poly  = (IPolyfacing)record.Context;
                    var         touch = poly.RootFace.AsHasTouchable();
                    if (touch != null)
                    {
                        touch.Touch();
                    }
                }
            }
            return(!isExpired);
        }
Example #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        currentActionable = other.gameObject;
        ITouchable touchable = currentActionable.GetComponent <ITouchable>();

        if (touchable != null)
        {
            touchable.Touch();
        }
    }
Example #3
0
        public void WillOmitSelfFromCollection()
        {
            IMutablePicoContainer pico = GetDefaultPicoContainer();

            pico.RegisterComponentImplementation(typeof(SimpleTouchable));
            pico.RegisterComponentImplementation(typeof(TouchableObserver));
            ITouchable observer = (ITouchable)pico.GetComponentInstanceOfType(typeof(TouchableObserver));

            Assert.IsNotNull(observer);
            observer.Touch();
            SimpleTouchable touchable = (SimpleTouchable)pico.GetComponentInstanceOfType(typeof(SimpleTouchable));

            Assert.IsTrue(touchable.WasTouched);
        }
Example #4
0
        public static TouchResponseData TouchGameObject(TouchData touchData, object subject)
        {
            ITouchable touchable = ExtractTouchable(subject);

            if (touchable != null)
            {
                return(touchable.Touch(touchData));
            }

            /*IActor actor = ExtractActor(subject);
             * if (actor != null)
             * {
             *  return actor.ActorTouch(touchData);
             * }*/
            return(TouchResponseData.block);
        }
		public DependsOnTouchable(ITouchable touchable)
		{
			Assert.IsNotNull(touchable, "Touchable cannot be passed in as null");
			touchable.Touch();
			this.touchable = touchable;
		}
 public void Touch()
 {
     theDelegate.Touch();
 }
 public DependsOnTouchable(ITouchable touchable)
 {
     Assert.IsNotNull(touchable, "Touchable cannot be passed in as null");
     touchable.Touch();
     this.touchable = touchable;
 }