xiaoye97 / xiaoye97-BepInEx-Plugins

基于BepInex的Unity游戏插件
57 stars 23 forks source link

Adding new veges errors game when loading into a world #9

Open ZorbZorbZorb opened 3 years ago

ZorbZorbZorb commented 3 years ago

Adding any new vege manually through resources, or through LDB tool, the game errors during loading in PlanetModelingManager.PrepareWorks with an IndexOutOfRangeException.

Error does not occur until attempting to load into a world.

Simpliest possible code to replicate using LDB tool below.

namespace Vegetal {
  [BepInPlugin("org.bepinex.plugins.vegetal", "Uh oh, you just got beaned", "1.0.0")]
  public class Vegetal : BaseUnityPlugin {
      void Start() {
          LDBTool.PostAddDataAction += Veges;
          Harmony.CreateAndPatchAll(typeof(Vegetal));
      }
      void Veges() {
          VegeProto vege126 = LDB.veges.Select(126);
          VegeProto newVege = vege126.Copy();
          newVege.ID = 3999;  // 3999 is not in use
          newVege.name = "TestVege";
          LDBTool.PostAddProto(ProtoType.Vege, newVege);

      }
  }
}