Zariteis vor 4 Jahren
Commit
66c244718a
47 geänderte Dateien mit 1738 neuen und 0 gelöschten Zeilen
  1. 512 0
      .gitignore
  2. 117 0
      API/ShopPlatform.cs
  3. 18 0
      API/ShopPlatformEntry.cs
  4. BIN
      Assets/bScrapYardbg0.png
  5. BIN
      Assets/bScrapYardbg1.png
  6. BIN
      Assets/bScrapYardbg2.png
  7. BIN
      Assets/bScrapYardbg3.png
  8. BIN
      Assets/bgScrapYard.png
  9. BIN
      Assets/bgScrapYardExtension.png
  10. BIN
      Assets/bgScrapYardTop.png
  11. BIN
      Assets/entranceScrapYard.png
  12. BIN
      Assets/iScrapTrophy.png
  13. BIN
      Assets/merchantBody.png
  14. BIN
      Assets/merchantHead.png
  15. BIN
      Assets/merchantPortrait.png
  16. BIN
      Assets/metalPlatform.png
  17. BIN
      Assets/metalPlatformClean.png
  18. BIN
      Assets/parallax.png
  19. BIN
      Assets/planetScrapYard.png
  20. BIN
      Assets/planetScrapYardPrev.png
  21. BIN
      Assets/planetScrapYard_old.png
  22. BIN
      Assets/planetSpacePrev.png
  23. BIN
      Assets/platform
  24. BIN
      Assets/rockPlatform.png
  25. BIN
      Assets/scrapYardStand.png
  26. BIN
      Assets/scrapYardStandInfo.png
  27. BIN
      Assets/scrapyardstand
  28. BIN
      Assets/shopStand.png
  29. BIN
      Assets/shopStand_blink.png
  30. BIN
      Assets/shopStand_old.png
  31. BIN
      Assets/shopStand_replaced.png
  32. BIN
      Assets/signScrapYard.png
  33. 9 0
      Core.cs
  34. 3 0
      Manifest.ini
  35. 1 0
      ModInfo.txt
  36. 33 0
      Patches/Patch_Chunk_OnDestroy.cs
  37. 23 0
      Patches/Patch_GameScript_Talk.cs
  38. 34 0
      Patches/Patch_KylockeStand_Awake.cs
  39. 10 0
      Properties/AssemblyInfo.cs
  40. 8 0
      Properties/launchSettings.json
  41. 15 0
      README.txt
  42. 337 0
      ScrapYard.cs
  43. 301 0
      ScrapYard.csproj
  44. 22 0
      ScrapYard.sln
  45. 35 0
      ScrapYardDecoBlinkScript.cs
  46. 119 0
      ScrapYardGenerator.cs
  47. 141 0
      ScrapYardShopStandScript.cs

+ 512 - 0
.gitignore

@@ -0,0 +1,512 @@
+### Csharp ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*[.json, .xml, .info]
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+### vs ###
+
+# User-specific files
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+
+# Mono auto generated files
+
+# Build results
+
+# Visual Studio 2015/2017 cache/options directory
+# Uncomment if you have tasks that create the project's static files in wwwroot
+
+# Visual Studio 2017 auto generated files
+
+# MSTest test Results
+
+# NUnit
+
+# Build Results of an ATL Project
+
+# Benchmark Results
+
+# .NET Core
+
+# StyleCop
+
+# Files built by Visual Studio
+
+# Chutzpah Test files
+
+# Visual C++ cache files
+
+# Visual Studio profiler
+
+# Visual Studio Trace Files
+
+# TFS 2012 Local Workspace
+
+# Guidance Automation Toolkit
+
+# ReSharper is a .NET coding add-in
+
+# TeamCity is a build add-in
+
+# DotCover is a Code Coverage Tool
+
+# AxoCover is a Code Coverage Tool
+
+# Coverlet is a free, cross platform Code Coverage Tool
+
+# Visual Studio code coverage results
+
+# NCrunch
+
+# MightyMoose
+
+# Web workbench (sass)
+
+# Installshield output folder
+
+# DocProject is a documentation generator add-in
+
+# Click-Once directory
+
+# Publish Web Output
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+
+# NuGet Packages
+# NuGet Symbol Packages
+# The packages folder can be ignored because of Package Restore
+# except build/, which is used as an MSBuild target.
+# Uncomment if necessary however generally it will be regenerated when needed
+# NuGet v3's project.json files produces more ignorable files
+
+# Microsoft Azure Build Output
+
+# Microsoft Azure Emulator
+
+# Windows Store app package directories and files
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+# but keep track of directories ending in .cache
+
+# Others
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+
+# RIA/Silverlight projects
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+
+# SQL Server files
+
+# Business Intelligence projects
+
+# Microsoft Fakes
+
+# GhostDoc plugin setting file
+
+# Node.js Tools for Visual Studio
+
+# Visual Studio 6 build log
+
+# Visual Studio 6 workspace options file
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+
+# Visual Studio LightSwitch build output
+
+# Paket dependency manager
+
+# FAKE - F# Make
+
+# CodeRush personal settings
+
+# Python Tools for Visual Studio (PTVS)
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+
+# Telerik's JustMock configuration file
+
+# BizTalk build output
+
+# OpenCover UI analysis results
+
+# Azure Stream Analytics local run output
+
+# MSBuild Binary and Structured Log
+
+# NVidia Nsight GPU debugger configuration file
+
+# MFractors (Xamarin productivity tool) working folder
+
+# Local History for Visual Studio
+
+# BeatPulse healthcheck temp database
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+
+# Ionide (cross platform F# VS Code tools) working folder

+ 117 - 0
API/ShopPlatform.cs

