Esempio n. 1
0
        public static uint CreateTile(MainSystem mainSystem, TileBluePrint tileBluePrint, Vector2 relativPosition, Vector2 tileDimensions)
        {
            uint id = mainSystem.CreateEntityID();
            Vector2 position = new Vector2(relativPosition.X * tileDimensions.X, relativPosition.Y * tileDimensions.Y);

            mainSystem.GetRenderSystem<Texture2DRenderSystem>().CreateTexture2DRenderNode(id, tileBluePrint.Texture2D);
            mainSystem.GetComponent<Position2DComponent>(id).Origin = new Vector2(tileDimensions.Y / 2, tileDimensions.X / 2);
            mainSystem.GetComponent<Position2DComponent>(id).Position = position;

            if (tileBluePrint.HitBoxOutline != null)
            {
                mainSystem.GetRenderSystem<HitBoxRenderSystem>().CreateHitBoxRenderNode(id, tileBluePrint.HitBoxOutline);
                mainSystem.GetComponent<HitBox2DComponent>(id).Position = position;
                mainSystem.GetUpdateSystem<HitBoxCollisionUpdateSystem>().CreateHitBoxCollisionUpadateNode(id, tileBluePrint.HitBoxOutline, null);
                mainSystem.GetComponent<HitBox2DComponent>(id).Position = position;

            }
            
            return id;
        }