void PortalHandler(Entity e, GameObjectTypeInfo obj, TiledMapObject tiled)
 {
     e.Set(new Trigger
     {
         Invoke = (action, entity) =>
         {
             var destination = tiled.Properties["destination"];
             GameContext.LoadMap(destination);
         }
     });
     e.Set(new Cursor("hand", new Rectangle(-16, -16, 32, 32)));
 }
        void ChestHandler(Entity e, GameObjectTypeInfo obj, TiledMapObject tiled)
        {
            e.Set(GameObjectType.Storage);
            e.Set(new Blocking());
            var storage = new Storage();

            foreach (var prop in tiled.Properties.Where(e => e.Key.StartsWith('~')))
            {
                var type         = GameObjectTypes[prop.Key.Substring(1)];
                var countInStack = int.Parse(prop.Value);
                if (countInStack == 0)
                {
                    continue;
                }

                while (countInStack > 0)
                {
                    if (type.StackSize < countInStack)
                    {
                        countInStack -= type.StackSize;
                        storage.Content.Add(new ItemStack
                        {
                            ItemType = type,
                            Count    = type.StackSize
                        });
                    }
                    else
                    {
                        storage.Content.Add(new ItemStack
                        {
                            ItemType = type,
                            Count    = countInStack,
                        });
                        break;
                    }
                }
            }

            e.Set(storage);
            e.Set(new Serializable());
            e.Set(new Cursor("hand", new Rectangle(-16, -16, 32, 32)));
        }
        void ActorHandler(Entity e, GameObjectTypeInfo type, TiledMapObject tiledMapObj)
        {
            if (type.TypeName == "player")
            {
                e.Set(new Storage());
                GameContext.Player = e;
                e.Set <IGameAI>(new PlayerControl());
            }
            if (type.TypeName == "enemy")
            {
                var sprite = e.Get <RenderingObject>();
                e.Set(new Cursor("sword", new Rectangle((int)sprite.Origin.X, (int)sprite.Origin.Y, sprite.Bounds.Width, sprite.Bounds.Height)));
                e.Set(GameObjectType.Enemy);
                e.Set <IGameAI>(new RandomMovement());
            }

            e.Set(new ActionPoints
            {
                Max    = 10,
                Remain = 10
            });
            e.Set(new Serializable());
            e.Set(new AllowedToAct());
        }