@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+
+namespace ScrapYard.API
+{
+  public class ShopPlatform
+  {
+    public readonly ShopPlatformSpacingType Type;
+
+    public readonly string Title;
+
+    internal List<ShopPlatformEntry> Entries = new List<ShopPlatformEntry>();
+
+    internal static Dictionary<string, ShopPlatform> ShopPlatforms = new Dictionary<string, ShopPlatform>();
+
+    public static ShopPlatform DefaultObjects
+    {
+      get => ShopPlatforms["DefaultObjects"];
+    }
+
+    public static ShopPlatform DefaultBlocks
+    {
+      get => ShopPlatforms["DefaultBlocks"];
+    }
+
+    public static ShopPlatform DefaultWalls
+    {
+      get => ShopPlatforms["DefaultWalls"];
+    }
+
+    public ShopPlatform(string title, ShopPlatformSpacingType spacingType = ShopPlatformSpacingType.Normal)
+    {
+      this.Type = spacingType;
+      this.Title = title;
+    }
+
+    public virtual ShopPlatform Register()
+    {
+      return Register(this.Title);
+    }
+
+    public virtual ShopPlatform Register(string id)
+    {
+      if (ShopPlatforms.ContainsKey(id))
+        ShopPlatforms.Remove(id);
+
+      ShopPlatforms.Add(id, this);
+      return this;
+    }
+
+    public ShopPlatformSpacingType GetShopPlatformSpacingType()
+    {
+      return Type;
+    }
+
+    public void AddShopPlatformEntry(ShopPlatformEntry row)
+    {
+      foreach (var e in Entries)
+        if (e.CurrencyItemID == row.CurrencyItemID
+          && e.ItemID == row.ItemID
+          && e.Quantity == row.Quantity
+          && e.Price == row.Price)
+          return;
+      Entries.Add(row);
+    }
+
+    public void RemoveShopPlatformEntry(ShopPlatformEntry row)
+    {
+      Entries.Remove(row);
+    }
+
+    public ShopPlatformEntry[] GetShopPlatformEntries()
+    {
+      return Entries.ToArray();
+    }
+
+    public static ShopPlatform[] GetShopPlatforms()
+    {
+      return new List<ShopPlatform>(ShopPlatforms.Values).ToArray();
+    }
+
+    internal int GetSpacesPerRow()
+    {
+      int spaces = 0;
+      switch (Type)
+      {
+        case ShopPlatformSpacingType.Normal:
+          spaces = 7;
+          break;
+        case ShopPlatformSpacingType.Near:
+          spaces = 13;
+          break;
+        case ShopPlatformSpacingType.Far:
+          spaces = 3;
+          break;
+      }
+      return spaces;
+    }
+
+    internal int GetRowsNeeded()
+    {
+      return ((Entries.Count - 1) / GetSpacesPerRow()) + 1;
+    }
+
+    internal static void Reset()
+    {
+      ShopPlatforms = new Dictionary<string, ShopPlatform>();
+    }
+  }
+
+  public enum ShopPlatformSpacingType
+  {
+    Normal,
+    Near,
+    Far
+  }
+}

+ 18 - 0
API/ShopPlatformEntry.cs

@@ -0,0 +1,18 @@
+namespace ScrapYard.API
+{
+  public class ShopPlatformEntry
+  {
+    public int ItemID { get; protected set; }
+    public int Price { get; protected set; }
+    public int Quantity { get; protected set; }
+    public int CurrencyItemID { get; protected set; }
+
+    public ShopPlatformEntry(int itemID, int price, int quantity = 1, int currencyItemID = 57)
+    {
+      this.ItemID = itemID;
+      this.Price = price;
+      this.CurrencyItemID = currencyItemID;
+      this.Quantity = quantity;
+    }
+  }
+}

BIN
Assets/bScrapYardbg0.png


BIN
Assets/bScrapYardbg1.png


BIN
Assets/bScrapYardbg2.png


BIN
Assets/bScrapYardbg3.png


BIN
Assets/bgScrapYard.png


BIN
Assets/bgScrapYardExtension.png


BIN
Assets/bgScrapYardTop.png


BIN
Assets/entranceScrapYard.png


BIN
Assets/iScrapTrophy.png


BIN
Assets/merchantBody.png


BIN
Assets/merchantHead.png


BIN
Assets/merchantPortrait.png


BIN
Assets/metalPlatform.png


BIN
Assets/metalPlatformClean.png


BIN
Assets/parallax.png


BIN
Assets/planetScrapYard.png


BIN
Assets/planetScrapYardPrev.png


BIN
Assets/planetScrapYard_old.png


BIN
Assets/planetSpacePrev.png


BIN
Assets/platform


BIN
Assets/rockPlatform.png


BIN
Assets/scrapYardStand.png


BIN
Assets/scrapYardStandInfo.png


BIN
Assets/scrapyardstand


BIN
Assets/shopStand.png


BIN
Assets/shopStand_blink.png


BIN
Assets/shopStand_old.png


BIN
Assets/shopStand_replaced.png


BIN
Assets/signScrapYard.png


+ 9 - 0
Core.cs

@@ -0,0 +1,9 @@
+using GadgetCore;
+
+namespace ScrapYard
+{
+  internal static class Core
+  {
+    public static GadgetLogger logger;
+  }
+}

+ 3 - 0
Manifest.ini

@@ -0,0 +1,3 @@
+[Metadata]
+Name=Scrap Yard
+Assembly=ScrapYard.dll

+ 1 - 0
ModInfo.txt

@@ -0,0 +1 @@
+A mod that adds a scryp yard planet.

+ 33 - 0
Patches/Patch_Chunk_OnDestroy.cs

@@ -0,0 +1,33 @@
+using GadgetCore.API;
+using HarmonyLib;
+using UnityEngine;
+
+namespace ScrapYard.Patches
+{
+  [HarmonyPatch(typeof(Chunk))]
+  [HarmonyPatch("OnDestroy")]
+  [HarmonyGadget("ScrapYard")]
+  public static class Patch_Chunk_OnDestroyy
+  {
+    [HarmonyPrefix]
+    [HarmonyPriority(1010)]
+    public static void Prefix(Chunk __instance, ref GameObject[] ___networkStuff)
+    {
+      if (___networkStuff.Length > 40)
+      {
+        if (Network.isServer)
+        {
+          for (int i = 0; i < ___networkStuff.Length; i++)
+          {
+            if (___networkStuff[i])
+            {
+              Network.RemoveRPCs(___networkStuff[i].GetComponent<NetworkView>().viewID);
+              Network.Destroy(___networkStuff[i].gameObject);
+            }
+          }
+        }
+        ___networkStuff = new GameObject[40];
+      }
+    }
+  }
+}

