using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;

using TInput = System.String;
using TOutput = GhostArena3DCustomContent.GhostArena3DCompiledData;

namespace GhostArena3DCustomContent
{
   [ContentProcessor(DisplayName = "GhostArena3DCustomContent.GhostArena3DProcessor")]
   public class GhostArena3DProcessor : ContentProcessor<TInput, TOutput>
   {
      public override TOutput Process(TInput input, ContentProcessorContext context)
      {
         char[] delimiters = { ',', ' ' };
         string[] tokens = input.Split(delimiters);

         int totalPaths = (tokens.Length / 3);
         int tokIndex = 0;
         
         if(totalPaths < 1)
         {
            throw new Exception("Must specify at least one valid spawn!");
         }
         
         Vector3[] pathList = new Vector3[totalPaths];
         
         for(int i = 0; i < totalPaths; i++)
         {
            pathList[i] = new Vector3(Convert.ToSingle(tokens[tokIndex++]),
                                      Convert.ToSingle(tokens[tokIndex++]),
                                      Convert.ToSingle(tokens[tokIndex++]));
         }

         return new GhostArena3DCompiledData(pathList);
      }
   }
}