﻿using Box2DX.Dynamics;
using Microsoft.Xna.Framework;
using Xna = Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MonoGameLib;

namespace OGPCPrototype
{
    //Holds the info for storing and drawing a static wall
    struct Wall
    {
        public Texture2D Texture;
        public Rectanglef Extents;
        public Rectangle TextureSource;
        public Xna.Color Color;
        public Body PhysicsBody;
        
        public Wall(World physics, Texture2D texture, Rectanglef extents, Rectangle? textureSource = null, Xna.Color? color = null)
        {
            Texture = texture;
            Extents = extents;
            TextureSource = textureSource ?? texture.Bounds;
            Color = color ?? Xna.Color.White;

            BodyDef bodyDef = new BodyDef();
            bodyDef.MassData.I = 0;
            bodyDef.MassData.Mass = 0;
            bodyDef.Position = extents.Center.ToVec2();
            PhysicsBody = physics.CreateBody(bodyDef);

            PolygonDef bodyFixture = new PolygonDef();
            bodyFixture.VertexCount = 4;
            bodyFixture.SetAsBox(extents.Width / 2, extents.Height / 2);
            bodyFixture.Density = 0;
            PhysicsBody.CreateFixture(bodyFixture);
        }
    }
}