+ 23 - 0
Patches/Patch_GameScript_Talk.cs

@@ -0,0 +1,23 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace ScrapYard.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("Talk")]
+  [HarmonyGadget("ScrapYard")]
+  public static class Patch_GameScript_Talk
+  {
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, int a)
+    {
+      if (a < 0)
+      {
+        __instance.StartCoroutine(__instance.ExitTalking());
+        return false;
+      }
+      return true;
+    }
+  }
+}

+ 34 - 0
Patches/Patch_KylockeStand_Awake.cs

@@ -0,0 +1,34 @@
+using GadgetCore.API;
+using HarmonyLib;
+using System.Collections;
+using UnityEngine;
+
+namespace ScrapYard.Patches
+{
+
+  [HarmonyPatch(typeof(KylockeStand))]
+  [HarmonyPatch("Awake")]
+  [HarmonyGadget("ScrapYard")]
+  public static class Patch_KylockeStand_Awake
+  {
+    [HarmonyPostfix]
+    public static void Postfix(KylockeStand __instance)
+    {
+      __instance.StartCoroutine(Deactivate(__instance));
+    }
+
+    private static IEnumerator Deactivate(KylockeStand instance)
+    {
+      while (!Network.isServer && !Network.isClient)
+      {
+        yield return new WaitForSeconds(0.25f);
+      }
+      yield return new WaitForSeconds(0.5f);
+      if (instance.itemID >= 2000 && instance.itemID < 2500 || instance.itemID == ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"))
+      {
+        instance.gameObject.SetActive(false);
+      }
+      yield break;
+    }
+  }
+}

+ 10 - 0
Properties/AssemblyInfo.cs

@@ -0,0 +1,10 @@
+using System.Reflection;
+using static ScrapYard.ScrapYard;
+
+[assembly: AssemblyProduct("ScrapYard")] //Set this to the full name of the mod including spaces.
+[assembly: AssemblyTitle("ScrapYard")] //This is only used when mousing over a dll file in Windows explorer.
+[assembly: AssemblyDescription("A Gadget mod for Roguelands, adding a scrap yard planet.")] //This is a short description for your mod's assembly.
+[assembly: AssemblyCompany("")] //Set this to your name/nickname and/or website
+[assembly: AssemblyCopyright("© 2021 Zariteis. All rights reserved.")] //Set this to your copyright name.
+[assembly: AssemblyVersion(MOD_VERSION)]
+[assembly: AssemblyFileVersion(MOD_VERSION)]

+ 8 - 0
Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "ScrapYard": {
+      "commandName": "Executable",
+      "executablePath": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Roguelands\\Roguelands.exe"
+    }
+  }
+}

+ 15 - 0
README.txt

@@ -0,0 +1,15 @@
+In addition to changing all references to "Template" this and that to a more appropriate name,
+you need to add a file called "GamePaths.xml" to the folder ABOVE where you put this template, with the following content:
+
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+  <PropertyGroup>
+    <!-- Set this full path to your game folder. Must contain a slash at the end. -->
+    <GamePath>C:\Program Files (x86)\Steam\steamapps\common\Roguelands\</GamePath>
+
+    <!-- Set this partial path to the game's Managed folder. Must contain a slash at the end. -->
+    <ManagedFolder>Roguelands_Data\Managed\</ManagedFolder>
+  </PropertyGroup>
+</Project>
+
+Note that `GamePath` may need to be changed, depending on the nature of your installation.

+ 337 - 0
ScrapYard.cs

