using UnityEngine;
using GadgetCore.API;
using UnityEngine.SceneManagement;
using System.Reflection;
using GadgetCore.API.ConfigMenu;
using System;
using ScrapYard.API;

namespace ShipDecorations
{
  [Gadget("ShipDecorations", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" }, LoadPriority: 100)]
  public class ShipDecorations : Gadget<ShipDecorations>
  {
    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
    public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.

    public override IGadgetConfigMenu GetConfigMenu() { return null; }
    protected override void LoadConfig() { Config.Reset(); Config.Save(); }

    public override string GetModDescription()
    {
      return "A mod that adds some more ship decorations.";
    }

    protected override void Initialize()
    {
      Logger.Log("Ship Decorations v" + Info.Mod.Version);
      Core.logger = Logger;

      var lightsPlatform = new ShopPlatform("Decorations").Register();

      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cBed.png", "iBed.png", "Bed"), 1000));
      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cPlant0Plant.png", "iPlant0Plant.png", "Bush Plant"), 1000));
      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cTree5Plant.png", "iTree5Plant.png", "Tree Plant"), 1000));
      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cTreantHeadPlant.png", "iTreantHeadPlant.png", "Treant Plant"), 2, 1, ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy")));
      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableSlideDoorItem("cDoor.png", "cDoorOpen.png", "iDoor.png", "Door"), 1000));

      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cWindowScrapWall.png", "iWindowScrapWall.png", "Scrap Wall Window"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cTitaniumWall.png", "iTitaniumWall.png", "Titaniu Wall"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cTitaniumWindow.png", "iTitaniumWindow.png", "Titaniu Window"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cHiveWall.png", "iHiveWall.png", "Hive Wall"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cHiveWindow.png", "iHiveWindow.png", "Hive Window"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cStealWall.png", "iStealWall.png", "Steal Wall"), 10));
      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cStealWindow.png", "iStealWindow.png", "Steal Window"), 10));

      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateBlockItem("cStealBlock.png", "iStealBlock.png", "Steal Block"), 10));

      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableStairsItemL("cStairs.png", "iStairs.png", "Stairs [L]", "StairsL"), 10));
      lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableStairsItemR("cStairsR.png", "iStairsR.png", "Stairs [R]", "StairsR"), 10));

      { // Part Engine Blue
        var asset = GadgetCoreAPI.LoadAssetBundle("engine");
        var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineBlue.prefab"));
        engine.name = "engineBlue";
        engine.transform.localScale = new Vector3(2, 2, 2);
        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineBlue", engine);
      }
      { // Part Engine Yellow
        var asset = GadgetCoreAPI.LoadAssetBundle("engine");
        var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineYellow.prefab"));
        engine.name = "engineYellow";
        engine.transform.localScale = new Vector3(2, 2, 2);
        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineYellow", engine);
      }
      { // Part Engine Red
        var asset = GadgetCoreAPI.LoadAssetBundle("engine");
        var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineRed.prefab"));
        engine.name = "engineRed";
        engine.transform.localScale = new Vector3(2, 2, 2);
        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineRed", engine);
      }
      { // Part Engine Green
        var asset = GadgetCoreAPI.LoadAssetBundle("engine");
        var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineGreen.prefab"));
        engine.name = "engineGreen";
        engine.transform.localScale = new Vector3(2, 2, 2);
        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineGreen", engine);
      }

      foreach (var e in ShopPlatform.DefaultObjects.GetShopPlatformEntries())
      {
        if (e.ItemID == 2400)
        {
          ShopPlatform.DefaultBlocks.RemoveShopPlatformEntry(e);
        }
      }

      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cBlueEngineBlock.png", "iBlueEngineBlock.png", "engineBlue", "Plasma Engine", "An engine for a ship.", "BlueEngineBlock"), 10));
      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cYellowEngineBlock.png", "iYellowEngineBlock.png", "engineYellow", "Differential Engine", "An engine for a ship.", "YellowEngineBlock"), 10));
      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateOverrideEngineItem("cRedEngineBlock.png", "iRedEngineBlock.png", "engineRed", "Combustion Engine", "An engine for a ship.", "RedEngineBlock"), 10));
      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cGreenEngineBlock.png", "iGreenEngineBlock.png", "engineGreen", "Burst Engine", "An engine for a ship.", "GreenEngineBlock"), 10));

    }
  }
}