@@ -0,0 +1,337 @@
+using GadgetCore.API;
+using GadgetCore.API.Dialog;
+using ScrapYard.API;
+using System.Collections;
+using System.Reflection;
+using UnityEngine;
+using UnityEngine.SceneManagement;
+
+namespace ScrapYard
+{
+  [Gadget("ScrapYard", RequiredOnClients: true, GadgetVersionSpecificity: VersionSpecificity.NONBREAKING)]
+  public class ScrapYard : Gadget<ScrapYard>
+  {
+    public const string MOD_VERSION = "1.6"; // 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.
+
+    protected override void LoadConfig()
+    {
+      Config.Load();
+
+      string fileVersion = Config.ReadString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
+
+      if (fileVersion != CONFIG_VERSION)
+      {
+        Config.Reset();
+        Config.WriteString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
+      }
+
+      Config.Save();
+    }
+
+    public override string GetModDescription()
+    {
+      return "A mod that adds a scryp yard planet.";
+    }
+
+    protected override void Initialize()
+    {
+      Logger.Log("Scrap Yard v" + Info.Mod.Version);
+      Core.logger = Logger;
+
+      Texture2D texturePlanetIcon = GadgetCoreAPI.LoadTexture2D("planetScrapYard.png");
+      Texture2D texturePlanetPrevIcon = GadgetCoreAPI.LoadTexture2D("planetScrapYardPrev.png");
+      Texture2D texturePortalSign = GadgetCoreAPI.LoadTexture2D("signScrapYard.png");
+
+      Texture2D textureBG = GadgetCoreAPI.LoadTexture2D("bgScrapYard.png");
+      Texture2D textureBGExtension = GadgetCoreAPI.LoadTexture2D("bgScrapYardExtension.png");
+      Texture2D textureBGTop = GadgetCoreAPI.LoadTexture2D("bgScrapYardTop.png");
+
+      Texture2D textureParalex = GadgetCoreAPI.LoadTexture2D("parallax.png");
+      Texture2D textureParalex0 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg0.png");
+      Texture2D textureParalex1 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg1.png");
+      Texture2D textureParalex2 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg2.png");
+      Texture2D textureParalex3 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg3.png");
+
+      Texture2D textureEntrance = GadgetCoreAPI.LoadTexture2D("entranceScrapYard.png");
+      Texture2D textureSmallSide = GadgetCoreAPI.LoadTexture2D("sideSmallScrapYard.png");
+      Texture2D textureBigSide = GadgetCoreAPI.LoadTexture2D("sideBigScrapYard.png");
+
+      Texture2D textureMid0 = GadgetCoreAPI.LoadTexture2D("midScrapYardChunk0.png");
+      Texture2D textureMid1 = GadgetCoreAPI.LoadTexture2D("midScrapYardChunk1.png");
+
+      Texture2D textureScrapTrophy = GadgetCoreAPI.LoadTexture2D("iScrapTrophy.png");
+
+      PlanetInfo scrapYardPlanet = new PlanetInfo(PlanetType.SPECIAL, "Scrap Yard", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(1, 100) });
+      scrapYardPlanet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
+      scrapYardPlanet.SetBackgroundInfo(textureParalex, textureParalex0, textureParalex1, textureParalex2, textureParalex3);
+      scrapYardPlanet.SetTerrainInfo(textureEntrance, textureBG, textureMid0, textureMid1, textureBigSide, textureSmallSide);
+
+      scrapYardPlanet.OnGenerateWorld += ScrapYardGenerator.GenarateTown;
+      scrapYardPlanet.Register("Scrap Yard");
+
+      scrapYardPlanet.PortalUses = -1;
+
+
+      ItemInfo item = new ItemInfo(ItemType.GENERIC, "Scrap Trophy", "A rusty trophy.\nUsed for purchasing\nspecial items.", textureScrapTrophy);
+      int itemID = ItemRegistry.Singleton.Register(item, "Scrap Trophy");
+      if (itemID == -1)
+        throw new System.Exception("Could not register item " + "Scrap Trophy");
+
+
+      { // Scrap Yard Bulding
+        var scrapYardShopBuilding = Object.Instantiate((GameObject)Resources.Load("prop/2501"));
+        scrapYardShopBuilding.transform.localScale *= 8;
+        Texture2D texture = GadgetCoreAPI.LoadTexture2D("shopStand.png");
+        var renderer = scrapYardShopBuilding.GetComponentInChildren<Renderer>();
+        renderer.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = texture
+        };
+        scrapYardShopBuilding.AddComponent<ScrapYardDecoBlinkScript>();
+        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/scrapYardShopBuilding", scrapYardShopBuilding);
+      }
+
+      { // Scrap Yard Shop Owner
+        var scrapYardMerchant = Object.Instantiate((GameObject)Resources.Load("npc/perceval"));
+        Texture2D textureBody = GadgetCoreAPI.LoadTexture2D("merchantBody.png");
+        Texture2D textureHead = GadgetCoreAPI.LoadTexture2D("merchantHead.png");
+
+        var gameObjectBody = scrapYardMerchant.transform.Find("e").Find("perceval").FindChild("Plane_002");
+        var rendererBody = gameObjectBody.gameObject.GetComponentInChildren<Renderer>();
+        rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = textureBody
+        };
+
+        var gameObjectHead = scrapYardMerchant.transform.Find("e").Find("perceval").FindChild("Plane");
+        var rendererHead = gameObjectHead.gameObject.GetComponentInChildren<Renderer>();
+        rendererHead.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = textureHead
+        };
+
+        //scrapYardMerchant.layer = 0;
+
+        scrapYardMerchant.transform.Find("e").rotation = Quaternion.Euler(0f, 180f, 0f);
+
+        scrapYardMerchant.name = "scrapyardmerchant";
+
+        Component.DestroyImmediate(scrapYardMerchant.GetComponent<npcTurnScript>());
+        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/scrapYardMerchant", scrapYardMerchant);
+
+
+        ItemInfo tileItem = new ItemInfo(ItemType.GENERIC, "scrapyardmerchant", "Degug item.", null as Texture2D).Register();
+        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardmerchant"), tileItem);
+        int tileID = TileRegistry.Singleton.Register(tile, "scrapyardmerchant");
+        if (tileID == -1)
+          throw new System.Exception("Could not register Tile " + "scrapyardmerchant");
+        DialogChain dialogChain = new DialogChain(tileID, "Ito", merchantPortraitMaterial, (e) => true, new DialogMessage("Haz a look at my warez!!!"));
+        dialogChain.RegisterDialogChain();
+        tile.OnInteract += tile.InitiateDialogRoutine;
+      }
+
+      { // Part Semicolider Platform
+        var asset = GadgetCoreAPI.LoadAssetBundle("platform");
+        var platform = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/platform.prefab"));
+        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/platform", platform);
+      }
+
+      { // Bottom Chunk
+        var gameObject = Object.Instantiate((GameObject)Resources.Load("z/chunk"));
+
+        var rendererBody = gameObject.GetComponentInChildren<Renderer>();
+        rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = textureBG
+        };
+
+        for (int i = 0; i < 6; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(0).gameObject);
+        for (int i = 0; i < 16; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(1).gameObject);
+
+        gameObject.transform.GetChild(0).GetChild(7).localScale += new Vector3(1.5f, 0, 0);
+        GameObject.DestroyImmediate(gameObject.transform.GetChild(0).GetChild(5).gameObject);
+        GameObject.DestroyImmediate(gameObject.transform.GetChild(0).GetChild(1).gameObject);
+
+        Component.DestroyImmediate(gameObject.GetComponent<Chunk>());
+
+        var platformComponent = Object.Instantiate((GameObject)Resources.Load("prop/ScrapYard/component/platform"));
+        platformComponent.transform.SetParent(gameObject.transform);
+        platformComponent.transform.localScale = new Vector3(0.5625f, 10, 1);
+        platformComponent.transform.localPosition = new Vector3(0, 0.25f, 0);
+        platformComponent.transform.localRotation = Quaternion.Euler(90, 0, 0);
+
+        GadgetCoreAPI.AddCustomResource("z/ScrapYard/chunkBase", gameObject);
+      }
+
+      { // Extension Chunk
+        var gameObject = Object.Instantiate((GameObject)Resources.Load("z/chunk"));
+
+        var rendererBody = gameObject.GetComponentInChildren<Renderer>();
+        rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = textureBGExtension
+        };
+
+        for (int i = 0; i < 6; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(0).gameObject);
+        for (int i = 0; i < 16; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(1).gameObject);
+
+        for (int i = 0; i < 6; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(0).GetChild(0).gameObject);
+
+        gameObject.transform.GetChild(0).GetChild(0).localScale = new Vector3(0.4375f, 2, 1);
+        gameObject.transform.GetChild(0).GetChild(0).localPosition = new Vector3(0.78125f, 0, 0);
+
+        gameObject.transform.GetChild(0).GetChild(1).localScale = new Vector3(0.4375f, 2, 1);
+        gameObject.transform.GetChild(0).GetChild(1).localPosition = new Vector3(-0.78125f, 0, 0);
+
+        Component.DestroyImmediate(gameObject.GetComponent<Chunk>());
+        GadgetCoreAPI.AddCustomResource("z/ScrapYard/chunkExtension", gameObject);
+      }
+
+      { // Top Chunk
+        var gameObject = Object.Instantiate((GameObject)Resources.Load("z/chunk"));
+
+        var rendererBody = gameObject.GetComponentInChildren<Renderer>();
+        rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = textureBGTop
+        };
+
+        for (int i = 0; i < 6; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(0).gameObject);
+        for (int i = 0; i < 16; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(1).gameObject);
+
+        for (int i = 0; i < 5; i++)
+          GameObject.DestroyImmediate(gameObject.transform.GetChild(0).GetChild(0).gameObject);
+
+        gameObject.transform.GetChild(0).GetChild(0).localPosition = new Vector3(0.78125f, 0, 0);
+        gameObject.transform.GetChild(0).GetChild(0).localScale = new Vector3(0.4375f, 2, 1);
+
+        gameObject.transform.GetChild(0).GetChild(1).localPosition = new Vector3(-0.78125f, 0, 0);
+        gameObject.transform.GetChild(0).GetChild(1).localScale = new Vector3(0.4375f, 2, 1);
+
+        gameObject.transform.GetChild(0).GetChild(2).localPosition = new Vector3(0, 0.5f, 0);
+        gameObject.transform.GetChild(0).GetChild(2).localScale = new Vector3(2f, 0.5f, 1);
+
+        Component.DestroyImmediate(gameObject.GetComponent<Chunk>());
+        GadgetCoreAPI.AddCustomResource("z/ScrapYard/chunkTop", gameObject);
+      }
+
+      { // Platform
+        var gameObject = Object.Instantiate((GameObject)Resources.Load("prop/2501"));
+        gameObject.transform.localScale = new Vector3(12, 2, 1);
+        Texture2D texture = GadgetCoreAPI.LoadTexture2D("metalPlatform.png");
+        var renderer = gameObject.GetComponentInChildren<Renderer>();
+        renderer.material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = texture
+        };
+        var platformComponent = Object.Instantiate((GameObject)Resources.Load("prop/ScrapYard/component/platform"));
+        platformComponent.transform.SetParent(gameObject.transform);
+        platformComponent.transform.localScale = new Vector3(2, 2, 1);
+        platformComponent.transform.localPosition = new Vector3(0, 0, 0);
+        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/metalPlatform", gameObject);
+      }
+
+      { // Shop Stand
+        var asset = GadgetCoreAPI.LoadAssetBundle("scrapyardstand");
+        var scrapYardStand = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/scrapyardstand.prefab"));
+        scrapYardStand.SetActive(false);
+        scrapYardStand.AddComponent<ScrapYardShopStandScript>();
+        scrapYardStand.name = "scrapyardstand";
+        GadgetCoreAPI.AddCustomResource("prop/ScrapYard/stand", scrapYardStand);
+
+        scrapYardStand.transform.GetChild(0).GetComponent<Renderer>().material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = GadgetCoreAPI.LoadTexture2D("scrapYardStand.png")
+        };
+
+        scrapYardStand.transform.GetChild(2).GetComponent<Renderer>().material = new Material(Shader.Find("Unlit/Transparent"))
+        {
+          mainTexture = GadgetCoreAPI.LoadTexture2D("scrapYardStandInfo.png")
+        };
+
+        ItemInfo tileItem = new ItemInfo(ItemType.GENERIC, "scrapyardstand", "Degug item.", null as Texture2D).Register();
+        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardstand"), tileItem);
+        int tileID = TileRegistry.Singleton.Register(tile, "scrapyardstand");
+        if (tileID == -1)
+          throw new System.Exception("Could not register Tile " + "scrapyardstand");
+        tile.OnInteract += OnInteractStand;
+      }
+
+      ShopPlatform.Reset();
+
+      // Setting up default shop platforms
+      new ShopPlatform("Default Objects", ShopPlatformSpacingType.Near).Register("DefaultObjects");
+      new ShopPlatform("Default Blocks", ShopPlatformSpacingType.Near).Register("DefaultBlocks");
+      new ShopPlatform("Default Walls", ShopPlatformSpacingType.Near).Register("DefaultWalls");
+
+      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(2000, 100));
+      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(2001, 100));
+      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(2002, 500));
+      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(2400, 7000));
+
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2100, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2101, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2102, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2103, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2104, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2105, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2106, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2107, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2108, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2403, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"), 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2401, 1000));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2402, 1000));
+
+      ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(2200, 50));
+
+      SceneManager.sceneLoaded += OnSceneLoaded;
+
+    }
+
+    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+    {
+      if (scene.buildIndex == 1)
+      {
+        try
+        {
+          var storageMenu = GameObject.Find("Ship").transform.Find("SHIPPLACES").transform.Find("mech").localPosition = new Vector3(-130f, -5.23f, 0.6f);
+        }
+        catch (System.Exception e) { Core.logger.LogError(e.Message); }
+      }
+    }
+
+    public static readonly FieldInfo canInteractField = typeof(PlayerScript).GetField("canInteract", BindingFlags.NonPublic | BindingFlags.Instance);
+    public static readonly FieldInfo interactingField = typeof(PlayerScript).GetField("interacting", BindingFlags.NonPublic | BindingFlags.Instance);
+
+    private IEnumerator OnInteractStand()
+    {
+      try
+      {
+        PlayerScript.curInteractObj.SendMessage("Request");
+        canInteractField.SetValue(InstanceTracker.PlayerScript, true);
+        interactingField.SetValue(InstanceTracker.PlayerScript, false);
+        InstanceTracker.PlayerScript.w.SetActive(true);
+      }
+      catch (System.Exception e)
+      {
+        Core.logger.Log(e);
+      }
+      yield break;
+    }
+
+    public static readonly Material merchantPortraitMaterial = new Material(Shader.Find("Unlit/Transparent"))
+    {
+      mainTexture = GadgetCoreAPI.LoadTexture2D("merchantPortrait.png"),
+      mainTextureScale = new Vector2(0.5f, 1)
+    };
+  }
+}

+ 301 - 0
ScrapYard.csproj

@@ -0,0 +1,301 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+  <ImportGroup>
+    <Import Project="../GamePaths.xml" />
+  </ImportGroup>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProjectGuid>{91AB81DE-EAEE-47D1-93DD-541179208219}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>ScrapYard</RootNamespace>
+    <AssemblyName>ScrapYard</AssemblyName>
+    <TargetFrameworks>net35</TargetFrameworks>
+    <FileAlignment>512</FileAlignment>
+    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+    <Configurations>Release</Configurations>
+    <Authors>Zariteis</Authors>
+    <ApplicationIcon />
+    <StartupObject />
+    <Platforms>x86</Platforms>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net35|x86'">
+    <NoWarn>1701;1702</NoWarn>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="0Harmony">
+      <HintPath>$(GamePath)$(ManagedFolder)0Harmony.dll</HintPath>
+      <SpecificVersion>false</SpecificVersion>
+      <Private>false</Private>
+      <RequiredTargetFramework>net35</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="Assembly-CSharp">
+      <HintPath>$(GamePath)$(ManagedFolder)Assembly-CSharp.dll</HintPath>
+      <SpecificVersion>false</SpecificVersion>
+      <RequiredTargetFramework>net35</RequiredTargetFramework>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="GadgetCore">
+      <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
+      <SpecificVersion>false</SpecificVersion>
+      <RequiredTargetFramework>net35</RequiredTargetFramework>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="UnityEngine">
+      <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
+      <SpecificVersion>false</SpecificVersion>
+      <RequiredTargetFramework>net35</RequiredTargetFramework>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="ModInfo.txt">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <UsingTask TaskName="GetFileVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+    <ParameterGroup>
+      <AssemblyPath ParameterType="System.String" Required="true" />
+      <Version ParameterType="System.String" Output="true" />
+      <TrimmedVersion ParameterType="System.String" Output="true" />
+    </ParameterGroup>
+    <Task>
+      <Using Namespace="System.Diagnostics" />
+      <Using Namespace="System.Text" />
+      <Using Namespace="System.Linq" />
+      <Code Type="Fragment" Language="cs">
+        <![CDATA[
+      this.Version = FileVersionInfo.GetVersionInfo(this.AssemblyPath).FileVersion;  
+      this.TrimmedVersion = this.Version.Split('.').TakeWhile(x => !x.Equals("0")).Aggregate(new StringBuilder(), (a, b) => { if (a.Length > 0) a.Append("."); a.Append(b); return a; }).ToString();
+      if (this.TrimmedVersion.IndexOf('.') == -1) this.TrimmedVersion += ".0";
+    ]]>
+      </Code>
+    </Task>
+  </UsingTask>
+  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+    <GetFileVersion AssemblyPath="$(TargetPath)">
+      <Output TaskParameter="Version" PropertyName="ModFullVersion" />
+      <Output TaskParameter="TrimmedVersion" PropertyName="AssemblyFileVersion" />
+    </GetFileVersion>
+    <ItemGroup>
+      <OldZip Include="$(TargetDir)$(AssemblyName)_v*.zip" />
+      <OldZip Include="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v*.zip" />
+    </ItemGroup>
+    <Delete Files="@(OldZip)" />
+    <MakeDir Directories="$(TargetDir)..\BuildCache\" />
+    <ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Copy SourceFiles="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <RemoveDir Directories="$(TargetDir)..\BuildCache\" />
+    <MakeDir Directories="$(GamePath)GadgetCore\Mods\" />
+    <Copy SourceFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Message Importance="High" Text="Mod Exported to $(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+  </Target>
+  <ItemGroup>
+    <None Update="Assets\bgScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bgScrapYardExtension.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bgScrapYardTop.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bScrapYardbg0.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bScrapYardbg1.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bScrapYardbg2.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\bScrapYardbg3.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cGreenLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\charBG.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cOrangeLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cPlatform.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cPurpleLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cWhiteLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cYellowLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\entranceScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\First\one">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iAirCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iEarthCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iFireCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iGreenLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iOrangeLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iPlatform.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iPurpleLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iScrapTrophy.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iWaterCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iWhiteLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iYellowLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\merchantBody.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\merchantHead.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\merchantPortrait.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\metalPlatform.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\midCoverChunk0.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\midHiddenChunk0.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\midScrapYardChunk0.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\midScrapYardChunk1.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\one">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\parallax.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\planetScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\planetScrapYardPrev.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\platform">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\scrapyardstand">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\scrapYardStand.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\scrapYardStandInfo.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\shopStand.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\shopStand_blink.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\sideBigScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\sidesmallScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\signScrapYard.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\testP.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Manifest.ini">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System">
+      <Private>false</Private>
+      <SpecificVersion>true</SpecificVersion>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Data">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Drawing">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.IO.Compression.FileSystem">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Numerics">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Runtime.Serialization">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml.Linq">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+</Project>

+ 22 - 0
ScrapYard.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31005.135
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScrapYard", "ScrapYard.csproj", "{91AB81DE-EAEE-47D1-93DD-541179208219}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{91AB81DE-EAEE-47D1-93DD-541179208219}.Release|x86.ActiveCfg = Release|x86
+		{91AB81DE-EAEE-47D1-93DD-541179208219}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {108575EB-1B8F-4B26-A5E4-9DD62C4B9AC6}
+	EndGlobalSection
+EndGlobal

+ 35 - 0
ScrapYardDecoBlinkScript.cs

@@ -0,0 +1,35 @@
+using GadgetCore.API;
+using System.Collections;
+using System.Reflection;
+using UnityEngine;
+
+namespace ScrapYard
+{
+  public class ScrapYardDecoBlinkScript : MonoBehaviour
+  {
+    private void Awake()
+    {
+      StartCoroutine(Update());
+    }
+
+    private static Material materialOff = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("shopStand.png") };
+    private static Material materialOn = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("shopStand_blink.png") };
+
+    private IEnumerator Update()
+    {
+      while (true)
+      {
+        yield return new WaitForSeconds(5f + Random.Range(0, 100) / 2f);
+        int times = Random.Range(1, 5);
+        for (int i = 0; i < times; i++)
+        {
+          yield return new WaitForSeconds(0.2f + Random.Range(0, 20) / 55f);
+          gameObject.GetComponentInChildren<Renderer>().material = materialOn;
+          yield return new WaitForSeconds(0.1f + Random.Range(0, 20) / 11f);
+          gameObject.GetComponentInChildren<Renderer>().material = materialOff;
+        }
+      }
+      yield break;
+    }
+  }
+}

+ 119 - 0
ScrapYardGenerator.cs

@@ -0,0 +1,119 @@
+using GadgetCore.API;
+using GadgetCore.Util;
+using ScrapYard.API;
+using System;
+using System.Reflection;
+using UnityEngine;
+
+namespace ScrapYard
+{
+  public class ScrapYardGenerator
+  {
+    private static readonly Material materialaBackLight = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("parallax.png") };
+    private static readonly Material materialaParalex0 = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("bScrapYardbg0.png") };
+    private static readonly Material materialaParalex1 = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("bScrapYardbg1.png") };
+    private static readonly Material materialaParalex2 = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("bScrapYardbg2.png") };
+    private static readonly Material materialaParalex3 = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("bScrapYardbg3.png") };
+
+    public static void GenarateTown(SpawnerScript s, int[] param)
+    {
+      try
+      {
+        s.backLights.SetActive(true);
+        s.mainLight.SetActive(true);
+        s.backLights.GetComponent<Renderer>().material = materialaBackLight;
+        s.mainLight.GetComponentInChildren<Light>().color = new Color(0.05f, 0.05f, 0.05f, 0.1f);
+
+        s.bg[0].GetComponent<Renderer>().material = materialaParalex0;
+        s.bg[1].GetComponent<Renderer>().material = materialaParalex1;
+        s.bg[2].GetComponent<Renderer>().material = materialaParalex2;
+        s.bg[3].GetComponent<Renderer>().material = materialaParalex3;
+
+        var chunks = s.GetFieldValue<GameObject[]>("chunks");
+        var num = 0;
+
+        chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/entrance"), new Vector3(224.5f, 0f, 5f), Quaternion.Euler(0f, 0f, 0f));
+        num++;
+        chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/ScrapYard/chunkBase"), new Vector3((float)(300 + 0 * 128), 0f, 5f), Quaternion.Euler(0f, 180f, 180f));
+        num++;
+        int rowsNeeded = 0;
+        foreach (var entry in ShopPlatform.ShopPlatforms)
+        {
+          rowsNeeded += entry.Value.GetRowsNeeded();
+        }
+        int extensionAmount = System.Math.Max((rowsNeeded + 3) / 8, 0);
+        for (int i = 0; i < extensionAmount; i++)
+        {
+          chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/ScrapYard/chunkExtension"), new Vector3((float)(300 + 0 * 128), 64 * (i + 1), 5f), Quaternion.Euler(0f, 180f, 180f));
+          num++;
+        }
+        chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/ScrapYard/chunkTop"), new Vector3((float)(300 + 0 * 128), 64 * (extensionAmount + 1), 5f), Quaternion.Euler(0f, 180f, 180f));
+        num++;
+        chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/exit"), new Vector3(375.5f, 0f, 5f), Quaternion.Euler(0f, 0f, 180f));
+        num++;
+        if (Network.isServer)
+        {
+          chunks[num] = new GameObject("chunk");
+          var chunk = chunks[num].AddComponent<Chunk>();
+          PopulateTown(chunk);
+          num++;
+        }
+      }
+      catch (System.Exception e) { Core.logger.LogConsole(e); }
+    }
+
+    public static void PopulateTown(Chunk chunk)
+    {
+      var networkStuff = new GameObject[400];
+      chunk.SetFieldValue("networkStuff", networkStuff);
+      chunk.GetFieldValue<GameObject[]>("networkStuff");
+      int temp = chunk.GetFieldValue<int>("temp");
+
+      try
+      {
+        networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("prop/ScrapYard/scrapYardShopBuilding"), new Vector3(250f, -6f + 0.118f, 0.3f), Quaternion.identity, 0);
+        temp++;
+        networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("prop/ScrapYard/scrapYardMerchant"), new Vector3(255f, -6f - 0.118f * 12, 0.2f), Quaternion.identity, 0);
+        temp++;
+        networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npcStorage"), new Vector3(234.5f, -6.118f, 0.2f), Quaternion.identity, 0);
+        temp++;
+        networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npcStorage"), new Vector3(362f, -6.118f, 0.2f), Quaternion.identity, 0);
+        temp++;
+        networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npc2103"), new Vector3(366f, -6.118f, 0.2f), Quaternion.identity, 0);
+        temp++;
+
+        int rowNumber = -1;
+        foreach (var platform in ShopPlatform.ShopPlatforms)
+        {
+          for (int i = 0; i < platform.Value.Entries.Count; i++)
+          {
+            ShopPlatformEntry entry = platform.Value.Entries[i];
+            if ((i % platform.Value.GetSpacesPerRow()) == 0)
+            {
+              rowNumber++;
+              networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("prop/ScrapYard/metalPlatform"), new Vector3(300, rowNumber * 8f, 0.4f), Quaternion.identity, 0);
+              temp++;
+            }
+            var step = (i % platform.Value.GetSpacesPerRow()) / (float)(platform.Value.GetSpacesPerRow() - 1);
+            networkStuff[temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load("prop/ScrapYard/stand"), new Vector3(300 - (40 / 2) + (step * 40), rowNumber * 8f + 0.5f - 0.05f, 0.2f), Quaternion.identity, 0);
+            networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(entry.ItemID, entry.Price, entry.Quantity, entry.CurrencyItemID);
+            temp++;
+          }
+        }
+        networkStuff[temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load("prop/ScrapYard/stand"), new Vector3(268.5f, -6.1175f - 1.45f, 0.2f), Quaternion.identity, 0);
+        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy"), 9999, 1, 57);
+        temp++;
+        networkStuff[temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load("prop/ScrapYard/stand"), new Vector3(272.5f, -6.1175f - 1.45f, 0.2f), Quaternion.identity, 0);
+        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(57, 1, 9999, ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy"));
+        temp++;
+      }
+      catch (Exception e) { Core.logger.LogError(e); }
+      GameScript.endPortal[3] = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), new Vector3(226f, -6.118f, 0f), Quaternion.identity, 0);
+      GameScript.endPortalUA[3] = GameScript.endPortal[3].transform.GetChild(0).gameObject;
+      GameScript.endPortal[3].GetComponent<NetworkView>().RPC("Activate", RPCMode.All, new object[0]);
+      GameScript.endPortalUA[3].GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { 98, 0, 3 });
+
+      chunk.SetFieldValue("temp", temp);
+    }
+  }
+}

+ 141 - 0
ScrapYardShopStandScript.cs

@@ -0,0 +1,141 @@
+using GadgetCore.API;
+using System.Collections;
+using System.Reflection;
+using UnityEngine;
+
+namespace ScrapYard
+{
+  public class ScrapYardShopStandScript : MonoBehaviour
+  {
+    public static readonly FieldInfo inventoryField = typeof(GameScript).GetField("inventory", BindingFlags.NonPublic | BindingFlags.Instance);
+
+    private void Awake()
+    {
+      UpdateUI();
+    }
+
+    [RPC]
+    private void Set(int itemID, int price, int quantity, int currencyItemID)
+    {
+      this.itemID = ItemRegistry.Singleton.ConvertIDToLocal(itemID);
+      this.currencyItemID = ItemRegistry.Singleton.ConvertIDToLocal(currencyItemID);
+      this.price = price;
+      this.quantity = quantity;
+      UpdateUI();
+    }
+
+    internal void StartCallSet(int itemID, int price, int quantity, int currencyItemID)
+    {
+      StartCoroutine(CallSet(itemID, price, quantity, currencyItemID));
+    }
+
+    private IEnumerator CallSet(int itemID, int price, int quantity, int currencyItemID)
+    {
+      yield return new WaitForSeconds(0.1f);
+      itemID = ItemRegistry.Singleton.ConvertIDToHost(itemID);
+      currencyItemID = ItemRegistry.Singleton.ConvertIDToHost(currencyItemID);
+      gameObject.GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { itemID, price, quantity, currencyItemID });
+      yield break;
+    }
+
+    private void UpdateUI()
+    {
+      gameObject.transform.GetChild(1).GetComponent<Animation>().Play("animationStand");
+      gameObject.transform.GetChild(1).GetComponent<Renderer>().material = (Material)Resources.Load("i/i" + itemID);
+      gameObject.transform.GetChild(2).GetChild(1).GetComponent<Renderer>().material = (Material)Resources.Load("i/i" + currencyItemID);
+
+      ItemInfo info = ItemRegistry.GetItem(itemID);
+
+      string title = (quantity > 1 ? quantity + "x " : "") + info.Name;
+
+      gameObject.transform.GetChild(2).GetChild(0).GetComponent<TextMesh>().text = title;
+      gameObject.transform.GetChild(2).GetChild(0).GetChild(0).GetComponent<TextMesh>().text = title;
+      gameObject.transform.GetChild(2).GetChild(2).GetComponent<TextMesh>().text = "" + price;
+      gameObject.transform.GetChild(2).GetChild(2).GetChild(0).GetComponent<TextMesh>().text = "" + price;
+    }
+
+    private void OnTriggerEnter(Collider c)
+    {
+      if (c.gameObject.layer == 8)
+      {
+        gameObject.transform.GetChild(2).gameObject.SetActive(true);
+      }
+    }
+
+    private void OnTriggerExit(Collider c)
+    {
+      if (c.gameObject.layer == 8)
+      {
+        gameObject.transform.GetChild(2).gameObject.SetActive(false);
+      }
+    }
+
+    private int GetItemAmount(GameScript gameScript, int id)
+    {
+      if (id == 0) return 0;
+      int num = 0;
+      Item[] inventory = (Item[])inventoryField.GetValue(gameScript);
+      for (int i = 0; i < 45; i++)
+      {
+        if (inventory[i].id == id)
+        {
+          num += inventory[i].q;
+        }
+      }
+      return num;
+    }
+
+    private void RemoveItemAmount(GameScript gameScript, int id, int amount)
+    {
+      Item[] inventory = (Item[])inventoryField.GetValue(gameScript);
+      for (int i = 0; i < 45; i++)
+      {
+        if (inventory[i].id == id)
+        {
+          if (amount - inventory[i].q > 0)
+          {
+            amount -= inventory[i].q;
+            inventory[i] = gameScript.EmptyItem();
+            gameScript.RefreshSlot(i);
+          }
+          else
+          {
+            if (amount - inventory[i].q == 0)
+            {
+              inventory[i] = gameScript.EmptyItem();
+              gameScript.RefreshSlot(i);
+              break;
+            }
+            inventory[i].q -= amount;
+            gameScript.RefreshSlot(i);
+            break;
+          }
+        }
+      }
+    }
+
+    private void Request()
+    {
+      var gameScript = (GameScript)Camera.main.GetComponent("GameScript");
+      int num = GetItemAmount(gameScript, currencyItemID);
+
+      if (num >= price)
+      {
+        base.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/purchase"), Menuu.soundLevel / 10f);
+        RemoveItemAmount(gameScript, currencyItemID, price);
+        Item item = new Item(itemID, quantity, 0, 0, 0, new int[3], new int[3]);
+        GadgetCoreAPI.SpawnItem(base.transform.position, item);
+      }
+      else
+      {
+        GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("txtError"), MenuScript.player.transform.position, Quaternion.identity);
+        gameObject.SendMessage("InitError", "Insufficient Currency!");
+      }
+    }
+
+    public int itemID = 1;
+    public int price = 1;
+    public int quantity = 1;
+    public int currencyItemID = 1;
+  }
+}