public static Component GetComponentWithIndex(this GameObject obj, string type)
        {
            int split = type.IndexOf(' ');

            if (split != -1 && int.TryParse(type.Substring(split + 1), out int index))
            {
                return(obj.GetComponent(type.Substring(0, split), index));
            }
            return(obj.GetComponent(GameObjectJSON.GetType(type)));
        }
 public static Component GetComponent(this GameObject obj, string type, int index)
 {
     Component[] components = obj.GetComponents(GameObjectJSON.GetType(type));
     if (components.Length > index)
     {
         return(components[index]);
     }
     if (components.Length != 0)
     {
         return(components[0]);
     }
     return(null);
 }
Ejemplo n.º 3
0
        public static IEnumerator <object> LoadCorps(bool LoadResources, bool LoadCorps)
        {
            var CustomCorps = GetCCDirectory;

            if (LoadResources)
            {
                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                var cbPng = CustomCorps.GetFiles("*.png", SearchOption.AllDirectories);
                int Count = 0;
                BlockLoader.Timer.Log("Loading json images...");
                yield return(null);

                foreach (FileInfo Png in cbPng)
                {
                    try
                    {
                        Texture2D tex = GameObjectJSON.ImageFromFile(Png.FullName);
                        GameObjectJSON.AddObjectToUserResources <Texture2D>(tex, Png.Name);
                        GameObjectJSON.AddObjectToUserResources <Texture>(tex, Png.Name);
                        GameObjectJSON.AddObjectToUserResources <Sprite>(GameObjectJSON.SpriteFromImage(tex), Png.Name);
                        Count++;
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Could not read image " + Png.Name + "\n at " + Png.FullName + "\n" + E.Message + "\n" + E.StackTrace);
                    }
                    yield return(null);
                }
                BlockLoader.Timer.ReplaceLast("Loaded " + Count.ToString() + " corp images");
                Console.WriteLine($"Took {sw.ElapsedMilliseconds} MS to get corp images");
            }
            if (LoadCorps)
            {
                var ccJson = CustomCorps.GetFiles("*.json", SearchOption.AllDirectories);
                //yield return null;
                foreach (FileInfo Json in ccJson)
                {
                    CreateJSONCorp(Json, Input.GetKey(KeyCode.LeftControl));
                    yield return(null);
                }
            }
            yield break;
        }
Ejemplo n.º 4
0
        public static void CreateBlocks()
        {
#warning Change "mod.json" info

            //var harmony = HarmonyInstance.Create("examplepack.changethisname");
            //harmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());

            new BlockPrefabBuilder(/*"GSO_Block_111", true*/) //Use a reference if you want quick functionality (explosion effects, etc)
            .SetBlockID(87532)                                //CHANGE THIS TO SOMETHING RANDOM
            .SetName("Block Name")
            .SetDescription("Description")
            .SetPrice(2000)
            .SetHP(100)
            .SetFaction(FactionSubTypes.SPE)
            .SetCategory(BlockCategories.Standard)
            .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile("Blocks/icon.png")))
            .SetMass(1f)
            .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
            .SetModel(GameObjectJSON.MeshFromFile("Blocks/block.obj"), true, GameObjectJSON.GetObjectFromGameResources <Material>("GSO_Main"))     //"GC_Main", "HE_Main", "BF_Main", "VEN_Main"
            .RegisterLater();
        }
Ejemplo n.º 5
0
        public static void Load()
        {
            var harmony = new Harmony("exund.weapongroups");
            harmony.PatchAll(Assembly.GetExecutingAssembly());

            var holder = new GameObject();
            holder.AddComponent<GroupControllerEditor>();

            GameObject.DontDestroyOnLoad(holder);

            new BlockPrefabBuilder(BlockTypes.HE_StdBlock_01_111)
                .SetBlockID(7030)
                .SetName("Hawkeye Weapons Controller")
                .SetDescription("This block can control the firing of weapons (guns, drills and hammers).\n\nUsed to manage weapon groups.")
                .SetFaction(FactionSubTypes.HE)
                .SetGrade(2)
                .SetCategory(BlockCategories.Accessories)
                .SetRarity(BlockRarity.Rare)
                .SetSize(IntVector3.one)
                .SetAPsManual(new Vector3[]
                {
                    Vector3.down * 0.5f,
                    Vector3.forward * 0.5f,
                    Vector3.left * 0.5f
                })
                .SetPrice(24705)
                .SetRecipe(new Dictionary<ChunkTypes, int> {
                    { ChunkTypes.HardenedTitanic, 1 },
                    { ChunkTypes.HeatCoil, 2 },
                    { ChunkTypes.SensoryTransmitter, 1 },
                    { ChunkTypes.TitanicAlloy, 1 },
                    { ChunkTypes.SeedAI, 1 }
                })
                .SetModel(GameObjectJSON.MeshFromFile(asm_path + "Assets/weapon_group_fusebox.obj"), true, GameObjectJSON.GetObjectFromGameResources<Material>("HE_Main"))
                .SetIcon(GameObjectJSON.ImageFromFile(asm_path + "Assets/weapon_group_fusebox.png"))
                .AddComponent<ModuleWeaponGroupController>()
                .SetCustomEmissionMode(BlockPrefabBuilder.EmissionMode.Active)
                .SetDropFromCrates(true)
                .RegisterLater();
        }
Ejemplo n.º 6
0
        public static void CreateForPlayer(NetPlayer Player)
        {
            if (Lookup == null)
            {
                Lookup = new Dictionary <NetPlayer, NetCamera>();
            }
            GameObject newbody = new GameObject("CameraObject");
            NetCamera  newcam  = newbody.AddComponent <NetCamera>();

            newcam.HasBody = Player != ManNetwork.inst.MyPlayer;
            newcam.player  = Player;
            if (newcam.HasBody)
            {
                if (MeshBody == null)
                {
                    MeshBody             = GameObjectJSON.MeshFromData(Properties.Resources.mpcamdrone_body);
                    MeshBarrel           = GameObjectJSON.MeshFromData(Properties.Resources.mpcamdrone_barrel);
                    DroneMat             = GameObjectJSON.MaterialFromShader();
                    DroneMat.mainTexture = GameObjectJSON.ImageFromFile(Properties.Resources.mpcamdrone_tex);
                }

                newbody.AddComponent <MeshFilter>().sharedMesh = MeshBody;
                newcam.color = newbody.AddComponent <MeshRenderer>();
                newcam.color.sharedMaterial = DroneMat;
                var barrel = new GameObject("Barrel");
                newcam.T_Barrel        = barrel.transform;
                newcam.T_Barrel.parent = newbody.transform;
                barrel.AddComponent <MeshFilter>().sharedMesh       = MeshBarrel;
                barrel.AddComponent <MeshRenderer>().sharedMaterial = DroneMat;
                newbody.transform.position = new Vector3(UnityEngine.Random.value * 5f - 2.5f, UnityEngine.Random.value * 5f - 1000f, UnityEngine.Random.value * 5f - 2.5f);
            }
            if (Lookup.ContainsKey(Player))
            {
                Lookup.Remove(Player);
            }
            Lookup.Add(Player, newcam);
        }
Ejemplo n.º 7
0
        public static void CreateBlocks()
        {
            Harmony mod = new Harmony("aceba1.fusionblock");

            mod.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());

            Texture2D rtex1 = GameObjectJSON.ImageFromFile(Properties.Resources.reactor_tex_1),
                      rtex2 = GameObjectJSON.ImageFromFile(Properties.Resources.reactor_tex_2),
                      rtex3 = GameObjectJSON.ImageFromFile(Properties.Resources.reactor_tex_3);
            Material gso_main = GameObjectJSON.GetObjectFromGameResources <Material>("GSO_Main"), bf_main = GameObjectJSON.GetObjectFromGameResources <Material>("BF_Main"), rf_main = GameObjectJSON.MaterialFromShader().SetTexturesToMaterial(rtex1, rtex2, rtex3, false), rf_glow = GameObjectJSON.MaterialFromShader("Legacy Shaders/Particles/Additive").SetTexturesToMaterial(rtex3);


            {
                new BlockPrefabBuilder("GSOBlock_111")
                .SetBlockID(98341)
                .SetName("Fusion Block").SetDescription("<i>(Vanilla-safe when merged)</i> Press this up to another of its kind and it will merge the two techs!\n" +
                                                        "Both techs must be facing the same direction, and the block must be oriented to lock together like puzzle pieces. " +
                                                        "Once that's done, it will fuse into a standard block!")
                .SetMass(0.5f).SetHP(125).SetGrade(1)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                .SetPrice(144)
                .SetFaction(FactionSubTypes.GSO).SetCategory(BlockCategories.Accessories)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.fusionblock)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.Fusion_Block), true, gso_main)
                .AddComponent <ModuleFuseHalf>(out ModuleFuseHalf moduleFuse)
                .RegisterLater();
                moduleFuse.ModelForwardPairing      = -1;
                moduleFuse.ModelForwardSignificance = true;
                moduleFuse.MakeSubstitiute          = true;
                moduleFuse.SubstituteType           = BlockTypes.GSOBlock_111;
                moduleFuse.JoinOffset = Vector3.zero;

                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[] {
                    new CustomRecipe.RecipeInput(0),     // Fibrewood
                    new CustomRecipe.RecipeInput(4),     // Plumbite
                    new CustomRecipe.RecipeInput(2, 2)   // Rubber Jelly
                }, new CustomRecipe.RecipeOutput[] {
                    new CustomRecipe.RecipeOutput(98341)
                });
            }
            {
                new BlockPrefabBuilder("GSOBlock_111")
                .SetBlockID(98342)
                .SetName("Fusion Bolt").SetDescription("<i>(Vanilla-safe when merged)</i> Press this up to another of its kind and it will merge the two techs!\n" +
                                                       "Both techs must be facing the same direction, and the block must be facing eachother. " +
                                                       "Once that's done, it will fuse into an exploding bolt!\n\nExploding may still occur while unfused")
                .SetMass(0.125f).SetHP(50).SetGrade(3)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                .SetPrice(324)
                .SetFaction(FactionSubTypes.GSO).SetCategory(BlockCategories.Accessories)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.fusionbolt)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.Fusion_Bolt), true, gso_main)
                .AddComponent <ModuleFuseHalf>(out ModuleFuseHalf moduleFuse)
                .AddComponent <ModuleDetachableLink>()
                .RegisterLater();
                moduleFuse.ModelForwardSignificance = false;
                moduleFuse.MakeSubstitiute          = true;
                moduleFuse.SubstituteType           = BlockTypes.GSO_Exploder_A_111;
                moduleFuse.JoinOffset = Vector3.zero;

                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[] {
                    new CustomRecipe.RecipeInput(1),     // Fibron Chunk
                    new CustomRecipe.RecipeInput(9),     // Carbius Brick
                    new CustomRecipe.RecipeInput(2, 2)   // Rubber Jelly
                }, new CustomRecipe.RecipeOutput[] {
                    new CustomRecipe.RecipeOutput(98342)
                });
            }
            {
                new BlockPrefabBuilder("BF_Block_111")
                .SetBlockID(98343)
                .SetName("Fusion Plate").SetDescription("<i>(Vanilla-safe when merged)</i> Press this up to another of its kind and it will merge the two techs!\n" +
                                                        "Both techs must be facing the same direction, and the block must be facing eachother. " +
                                                        "Once that's done, the halves will melt away and the techs will be merged!")
                .SetMass(0.45f).SetHP(150).SetGrade(1)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                .SetPrice(312)
                .SetFaction(FactionSubTypes.BF).SetCategory(BlockCategories.Accessories)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.fusionplate)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.Fusion_Plate), true, bf_main)
                .AddComponent <ModuleFuseHalf>(out ModuleFuseHalf moduleFuse)
                .RegisterLater();
                moduleFuse.ModelForwardSignificance = false;
                moduleFuse.MakeSubstitiute          = false;
                moduleFuse.JoinOffset = Vector3.down;

                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[] {
                    new CustomRecipe.RecipeInput(32),     // Luxian Crystal
                    new CustomRecipe.RecipeInput(43),     // Fibre Plating
                    new CustomRecipe.RecipeInput(2, 2)    // Rubber Jelly
                }, new CustomRecipe.RecipeOutput[] {
                    new CustomRecipe.RecipeOutput(98343)
                }, NameOfFabricator: "bffab");
            }
            {
                new BlockPrefabBuilder("HEBlock_111")
                .SetBlockID(98350)
                .SetName("Reactor Passive Blast Block").SetDescription("A dense heat-resistent block, that can permit the flow of rodius through all APs on it.")
                .SetMass(3f).SetHP(400).SetGrade(2)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                .SetPrice(400)
                .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_blast_block_passive)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.ReactorBlastBlockPassive), true, rf_main)
                .AddComponent(out Reactors.ModuleReactorHolder moduleReactor)
                .SetDamageableType(ManDamage.DamageableType.Rock)
                .RegisterLater();
                moduleReactor.ThisCapacity = 0.5f;
            }
            {
                new BlockPrefabBuilder("HEBlock_111")
                .SetBlockID(98356)
                .SetName("Reactor Passive Cell Block").SetDescription("A dense heat-resistent block, which can hold more rodius within it than a passive blast block. Optimal for storage.")
                .SetMass(6f).SetHP(400).SetGrade(2)
                .SetSize(new IntVector3(1, 2, 1))
                .SetAPsManual(new Vector3[] { new Vector3(0, -0.5f, 0f), new Vector3(0, 1.5f, 0f) })
                .SetPrice(1200)
                .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_cell)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.ReactorCellPassive), true, rf_main)
                .AddComponent(out Reactors.ModuleReactorHolder moduleReactor)
                .SetDamageableType(ManDamage.DamageableType.Rock)
                .RegisterLater();
                moduleReactor.ThisCapacity = 4f;
            }
            {
                new BlockPrefabBuilder("HEBlock_111")
                .SetBlockID(98351)
                .SetName("Reactor Blast Block").SetDescription("A dense heat-resistent block that can widthstand the jets radiated by a reactor ring. Or a flamethrower.")
                .SetMass(3f).SetHP(550).SetGrade(2)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                .SetPrice(400)
                .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_blast_block)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.ReactorBlastBlock), true, rf_main)
                .SetDamageableType(ManDamage.DamageableType.Rock)
                .RegisterLater();
            }
            {
                var coolerPrefab = new BlockPrefabBuilder("HEBlock_111")
                                   .SetBlockID(98353)
                                   .SetName("Reactor Cooler").SetDescription("It's a spinny!")
                                   .SetMass(1f).SetHP(500).SetGrade(2)
                                   .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                                   .SetPrice(400)
                                   .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Accessories)
                                   .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_cooler)))
                                   .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.ReactorCooler), true, rf_main)
                                   .AddComponent(out Reactors.ModuleReactorCooler moduleCooler)
                                   .SetDamageableType(ManDamage.DamageableType.Rock);

                var fan = new GameObject("m_Spinner");
                fan.AddComponent <MeshFilter>().sharedMesh       = GameObjectJSON.MeshFromData(Properties.Resources.ReactorCoolerFan);
                fan.AddComponent <MeshRenderer>().sharedMaterial = rf_main;
                fan.layer = Globals.inst.layerTank;
                var spinner = fan.AddComponent <Spinner>();
                var tS      = typeof(Spinner);
                tS.GetField("m_Speed", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(spinner, 5f);
                tS.GetField("m_AutoSpin", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(spinner, true);
                tS.GetField("m_SpinUpTime", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(spinner, 0.75f);
                spinner.m_RotationAxis      = new Axis(Axis.AxisType.Y);
                spinner.m_SteerAxis         = new Axis(Axis.AxisType.Y);
                fan.transform.parent        = coolerPrefab.Prefab.transform;
                fan.transform.localPosition = Vector3.zero;

                coolerPrefab.RegisterLater();
            }
            {
                var mesh   = GameObjectJSON.MeshFromData(Properties.Resources.ReactorRingIV);
                var ringIV = new BlockPrefabBuilder("HE_Battery_211")
                             .SetBlockID(98354)
                             .SetName("Reactor Ring IV").SetDescription("This is a rodite generator. It pulls rodite from the connected passive blocks and produces electrical energy. It also lets off jets of heat from the spinning core, which may melt your tech")
                             .SetMass(8f).SetHP(1000).SetGrade(2)
                             .SetSizeManual(new IntVector3[]
                {
                    new IntVector3(0, 0, 0), new IntVector3(0, 0, 1), new IntVector3(0, 0, 2), new IntVector3(1, 0, 2),
                    new IntVector3(2, 0, 2), new IntVector3(2, 0, 1), new IntVector3(2, 0, 0), new IntVector3(1, 0, 0),
                }, new Vector3[]
                {
                    new Vector3(1f, -.5f, 0f), new Vector3(2f, -.5f, 1f), new Vector3(1f, -.5f, 2f), new Vector3(0f, -.5f, 1f),
                    new Vector3(1f, .5f, 0f), new Vector3(2f, .5f, 1f), new Vector3(1f, .5f, 2f), new Vector3(0f, .5f, 1f),

                    new Vector3(1f, 0f, -0.5f), new Vector3(2.5f, 0f, 1f), new Vector3(1f, 0f, 2.5f), new Vector3(-.5f, 0f, 1f),
                })
                             .SetPrice(400)
                             .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                             .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_ring_iv)))
                             .SetModel(mesh, false, rf_main)
                             .AddComponent(out Reactors.ModuleReactorRing moduleEnergy)
                             .SetDamageableType(ManDamage.DamageableType.Rock)
                             .SetCenterOfMass(new Vector3(1f, 0f, 1f));

                AddBoxCollider(ringIV.Prefab, new Vector3(1f, 0f, -.05f), Vector3.zero, new Vector3(1.15f, 1f, .7f));
                AddBoxCollider(ringIV.Prefab, new Vector3(1f, 0f, 2.05f), Vector3.zero, new Vector3(1.15f, 1f, .7f));
                AddBoxCollider(ringIV.Prefab, new Vector3(-.05f, 0f, 1f), Vector3.zero, new Vector3(.7f, 1f, 1.15f));
                AddBoxCollider(ringIV.Prefab, new Vector3(2.05f, 0f, 1f), Vector3.zero, new Vector3(.7f, 1f, 1.15f));
                AddBoxCollider(ringIV.Prefab, new Vector3(1.73f, 0f, 0.27f), new Vector3(0, -45, 0), new Vector3(1.15f, 1f, .7f));
                AddBoxCollider(ringIV.Prefab, new Vector3(0.27f, 0f, 1.73f), new Vector3(0, -45, 0), new Vector3(1.15f, 1f, .7f));
                AddBoxCollider(ringIV.Prefab, new Vector3(0.27f, 0f, 0.27f), new Vector3(0, 45, 0), new Vector3(1.15f, 1f, .7f));
                AddBoxCollider(ringIV.Prefab, new Vector3(1.73f, 0f, 1.73f), new Vector3(0, 45, 0), new Vector3(1.15f, 1f, .7f));

                moduleEnergy.ThisCapacity     = 1f;
                moduleEnergy.UseAPIDs         = false;
                moduleEnergy.DrainPerSecond   = 0.04f;
                moduleEnergy.JetCapsule1      = new Vector3(1f, 0.2f, 1f);
                moduleEnergy.JetCapsule2      = new Vector3(1f, -0.2f, 1f);
                moduleEnergy.JetCapsuleRad    = 1f;
                moduleEnergy.JetCapsuleDamage = 45f;
                Component.DestroyImmediate(ringIV.Prefab.GetComponentInChildren <EnergyGauge>());
                var power = ringIV.Prefab.GetComponent <ModuleEnergyStore>();
                power.m_Capacity           = 400;
                power.m_AcceptRemoteCharge = false;

                var daage = ringIV.Prefab.GetComponent <ModuleDamage>();
                daage.deathExplosion = Transform.Instantiate(daage.deathExplosion);
                var damage = daage.deathExplosion.GetComponent <Explosion>();
                damage.m_MaxDamageStrength       = 1400;
                damage.m_EffectRadius            = 8;
                damage.m_EffectRadiusMaxStrength = 6;
                var particles = daage.deathExplosion.GetComponentsInChildren <ParticleSystem>();
                foreach (var particle in particles)
                {
                    var m = particle.main;
                    m.startSpeedMultiplier *= 2f;
                    m.startSizeMultiplier  *= 3f;
                    m.startColor            = rf_ExplosionColor;
                }

                var jet = new GameObject("BlastJet");
                jet.AddComponent <MeshFilter>().sharedMesh       = GameObjectJSON.MeshFromData(Properties.Resources.ReactorRingIVJet);
                jet.AddComponent <MeshRenderer>().sharedMaterial = rf_glow;
                jet.transform.parent        = ringIV.Prefab.transform;
                jet.transform.localPosition = new Vector3(1f, 0f, 1f);

                ringIV.RegisterLater();
            }
            {
                var mesh  = GameObjectJSON.MeshFromData(Properties.Resources.ReactorRingX);
                var ringX = new BlockPrefabBuilder("HE_Battery_211")
                            .SetBlockID(98355)
                            .SetName("Reactor Ring X").SetDescription("This is a more powerful rodite generator. It pulls rodite from the connected passive blocks and produces electrical energy. It also lets off jets of heat from the spinning core, which may melt your tech")
                            .SetMass(16f).SetHP(2000).SetGrade(2)
                            .SetSizeManual(new IntVector3[]
                {
                    new IntVector3(0, 0, 0), new IntVector3(0, 0, 1), new IntVector3(0, 0, 2), new IntVector3(1, 0, 2),
                    new IntVector3(2, 0, 2), new IntVector3(2, 0, 1), new IntVector3(2, 0, 0), new IntVector3(1, 0, 0),

                    new IntVector3(0, 1, 0), new IntVector3(0, 1, 1), new IntVector3(0, 1, 2), new IntVector3(1, 1, 2),
                    new IntVector3(2, 1, 2), new IntVector3(2, 1, 1), new IntVector3(2, 1, 0), new IntVector3(1, 1, 0),
                }, new Vector3[]
                {
                    new Vector3(1f, -.5f, 0f), new Vector3(2f, -.5f, 1f), new Vector3(1f, -.5f, 2f), new Vector3(0f, -.5f, 1f),
                    new Vector3(1f, 1.5f, 0f), new Vector3(2f, 1.5f, 1f), new Vector3(1f, 1.5f, 2f), new Vector3(0f, 1.5f, 1f),

                    new Vector3(1f, 0f, -0.5f), new Vector3(2.5f, 0f, 1f), new Vector3(1f, 0f, 2.5f), new Vector3(-.5f, 0f, 1f),
                    new Vector3(1f, 1f, -0.5f), new Vector3(2.5f, 1f, 1f), new Vector3(1f, 1f, 2.5f), new Vector3(-.5f, 1f, 1f),
                })
                            .SetPrice(400)
                            .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                            .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_ring_x)))
                            .SetModel(mesh, false, rf_main)
                            .AddComponent(out Reactors.ModuleReactorRing moduleReactor)
                            .SetDamageableType(ManDamage.DamageableType.Rock)
                            .SetCenterOfMass(new Vector3(1f, 0.5f, 1f));

                AddBoxCollider(ringX.Prefab, new Vector3(1f, 0.5f, -.50f), Vector3.zero, new Vector3(1.15f, 2f, .7f));
                AddBoxCollider(ringX.Prefab, new Vector3(1f, 0.5f, 2.05f), Vector3.zero, new Vector3(1.15f, 2f, .7f));
                AddBoxCollider(ringX.Prefab, new Vector3(-.05f, 0.5f, 1f), Vector3.zero, new Vector3(.7f, 2f, 1.15f));
                AddBoxCollider(ringX.Prefab, new Vector3(2.05f, 0.5f, 1f), Vector3.zero, new Vector3(.7f, 2f, 1.15f));
                AddBoxCollider(ringX.Prefab, new Vector3(1.73f, 0f, 0.27f), new Vector3(0, -45, 0), new Vector3(1.15f, 2f, .7f));
                AddBoxCollider(ringX.Prefab, new Vector3(0.27f, 0f, 1.73f), new Vector3(0, -45, 0), new Vector3(1.15f, 2f, .7f));
                AddBoxCollider(ringX.Prefab, new Vector3(0.27f, 0f, 0.27f), new Vector3(0, 45, 0), new Vector3(1.15f, 2f, .7f));
                AddBoxCollider(ringX.Prefab, new Vector3(1.73f, 0f, 1.73f), new Vector3(0, 45, 0), new Vector3(1.15f, 2f, .7f));

                moduleReactor.ThisCapacity     = 1f;
                moduleReactor.DrainPerSecond   = 0.1f;
                moduleReactor.JetCapsule1      = new Vector3(1f, 1.2f, 1f);
                moduleReactor.JetCapsule2      = new Vector3(1f, -0.2f, 1f);
                moduleReactor.JetCapsuleRad    = 1f;
                moduleReactor.JetCapsuleDamage = 60f;
                Component.DestroyImmediate(ringX.Prefab.GetComponentInChildren <EnergyGauge>());
                var power = ringX.Prefab.GetComponent <ModuleEnergyStore>();
                power.m_Capacity           = 1000;
                power.m_AcceptRemoteCharge = false;

                var daage = ringX.Prefab.GetComponent <ModuleDamage>();
                daage.deathExplosion = Transform.Instantiate(daage.deathExplosion);
                var damage = daage.deathExplosion.GetComponent <Explosion>();
                damage.m_MaxDamageStrength       = 2500;
                damage.m_EffectRadius            = 12;
                damage.m_EffectRadiusMaxStrength = 10;
                var particles = daage.deathExplosion.GetComponentsInChildren <ParticleSystem>();
                foreach (var particle in particles)
                {
                    var m = particle.main;
                    m.startSpeedMultiplier *= 3f;
                    m.startSizeMultiplier  *= 4f;
                    m.startColor            = rf_ExplosionColor;
                }

                var jet = new GameObject("BlastJet");
                jet.AddComponent <MeshFilter>().sharedMesh       = GameObjectJSON.MeshFromData(Properties.Resources.ReactorRingXJet);
                jet.AddComponent <MeshRenderer>().sharedMaterial = rf_glow;
                jet.transform.parent        = ringX.Prefab.transform;
                jet.transform.localPosition = new Vector3(1f, 0f, 1f);

                ringX.RegisterLater();
            }
            {
                var mesh         = GameObjectJSON.MeshFromData(Properties.Resources.ReactorLoaderPassive);
                var loaderPrefab = new BlockPrefabBuilder("GSO_Generator_211")//"BF_PlasmaFurnace_333")
                                   .SetBlockID(98352)
                                   .SetName("Reactor Resource Loader").SetDescription("This is the rodite loader for any reactor setup on a tech.\n<b>There is only one passive AP on the bottom of this block.</b> Attach this to another passive AP to power ring generators with rodite ore or capsules.")
                                   .SetMass(3f).SetHP(400).SetGrade(2)
                                   .SetSize(new IntVector3(1, 2, 1))
                                   .SetAPsManual(new Vector3[]
                {
                    new Vector3(0, -0.5f, 0),
                    new Vector3(0, 0, -0.5f),
                    new Vector3(0, 0, 0.5f),
                    new Vector3(-0.5f, 0, 0),
                    new Vector3(0.5f, 0, 0),
                })
                                   .SetPrice(400)
                                   .SetFaction(FactionSubTypes.HE).SetCategory(BlockCategories.Base)
                                   .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.reactor_loader)))
                                   .SetModel(mesh, false, rf_main)
                                   .AddComponent(out Reactors.ModuleReactorLoader moduleReactor)
                                   .SetDamageableType(ManDamage.DamageableType.Rock)
                                   .SetCenterOfMass(Vector3.zero);

                AddBoxCollider(loaderPrefab.Prefab, new Vector3(0f, -0.175f, 0f), Vector3.zero, new Vector3(1f, 0.65f, 1f));
                AddBoxCollider(loaderPrefab.Prefab, new Vector3(0.28f, 0.5f, 0.28f), Vector3.zero, new Vector3(.2f, 1.6f, .2f));
                AddBoxCollider(loaderPrefab.Prefab, new Vector3(0.28f, 0.5f, -0.28f), Vector3.zero, new Vector3(.2f, 1.6f, .2f));
                AddBoxCollider(loaderPrefab.Prefab, new Vector3(-0.28f, 0.5f, -0.28f), Vector3.zero, new Vector3(.2f, 1.6f, .2f));
                AddBoxCollider(loaderPrefab.Prefab, new Vector3(-0.28f, 0.5f, 0.28f), Vector3.zero, new Vector3(.2f, 1.6f, .2f));

                moduleReactor.ThisCapacity = 2.5f;
                moduleReactor.APIDs        = new int[] { 0 };
                moduleReactor.UseAPIDs     = true;
                ModuleItemConsume consume = loaderPrefab.Prefab.GetComponent <ModuleItemConsume>();
                Component.DestroyImmediate(loaderPrefab.Prefab.GetComponent <ModuleAnchor>());
                //loaderPrefab.Prefab.transform.Find("BF_PlasmaFurnace_333").localPosition = new Vector3(0, 0, 0);

                Type         MIC = typeof(ModuleItemConsume);
                BindingFlags BF  = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
                FieldInfo //NTBA = MIC.GetField("m_NeedsToBeAnchored", BF),
                    CS  = MIC.GetField("m_Consume", BF),
                    IP  = MIC.GetField("m_Input", BF),
                    EM  = MIC.GetField("m_EnergyMultiplier", BF),
                    OBP = typeof(ModuleItemHolder).GetField("m_OverrideBasePositons", BF),
                    RLN = typeof(ModuleRecipeProvider).GetField("m_RecipeListNames", BF);
                try
                {
                    RLN.SetValue(loaderPrefab.Prefab.GetComponent <ModuleRecipeProvider>(), new RecipeManager.RecipeNameWrapper[] { new RecipeManager.RecipeNameWrapper()
                                                                                                                                    {
                                                                                                                                        name = Reactors.ModuleReactorLoader.RecipeName
                                                                                                                                    } });
                    //NTBA.SetValue(consume, false);
                    EM.SetValue(consume, 0f);
                    (IP.GetValue(consume) as ModuleItemHolder.StackHandle).localPos = new Vector3(0, 0.37f, 0);
                    (CS.GetValue(consume) as ModuleItemHolder.StackHandle).localPos = new Vector3(0, -0.5f, 0);
                    Vector3[] overrideBasePositions = OBP.GetValue(loaderPrefab.Prefab.GetComponent <ModuleItemHolder>()) as Vector3[];
                    overrideBasePositions[0] = new Vector3(0, 0.37f, 0);
                    overrideBasePositions[1] = new Vector3(0, -0.5f, 0);
                }
                catch (Exception E) { do
                                      {
                                          Console.WriteLine(E); E = E.InnerException;
                                      } while (E.InnerException != null); }
                loaderPrefab.RegisterLater();
                BlockLoader.DelayAfterSingleton(AddRoditeRecipeList);
            }
            {
                new BlockPrefabBuilder("BF_Block_111")
                .SetBlockID(98344)
                .SetName("Reusable Fusion Bolt").SetDescription("Press this up to another of its kind and it will merge the two techs!\n" +
                                                                "Both techs must be facing the same direction, and the block must be facing eachother. " +
                                                                "Once that's done, the halves join together to form one tech, and can be separated")
                .SetMass(0.6f).SetHP(200).SetGrade(1)
                .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                .SetPrice(624)
                .SetFaction(FactionSubTypes.BF).SetCategory(BlockCategories.Accessories)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.ionicboltopen)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.Ionic_Bolt_Open), true, bf_main)
                .AddComponent(out ModuleFuseHalf moduleFuse)
                .RegisterLater();
                moduleFuse.ModelForwardSignificance = false;
                moduleFuse.MakeSubstitiute          = true;
                moduleFuse.SubstituteType           = (BlockTypes)98345;
                moduleFuse.JoinOffset = Vector3.zero;

                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[] {
                    new CustomRecipe.RecipeInput(32, 2),   // Luxian Crystal
                    new CustomRecipe.RecipeInput(43, 2),   // Fibre Plating
                    new CustomRecipe.RecipeInput(2, 4)     // Rubber Jelly
                }, new CustomRecipe.RecipeOutput[] {
                    new CustomRecipe.RecipeOutput(98344)
                }, NameOfFabricator: "bffab");
            }
            {
                new BlockPrefabBuilder("BF_Block_111")
                .SetBlockID(98345)
                .SetName("Reusable Fusion Bolt Pair").SetDescription("This is a joined pair of Resusable Fusion Bolts. They can be separated like a normal bolt")
                .SetMass(1.2f).SetHP(400).SetGrade(1)
                .SetSize(IntVector3.one)
                .SetAPsManual(new Vector3[] {
                    Vector3.down * 0.5f,
                    Vector3.up * 0.5f
                })
                .SetPrice(1248)
                .SetFaction(FactionSubTypes.BF).SetCategory(BlockCategories.Accessories)
                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.ionicbolt)))
                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.Ionic_Bolt), true, bf_main)
                .AddComponent(out ModuleFuseHalf moduleFuse)
                .AddComponent <ModuleDetachableLink>()
                .RegisterLater();
                moduleFuse.Separator      = true;
                moduleFuse.SubstituteType = (BlockTypes)98344;

                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[] {
                    new CustomRecipe.RecipeInput(32, 4),   // Luxian Crystal
                    new CustomRecipe.RecipeInput(43, 4),   // Fibre Plating
                    new CustomRecipe.RecipeInput(2, 8)     // Rubber Jelly
                }, new CustomRecipe.RecipeOutput[] {
                    new CustomRecipe.RecipeOutput(98345)
                }, NameOfFabricator: "bffab");
            }
        }
Ejemplo n.º 8
0
        public static void Load()
        {
            ModConfig config = new ModConfig();
            int       v      = (int)KeyCode.Keypad0;

            config.TryGetConfig <int>("colorToolsKeycode", ref v);
            colorToolsKeycode = (KeyCode)v;

            OptionKey commandConsoleKey = new OptionKey("Color tools toggle", "Procedural Blocks", colorToolsKeycode);

            commandConsoleKey.onValueSaved.AddListener(() =>
            {
                colorToolsKeycode           = commandConsoleKey.SavedValue;
                config["colorToolsKeycode"] = (int)colorToolsKeycode;
            });

            v = (int)KeyCode.M;
            config.TryGetConfig <int>("img2TechKeycode", ref v);
            img2TechKeycode = (KeyCode)v;

            OptionKey img2TechKey = new OptionKey("Image to tech toggle", "Procedural Blocks", img2TechKeycode);

            img2TechKey.onValueSaved.AddListener(() =>
            {
                img2TechKeycode           = img2TechKey.SavedValue;
                config["img2TechKeycode"] = (int)img2TechKeycode;
            });

            NativeOptionsMod.onOptionsSaved.AddListener(() =>
            {
                config.WriteConfigJsonFile();
            });


            var harmony = new Harmony("exund.prodcedural.blocks");

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            _holder = new GameObject();
            _holder.AddComponent <ProceduralEditor>();
            _holder.AddComponent <ImageToTech>();
            _holder.AddComponent <ColorTools>();
            UnityEngine.Object.DontDestroyOnLoad(_holder);

            var t = new Texture2D(1, 1);

            t.SetPixel(0, 0, Color.white);

            Material mat = GameObjectJSON.MaterialFromShader();

            mat.mainTexture = Texture2D.whiteTexture;
            mat.name        = "ProceduralMaterial";

            var cube1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube1.GetComponent <MeshRenderer>().material.color       = Color.white;
            cube1.GetComponent <MeshRenderer>().material.mainTexture = t;
            var color_block = new BlockPrefabBuilder()
                              .SetBlockID(7000, "64965b4027b723b16d1c")
                              .SetName("Color Block")
                              .SetDescription("A block that can change color (right click to edit)")
                              .SetFaction(FactionSubTypes.SPE)
                              .SetCategory(BlockCategories.Standard)
                              .SetGrade()
                              .SetHP(250)
                              .SetMass(1)
                              .SetModel(cube1.GetComponent <MeshFilter>().sharedMesh, cube1.GetComponent <MeshFilter>().sharedMesh, true, mat)
                              .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                              .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Path.Combine(AssetsFolder, "Icons/colorblock_icon.png"))))
                              .AddComponent <ModuleColor>();

            color_block.RegisterLater();
            GameObject.Destroy(cube1);

            var cube = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Block.obj"));

            cube.name = "ProceduralMesh";
            var procedural_block = new BlockPrefabBuilder()
                                   .SetBlockID(7001, "fd49964942512e91ec41")
                                   .SetName("Procedural Block")
                                   .SetDescription("A block that can change size")
                                   .SetFaction(FactionSubTypes.EXP)
                                   .SetCategory(BlockCategories.Standard)
                                   .SetGrade()
                                   .SetHP(250)
                                   .SetMass(1)
                                   .SetModel(cube, cube, true, mat)
                                   .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                                   .AddComponent <ModuleProcedural>()
                                   .AddComponent <ModuleColor>();

            procedural_block.RegisterLater();

            var cylinder = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Cylinder.obj"));

            cylinder.name = "ProceduralMesh";
            var procedural_cylinder = new BlockPrefabBuilder()
                                      .SetBlockID(7002, "8ccfce9497e1ace52d5b")
                                      .SetName("Procedural Cylinder")
                                      .SetDescription("A cylinder that can change size")
                                      .SetFaction(FactionSubTypes.EXP)
                                      .SetCategory(BlockCategories.Standard)
                                      .SetGrade()
                                      .SetHP(250)
                                      .SetMass(1)
                                      .SetModel(cylinder, cylinder, true, mat)
                                      .SetSize(IntVector3.one)
                                      .AddComponent <ModuleProceduralCylinder>()
                                      .AddComponent <ModuleColor>();

            procedural_cylinder.TankBlock.attachPoints = new Vector3[] { new Vector3(0, -0.5f, 0), new Vector3(0, 0.5f, 0) };
            procedural_cylinder.RegisterLater();

            var half = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Half Block.obj"));

            half.name = "ProceduralMesh";
            var procedural_half = new BlockPrefabBuilder()
                                  .SetBlockID(7003, "89c854222b7088b24b72")
                                  .SetName("Procedural Half Block")
                                  .SetDescription("A half block that can change size")
                                  .SetFaction(FactionSubTypes.EXP)
                                  .SetCategory(BlockCategories.Standard)
                                  .SetGrade()
                                  .SetHP(250 / 2)
                                  .SetMass(1)
                                  .SetModel(half, half, true, mat)
                                  .SetSize(IntVector3.one)
                                  .AddComponent <ModuleProceduralHalfBlock>()
                                  .AddComponent <ModuleColor>();

            procedural_half.TankBlock.attachPoints = new Vector3[] { new Vector3(0, -0.5f, 0), new Vector3(-0.5f, 0, 0), new Vector3(0, 0, -0.5f), new Vector3(0, 0, 0.5f) };
            procedural_half.RegisterLater();

            var corner2 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Corner (2-way).obj"));

            corner2.name = "ProceduralMesh";
            var procedural_corner_2 = new BlockPrefabBuilder()
                                      .SetBlockID(7004, "3302c74153a768f81be1")
                                      .SetName("Procedural Corner (2-way)")
                                      .SetDescription("A corner that can change size")
                                      .SetFaction(FactionSubTypes.EXP)
                                      .SetCategory(BlockCategories.Standard)
                                      .SetGrade()
                                      .SetHP(250)
                                      .SetMass(1)
                                      .SetModel(corner2, corner2, true, mat)
                                      .SetSize(IntVector3.one)
                                      .AddComponent <ModuleProceduralCorner2>()
                                      .AddComponent <ModuleColor>();

            procedural_corner_2.TankBlock.attachPoints = new Vector3[] { new Vector3(0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, 0.5f) };
            procedural_corner_2.RegisterLater();

            var corner3 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Corner (3-way).obj"));

            corner3.name = "ProceduralMesh";
            var procedural_corner_3 = new BlockPrefabBuilder()
                                      .SetBlockID(7005, "5397ca4583307f7d37fe")
                                      .SetName("Procedural Corner (3-way)")
                                      .SetDescription("A corner that can change size")
                                      .SetFaction(FactionSubTypes.EXP)
                                      .SetCategory(BlockCategories.Standard)
                                      .SetGrade()
                                      .SetHP(250 / 3)
                                      .SetMass(1)
                                      .SetModel(corner3, corner3, true, mat)
                                      .SetSize(IntVector3.one)
                                      .AddComponent <ModuleProceduralCorner3>()
                                      .AddComponent <ModuleColor>();

            procedural_corner_3.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f) };
            procedural_corner_3.RegisterLater();

            var rounded = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Rounded Half Block.obj"));

            rounded.name = "ProceduralMesh";
            var procedural_rounded = new BlockPrefabBuilder()
                                     .SetBlockID(7006, "be4c9e7859e29073aec0")
                                     .SetName("Procedural Rounded Half Block")
                                     .SetDescription("A rounded half block that can change size")
                                     .SetFaction(FactionSubTypes.EXP)
                                     .SetCategory(BlockCategories.Standard)
                                     .SetGrade()
                                     .SetHP(250 / 2)
                                     .SetMass(1)
                                     .SetModel(rounded, rounded, true, mat)
                                     .SetSize(IntVector3.one)
                                     .AddComponent <ModuleProceduralRoundedHalfBlock>()
                                     .AddComponent <ModuleColor>();

            procedural_rounded.TankBlock.attachPoints = new Vector3[] { new Vector3(0, -0.5f, 0), new Vector3(-0.5f, 0, 0), new Vector3(0, 0, -0.5f), new Vector3(0, 0, 0.5f) };
            procedural_rounded.RegisterLater();

            var sphere = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Sphere.obj"));

            sphere.name = "ProceduralMesh";
            var procedural_sphere = new BlockPrefabBuilder()
                                    .SetBlockID(7007, "88df56b7bc96edd1e288")
                                    .SetName("Procedural Sphere")
                                    .SetDescription("A sphere that can change size")
                                    .SetFaction(FactionSubTypes.EXP)
                                    .SetCategory(BlockCategories.Standard)
                                    .SetGrade()
                                    .SetHP(250)
                                    .SetMass(1)
                                    .SetModel(sphere, sphere, true, mat)
                                    .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                                    .AddComponent <ModuleProcedural>()
                                    .AddComponent <ModuleColor>();

            procedural_sphere.RegisterLater();

            var converter = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Cylinder-Cube Converter.obj"));

            converter.name = "ProceduralMesh";
            var procedural_converter = new BlockPrefabBuilder()
                                       .SetBlockID(7008, "92f1be44b016bb6e7e50")
                                       .SetName("Procedural Converter")
                                       .SetDescription("A cylinder that can change size")
                                       .SetFaction(FactionSubTypes.EXP)
                                       .SetCategory(BlockCategories.Standard)
                                       .SetGrade()
                                       .SetHP(250)
                                       .SetMass(1)
                                       .SetModel(converter, converter, true, mat)
                                       .SetSize(IntVector3.one)
                                       .AddComponent <ModuleProceduralConverter>()
                                       .AddComponent <ModuleColor>();

            procedural_converter.TankBlock.attachPoints = new Vector3[] { new Vector3(0, -0.5f, 0), new Vector3(0, 0.5f, 0) };
            procedural_converter.RegisterLater();

            var incorner2 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Inside Corner (2-way).obj"));

            incorner2.name = "ProceduralMesh";
            var procedural_incorner_2 = new BlockPrefabBuilder()
                                        .SetBlockID(7009, "d2976201068b86e4b7cc")
                                        .SetName("Procedural Inside Corner (2-way)")
                                        .SetDescription("A corner that can change size")
                                        .SetFaction(FactionSubTypes.EXP)
                                        .SetCategory(BlockCategories.Standard)
                                        .SetGrade()
                                        .SetHP(250)
                                        .SetMass(1)
                                        .SetModel(incorner2, incorner2, true, mat)
                                        .SetSize(IntVector3.one)
                                        .AddComponent <ModuleProceduralCorner2>(out ModuleProceduralCorner2 inverted2)
                                        .AddComponent <ModuleColor>();

            procedural_incorner_2.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f), new Vector3(0.5f, 0, 0), new Vector3(0, 0, 0.5f) };
            inverted2.inverted = true;
            procedural_incorner_2.RegisterLater();

            var incorner3 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Inside Corner (3-way).obj"));

            incorner3.name = "ProceduralMesh";
            var procedural_incorner_3 = new BlockPrefabBuilder()
                                        .SetBlockID(7010, "d85e864aad33b54a6028")
                                        .SetName("Procedural Inside Corner (3-way)")
                                        .SetDescription("A corner that can change size")
                                        .SetFaction(FactionSubTypes.EXP)
                                        .SetCategory(BlockCategories.Standard)
                                        .SetGrade()
                                        .SetHP(250 / 3)
                                        .SetMass(1)
                                        .SetModel(incorner3, incorner3, true, mat)
                                        .SetSize(IntVector3.one)
                                        .AddComponent <ModuleProceduralCorner3>(out ModuleProceduralCorner3 inverted3)
                                        .AddComponent <ModuleColor>();

            procedural_incorner_3.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f), new Vector3(0.5f, 0, 0), new Vector3(0, 0.5f, 0), new Vector3(0, 0, 0.5f) };
            inverted3.inverted = true;
            procedural_incorner_3.RegisterLater();

            var rounded_corner2 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Rounded Corner (2-way).obj"));

            rounded_corner2.name = "ProceduralMesh";
            var procedural_rounded_corner2 = new BlockPrefabBuilder()
                                             .SetBlockID(7011, "ab23c00ba9ab31d27e04")
                                             .SetName("Procedural Rounded Corner (2-way)")
                                             .SetDescription("A rounded corner that can change size")
                                             .SetFaction(FactionSubTypes.EXP)
                                             .SetCategory(BlockCategories.Standard)
                                             .SetGrade()
                                             .SetHP(250)
                                             .SetMass(1)
                                             .SetModel(rounded_corner2, rounded_corner2, true, mat)
                                             .SetSize(IntVector3.one)
                                             .AddComponent <ModuleProceduralRoundedCorner2>()
                                             .AddComponent <ModuleColor>();

            procedural_rounded_corner2.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f) };
            procedural_rounded_corner2.RegisterLater();

            var rounded_corner3 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Rounded Corner (3-way).obj"));

            rounded_corner3.name = "ProceduralMesh";
            var procedural_rounded_corner3 = new BlockPrefabBuilder()
                                             .SetBlockID(7012, "9630f2a69c42c30c0862")
                                             .SetName("Procedural Rounded Corner (3-way)")
                                             .SetDescription("A rounded corner that can change size")
                                             .SetFaction(FactionSubTypes.EXP)
                                             .SetCategory(BlockCategories.Standard)
                                             .SetGrade()
                                             .SetHP(250)
                                             .SetMass(1)
                                             .SetModel(rounded_corner3, rounded_corner3, true, mat)
                                             .SetSize(IntVector3.one)
                                             .AddComponent <ModuleProceduralRoundedCorner3>()
                                             .AddComponent <ModuleColor>();

            procedural_rounded_corner3.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f) };
            procedural_rounded_corner3.RegisterLater();

            var rounded_incorner2 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Inside Rounded Corner (2-way).obj"));

            rounded_incorner2.name = "ProceduralMesh";
            var procedural_rounded_incorner2 = new BlockPrefabBuilder()
                                               .SetBlockID(7013, "2381cf216f226ed2f537")
                                               .SetName("Procedural Inside Rounded Corner (2-way)")
                                               .SetDescription("A rounded corner that can change size")
                                               .SetFaction(FactionSubTypes.EXP)
                                               .SetCategory(BlockCategories.Standard)
                                               .SetGrade()
                                               .SetHP(250)
                                               .SetMass(1)
                                               .SetModel(rounded_incorner2, rounded_incorner2, true, mat)
                                               .SetSize(IntVector3.one)
                                               .AddComponent <ModuleProceduralRoundedCorner2>(out ModuleProceduralRoundedCorner2 invertedr2)
                                               .AddComponent <ModuleColor>();

            procedural_rounded_incorner2.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f) };
            invertedr2.inverted = true;
            procedural_rounded_incorner2.RegisterLater();

            var rounded_incorner3 = GameObjectJSON.MeshFromFile(Path.Combine(AssetsFolder, "Models/Standalone/Procedural Inside Rounded Corner (3-way).obj"));

            rounded_incorner3.name = "ProceduralMesh";
            var procedural_rounded_incorner3 = new BlockPrefabBuilder()
                                               .SetBlockID(7014, "eadb1d61f1dc3e7f1fc9")
                                               .SetName("Procedural Inside Rounded Corner (3-way)")
                                               .SetDescription("A rounded corner that can change size")
                                               .SetFaction(FactionSubTypes.EXP)
                                               .SetCategory(BlockCategories.Standard)
                                               .SetGrade()
                                               .SetHP(250)
                                               .SetMass(1)
                                               .SetModel(rounded_incorner3, rounded_incorner3, true, mat)
                                               .SetSize(IntVector3.one)
                                               .AddComponent <ModuleProceduralRoundedCorner3>(out ModuleProceduralRoundedCorner3 invertedr3)
                                               .AddComponent <ModuleColor>();

            procedural_rounded_incorner3.TankBlock.attachPoints = new Vector3[] { new Vector3(-0.5f, 0, 0), new Vector3(0, -0.5f, 0), new Vector3(0, 0, -0.5f) };
            invertedr3.inverted = true;
            procedural_rounded_incorner3.RegisterLater();


            var cube2 = GameObject.Instantiate(cube);

            cube2.name = "ProceduralMesh";
            var procedural_mesh_block = new BlockPrefabBuilder()
                                        .SetBlockID(7015)
                                        .SetName("Procedural Mesh Block")
                                        .SetDescription("A block that can change size")
                                        .SetFaction(FactionSubTypes.EXP)
                                        .SetCategory(BlockCategories.Standard)
                                        .SetGrade()
                                        .SetHP(250)
                                        .SetMass(1)
                                        .SetModel(cube2, true, mat)
                                        //.SetModel(cube2, cube2, true, mat)
                                        .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                                        .AddComponent <ModuleProceduralSlicedMesh>()
                                        .AddComponent <ModuleColor>();

            procedural_mesh_block.RegisterLater();

            if (!Directory.Exists(TechArtFolder))
            {
                Directory.CreateDirectory(TechArtFolder);
            }

            SlicedMeshJSON.LoadSets();
        }
Ejemplo n.º 9
0
        public static void CreateBlocks()
        {
            //var harmony = HarmonyInstance.Create("examplepack.changethisname");
            //harmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
            Material gso_mat = GameObjectJSON.GetObjectFromGameResources <Material>("GSO_Main"),
                     bf_mat  = GameObjectJSON.GetObjectFromGameResources <Material>("BF_Main");
            var host         = new GameObject("Motion Blocks singleton host");

            host.AddComponent <OptionMenuDensityShift>();
            host.AddComponent <GUIOverseer>();
            {
                var gso_rag = new BlockPrefabBuilder(/*"GSOBlock(111)", false*/) //Use a reference if you want quick functionality
                              .SetBlockID(9210)
                              .SetName("GSO Reflex Axis Gyro")
                              .SetDescription("This 'RAG' is capable of providing a corrective force against idle rotation, and give you the push you need for those sharp angles")
                              .SetPrice(6000)
                              .SetHP(1250)
                              .SetFaction(FactionSubTypes.GSO)
                              .SetCategory(BlockCategories.Accessories)
                              .SetIcon(GameObjectJSON.ImageFromFile(Properties.Resources.gso_reflex_axis_gyro_png))
                              .SetMass(8f)
                              .SetSizeManual(
                    new IntVector3[] {
                    IntVector3.zero, IntVector3.right, IntVector3.forward, new IntVector3(1, 0, 1)
                },
                    new Vector3[] {
                    new Vector3(0f, 0f, -0.5f), new Vector3(1f, 0f, -0.5f),
                    new Vector3(-0.5f, 0f, 0f), new Vector3(-0.5f, 0f, 1f),
                    new Vector3(0f, 0f, 1.5f), new Vector3(1f, 0f, 1.5f),
                    new Vector3(1.5f, 0f, 0f), new Vector3(1.5f, 0f, 1f)
                })
                              .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.gso_rag_base), true, gso_mat)
                              .AddComponent <ModuleReflexGyro>(out ModuleReflexGyro gyro)
                              .SetDeathExplosionReference((int)BlockTypes.GSOGyroAllAxisActive_111);
                GameObject drum = new GameObject("Gyro_Drum");
                drum.AddComponent <MeshFilter>().sharedMesh       = GameObjectJSON.MeshFromData(Properties.Resources.gso_rag_drum);
                drum.AddComponent <MeshRenderer>().sharedMaterial = gso_mat;
                drum.transform.parent        = gso_rag.Prefab.transform;
                drum.transform.localPosition = new Vector3(0.5f, 0f, 0.5f);
                gso_rag.RegisterLater();

                gyro.MaxStrength = 250f;
                gyro.Strength    = 200f;
                gyro.AllAxis     = false;
            }
            {
                var gso_ballast = new BlockPrefabBuilder()
                                  .SetBlockID(9211)
                                  .SetName("GSO Graviton Ballast")
                                  .SetDescription("Composed of a strange lead-like alloy which's gravitational influence can be altered through exposure to electromagnetic polarity")
                                  .SetPrice(750)
                                  .SetHP(600)
                                  .SetFaction(FactionSubTypes.GSO)
                                  .SetGrade(2)
                                  .SetCategory(BlockCategories.Accessories)
                                  .SetIcon(GameObjectJSON.ImageFromFile(Properties.Resources.gso_ballast_png))
                                  .SetMass(4)
                                  .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.All)
                                  .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.gso_ballast), true, gso_mat)
                                  .AddComponent <ModuleDensityShift>(out ModuleDensityShift module)
                                  .SetDeathExplosionReference((int)BlockTypes.GSOFabricator_322);
                GameObject weight = new GameObject("Ballast_Weight");
                weight.AddComponent <MeshFilter>().sharedMesh       = GameObjectJSON.MeshFromData(Properties.Resources.gso_ballast_weight);
                weight.AddComponent <MeshRenderer>().sharedMaterial = gso_mat;
                weight.transform.parent        = gso_ballast.Prefab.transform;
                weight.transform.localPosition = Vector3.zero;
                gso_ballast.RegisterLater();

                module.Range = new Vector2(4, 16);
            }
            {
                var bf_small_floater = new BlockPrefabBuilder("BF_Block_111")
                                       .SetName("Better Future Small Floater Tank")
                                       .SetDescription("When attached to a Tech, this tank heats Celestian Crystals contained within, sublimating these into Celestian Gas, which has high atmospheric buyoancy due to antigravity properties.\nHowever, at higher altitudes it has decreased effect, due to the thin atmosphere.")
                                       .SetBlockID(910601)
                                       .SetFaction(FactionSubTypes.BF)
                                       .SetCategory(BlockCategories.Flight)
                                       .SetGrade(1)
                                       .SetPrice(3096)
                                       .SetHP(400)
                                       .SetMass(0.3f)
                                       .SetIcon(GameObjectJSON.ImageFromFile(Properties.Resources.bf_small_floater_tank_png))
                                       .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.bf_small_floater_tank), true, bf_mat)
                                       .SetSize(new IntVector3(1, 1, 2), BlockPrefabBuilder.AttachmentPoints.Bottom)
                                       .AddComponent <ModuleFloater>(out ModuleFloater module)
                                       .RegisterLater();

                //module.Strength;
                CustomRecipe.RegisterRecipe(
                    new CustomRecipe.RecipeInput[]
                {
                    new CustomRecipe.RecipeInput(17, 1),
                    new CustomRecipe.RecipeInput(43, 1),
                    new CustomRecipe.RecipeInput(45, 1),
                    new CustomRecipe.RecipeInput(49, 1),
                },
                    new CustomRecipe.RecipeOutput[]
                {
                    new CustomRecipe.RecipeOutput(910601)
                }, NameOfFabricator: "bffab");
            }
        }
        public static void Load()
        {
            var harmony = HarmonyInstance.Create("exund.advancedbuilding");

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            assetBundle = AssetBundle.LoadFromFile(asm_path + "Assets/advancedbuilding");

            try
            {
                _holder = new GameObject();
                _holder.AddComponent <AdvancedEditor>();
                _holder.AddComponent <BlockPicker>();

                if (Directory.Exists(PreciseSnapshotsFolder))
                {
                    _holder.AddComponent <LoadWindow>();
                }


                UnityEngine.Object.DontDestroyOnLoad(_holder);

                transformGizmo         = Singleton.cameraTrans.gameObject.AddComponent <RuntimeGizmos.TransformGizmo>();
                transformGizmo.enabled = false;

                config.TryGetConfig <float>("position_step", ref AdvancedEditor.position_step);
                config.TryGetConfig <float>("rotation_step", ref AdvancedEditor.rotation_step);
                config.TryGetConfig <float>("scale_step", ref AdvancedEditor.scale_step);

                config.TryGetConfig <bool>("open_inventory", ref BlockPicker.open_inventory);
                config.TryGetConfig <bool>("global_filters", ref BlockPicker.global_filters);
                var key = (int)BlockPicker.block_picker_key;
                config.TryGetConfig <int>("block_picker_key", ref key);
                BlockPicker.block_picker_key = (KeyCode)key;

                config.TryGetConfig <bool>("clearOnCollapse", ref PaletteTextFilter.clearOnCollapse);

                var key2 = (int)PhysicsInfo.centers_key;
                config.TryGetConfig <int>("centers_key", ref key2);
                PhysicsInfo.centers_key = (KeyCode)key2;


                string    modName        = "Advanced Building";
                OptionKey blockPickerKey = new OptionKey("Block Picker activation key", modName, BlockPicker.block_picker_key);
                blockPickerKey.onValueSaved.AddListener(() =>
                {
                    BlockPicker.block_picker_key = blockPickerKey.SavedValue;
                    config["block_picker_key"]   = (int)BlockPicker.block_picker_key;
                });

                OptionToggle globalFilterToggle = new OptionToggle("Block Picker - Use global filters", modName, BlockPicker.global_filters);
                globalFilterToggle.onValueSaved.AddListener(() =>
                {
                    BlockPicker.global_filters = globalFilterToggle.SavedValue;
                    config["global_filters"]   = BlockPicker.global_filters;
                });

                OptionToggle openInventoryToggle = new OptionToggle("Block Picker - Automatically open the inventory when picking a block", modName, BlockPicker.open_inventory);
                openInventoryToggle.onValueSaved.AddListener(() =>
                {
                    BlockPicker.open_inventory = openInventoryToggle.SavedValue;
                    config["open_inventory"]   = BlockPicker.open_inventory;
                });

                OptionToggle clearOnCollapse = new OptionToggle("Block Search - Clear filter when closing inventory", modName, PaletteTextFilter.clearOnCollapse);
                clearOnCollapse.onValueSaved.AddListener(() =>
                {
                    PaletteTextFilter.clearOnCollapse = clearOnCollapse.SavedValue;
                    config["clearOnCollapse"]         = PaletteTextFilter.clearOnCollapse;
                });

                OptionKey centersKey = new OptionKey("Open physics info menu (Ctrl + ?)", modName, PhysicsInfo.centers_key);
                centersKey.onValueSaved.AddListener(() =>
                {
                    PhysicsInfo.centers_key = centersKey.SavedValue;
                    config["centers_key"]   = (int)PhysicsInfo.centers_key;
                });

                NativeOptionsMod.onOptionsSaved.AddListener(() =>
                {
                    config.WriteConfigJsonFile();
                });

                new BlockPrefabBuilder(BlockTypes.GSOBlock_111, true)
                .SetBlockID(7020)
                .SetName("Reticule Research Hadamard Superposer")
                .SetDescription("This block can register quantum fluctuations applied on the tech's blocks and stabilize them during the snapshot process.\n\n<b>Warning</b>: Can cause temporary quantum jumps if it enters in contact with zero-stasis gluons.\nUsed to activate Advanced Building.")
                .SetFaction(FactionSubTypes.EXP)
                .SetCategory(BlockCategories.Accessories)
                .SetRarity(BlockRarity.Rare)
                .SetPrice(58860)
                .SetRecipe(new Dictionary <ChunkTypes, int> {
                    { ChunkTypes.SeedAI, 5 }
                })
                .SetModel(GameObjectJSON.MeshFromFile(asm_path + "Assets/hadamard_superposer.obj"), true, GameObjectJSON.GetObjectFromGameResources <Material>("RR_Main"))
                .SetIcon(GameObjectJSON.ImageFromFile(asm_path + "Assets/hadamard_superposer.png"))
                .AddComponent <ModuleOffgridStore>()
                .RegisterLater();

                {
                    var ontop = new Material(assetBundle.LoadAsset <Shader>("OnTop"));
                    var go    = new GameObject();
                    var mr    = go.AddComponent <MeshRenderer>();
                    mr.material                        = ontop;
                    mr.material.mainTexture            = GameObjectJSON.ImageFromFile(asm_path + "Assets/CO.png");
                    mr.material.mainTexture.filterMode = FilterMode.Point;
                    var mf = go.AddComponent <MeshFilter>();
                    mf.sharedMesh = mf.mesh = GameObjectJSON.MeshFromFile(asm_path + "Assets/CO.obj");

                    var line = new GameObject();
                    var lr   = line.AddComponent <LineRenderer>();
                    lr.startWidth = 0.5f;
                    lr.endWidth   = 0;
                    lr.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero });
                    lr.useWorldSpace  = true;
                    lr.material       = ontop;
                    lr.material.color = lr.material.color.SetAlpha(1);
                    line.transform.SetParent(go.transform, false);

                    go.SetActive(false);
                    go.transform.SetParent(_holder.transform, false);

                    PhysicsInfo.COM = GameObject.Instantiate(go);
                    var commat = PhysicsInfo.COM.GetComponent <MeshRenderer>().material;
                    commat.color       = Color.yellow;
                    commat.renderQueue = 1;
                    PhysicsInfo.COM.GetComponentInChildren <LineRenderer>().enabled = false;

                    PhysicsInfo.COT = GameObject.Instantiate(go);
                    PhysicsInfo.COT.transform.localScale *= 0.8f;
                    var cotmat = PhysicsInfo.COT.GetComponent <MeshRenderer>().material;
                    cotmat.color       = Color.magenta;
                    cotmat.renderQueue = 3;
                    var COTlr = PhysicsInfo.COT.GetComponentInChildren <LineRenderer>();
                    COTlr.material.renderQueue = 2;
                    COTlr.startColor           = COTlr.endColor = Color.magenta;

                    PhysicsInfo.COL = GameObject.Instantiate(go);
                    PhysicsInfo.COL.transform.localScale *= 0.64f;
                    var colmat = PhysicsInfo.COL.GetComponent <MeshRenderer>().material;
                    colmat.color       = Color.cyan;
                    colmat.renderQueue = 5;
                    var COLlr = PhysicsInfo.COL.GetComponentInChildren <LineRenderer>();
                    COLlr.startColor           = COLlr.endColor = Color.cyan;
                    COLlr.material.renderQueue = 4;
                }

                _holder.AddComponent <PhysicsInfo>();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static void Load()
        {
            #region Blocks
            {
                Material mat = GameObjectJSON.MaterialFromShader()
                               .SetTexturesToMaterial(
                    Alpha: GameObjectJSON.ImageFromFile(Properties.Resources.bacon_material_png
                                                        )
                    );
                Material GSOMain = GameObjectJSON.GetObjectFromGameResources <Material>("GSO_Main");
                {
                    var bacon = new BlockPrefabBuilder(/*"GSOBlock(111)", true*/)
                                .SetBlockID(10000) // Eventually, IDs could be either simple numbers (with or without quotes), or strings preferably with an author/pack naming scheme. Such as "author:block"
                                .SetName("GSO Bacon strip")
                                .SetDescription("A long strip of bacon with bullet absoring grease.\n\nOriginating from back when the Nuterra API was still being worked on, and was the first block to be recovered after their vanish...\n" +
                                                "\n" +
                                                "<b>HeX</b>: uuuhhhhh\n" +
                                                "one day a pig was born\n" +
                                                "little did people know\n" +
                                                "it was the son of god\n" +
                                                "Jesus - the holy pig\n" +
                                                "was one day cruxified\n" +
                                                "he yelled\n" +
                                                "then turned into the bacon\n" +
                                                "<b>Aceba1</b>: ...I think I'll add that to the description of the block\n" +
                                                "<b>HeX</b>: yay\n" +
                                                "credit me\n" +
                                                "\n" +
                                                "  - <b>HeX</b>, 8/22/2018")
                                .SetPrice(500)
                                .SetFaction(FactionSubTypes.GSO)
                                .SetCategory(BlockCategories.Standard)
                                .SetSizeManual(
                        new IntVector3[] {
                        new IntVector3(0, 0, 0), new IntVector3(1, 0, 0), new IntVector3(2, 0, 0), new IntVector3(3, 0, 0)
                    },
                        new Vector3[] {
                        new Vector3(-.5f, 0f, 0f), new Vector3(0f, .5f, 0f), new Vector3(1f, -.5f, 0f),
                        new Vector3(2f, .5f, 0f), new Vector3(3f, -.5f, 0f), new Vector3(3.5f, 0f, 0f)
                    })
                                .SetMass(4)
                                .SetHP(3000)
                                .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.bacon), true, mat)
                                .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.bacon_icon_png)))
                                .SetDeathExplosionReference((int)BlockTypes.GSOBigBertha_845)
                                .SetRecipe(new Dictionary <ChunkTypes, int> {
                        { ChunkTypes.OleiteJelly, 4 },
                        { ChunkTypes.Wood, 4 }
                    })     // This is the cleaner way to set a recipe
                                .RegisterLater();


                    // Here is what needs to be done for the older way of making recipes below. They should both achieve the same thing

                    //CustomRecipe.RegisterRecipe( // This is the old way to make recipes
                    //    new CustomRecipe.RecipeInput[]
                    //    {
                    //        new CustomRecipe.RecipeInput((int)ChunkTypes.OleiteJelly, 4),
                    //        new CustomRecipe.RecipeInput((int)ChunkTypes.Wood, 4)
                    //    },
                    //    new CustomRecipe.RecipeOutput[]
                    //    {
                    //        new CustomRecipe.RecipeOutput(bacon.RuntimeID)
                    //    });
                } // Bacon
                {
                    var banagun = new BlockPrefabBuilder("GSOMGunFixed(111)", false);
                    banagun.SetBlockID(10001)
                    .SetName("GSO Banana gun")
                    .SetDescription("A very special banana. But not as special as you are, your banana friend tells us.\n\nBefore the official release of TerraTech 1.0, there was a mod called the <b>UltiMod</b>. A collection of mods that added things like the water mod, block replacements, 'improved' EXP joints, and various tools & keybind options. This banana gun was part of the block replacement mod, which back then only reskinned existing blocks.\nBits of code from the <b>UltiMod</b> still persist in mods after 1.0, no longer stuck under one title.\n\nWe've come a long way...")
                    .SetPrice(297)
                    .SetFaction(FactionSubTypes.GSO)
                    .SetCategory(BlockCategories.Weapons)
                    .SetHP(200)
                    .SetRecipe(ChunkTypes.PlumbiteOre, ChunkTypes.LuxiteShard, ChunkTypes.LuxiteShard);
                    // Another way to set recipes for a block. Resembles the string/array system for JSON-Blocks

                    MeshFilter[] componentsInChildren2 = banagun.TankBlock.GetComponentsInChildren <MeshFilter>(true);

                    Texture2D main  = GameObjectJSON.ImageFromFile(Properties.Resources.banana_material_png);
                    Texture2D gloss = GameObjectJSON.ImageFromFile(Properties.Resources.banana_gloss_material_png);

                    Material changemat2 = GameObjectJSON.MaterialFromShader().SetTexturesToMaterial(main, gloss);

                    foreach (MeshFilter mes in componentsInChildren2) // This somewhat mimics the JSON-Block parser...
                    {
                        string name = mes.name;
                        if (name == "m_MuzzleFlash_01")
                        {
                            mes.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", GameObjectJSON.ImageFromFile(Properties.Resources.banana_blast_material_png));
                        }
                        else
                        {
                            if (name == "m_GSO_MgunFixed_111_Barrel")
                            {
                                mes.mesh = GameObjectJSON.MeshFromData(Properties.Resources.banana_barrel);
                            }
                            else if (name == "m_GSO_MgunFixed_111_Body")
                            {
                                mes.mesh = GameObjectJSON.MeshFromData(Properties.Resources.banana_body);
                            }
                            else if (name == "m_GSO_MgunFixed_111_Base")
                            {
                                mes.mesh = GameObjectJSON.MeshFromData(Properties.Resources.banana_base);
                            }
                            else
                            {
                                Component.DestroyImmediate(mes);
                                continue;
                            }
                            mes.GetComponent <MeshRenderer>().material = changemat2;
                        }
                    }
                    var firedata = banagun.Prefab.GetComponent <FireData>();
                    firedata.m_MuzzleVelocity      *= 1.6f;
                    firedata.m_BulletSprayVariance *= 0.3f;
                    firedata.m_KickbackStrength    *= 1.6f;
                    var newbullet = GameObject.Instantiate(firedata.m_BulletPrefab);
                    newbullet.gameObject.SetActive(false);
                    var lr        = newbullet.gameObject.GetComponent <LineRenderer>();
                    var colorKeys = lr.colorGradient.colorKeys;
                    for (int i = 0; i < colorKeys.Length; i++)
                    {
                        var color = colorKeys[i];
                        colorKeys[i] = new GradientColorKey(new Color(color.color.r, color.color.g, 0), color.time);
                    }
                    typeof(WeaponRound).GetField("m_Damage", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(newbullet, 100);
                    firedata.m_BulletPrefab = newbullet;
                    banagun.SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.banana_icon_png)))
                    .RegisterLater();
                } // Banana Gun
                {
                    var cockpit_s = new BlockPrefabBuilder("GSOLightStud(111)", true)
                                    .SetBlockID(9000)
                                    .SetName("GSO Top Cockpit")
                                    .SetDescription("Pop in here and have a first-person look at the world from this block! (The side with the diamond is the viewing direction)\n\nRight click and drag to look and Cycle views with R (and backwards with Shift held down)")
                                    .SetPrice(300)
                                    .SetHP(500)
                                    .SetFaction(FactionSubTypes.GSO)
                                    .SetCategory(BlockCategories.Accessories)
                                    .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.cockpit_small), true, GSOMain)
                                    .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.cockpit_small_icon_png)))
                                    .SetSize(IntVector3.one, BlockPrefabBuilder.AttachmentPoints.Bottom)
                                    .SetRecipe(new Dictionary <ChunkTypes, int> {
                        { ChunkTypes.PlumbiteOre, 2 },
                        { ChunkTypes.RoditeOre, 1 },
                        { ChunkTypes.RubberJelly, 2 }
                    });

                    var view = new GameObject("FirstPersonAnchor");
                    view.AddComponent <ModuleFirstPerson>();
                    view.transform.parent = cockpit_s.TankBlock.transform;

                    cockpit_s.RegisterLater();
                } // GSO Top FPV
                {
                    var cockpit_s2 = new BlockPrefabBuilder(BlockTypes.GSOLightStud_111, true) // "GSOLightStud(111)"
                                     .SetBlockID(9005)
                                     .SetName("GSO Sided Swerve Cockpit")
                                     .SetDescription("Just like the other cockpit, but can be mounted on the sides of things for a better look at your surroundings! Note: Orientation requires adjusting\n\nRight click and drag to look and Cycle views with R (and backwards with Shift held down)")
                                     .SetPrice(300)
                                     .SetHP(500)
                                     .SetFaction(FactionSubTypes.GSO)
                                     .SetCategory(BlockCategories.Accessories)
                                     .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.cockpit_small_2), true, GSOMain)
                                     .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.cockpit_small_2_icon_png)))
                                     .SetSizeManual(new IntVector3[] { IntVector3.zero }, new Vector3[] { Vector3.down * 0.5f, Vector3.back * 0.5f })
                                     .SetRecipe(new Dictionary <ChunkTypes, int> {
                        { ChunkTypes.PlumbiteOre, 3 },
                        { ChunkTypes.RodiusCapsule, 1 },
                        { ChunkTypes.RubberJelly, 2 }
                    });

                    var view1 = new GameObject("FirstPersonAnchor");
                    view1.AddComponent <ModuleFirstPerson>();
                    view1.transform.parent   = cockpit_s2.TankBlock.transform;
                    view1.transform.rotation = Quaternion.Euler(-90, 0, 0);

                    cockpit_s2.RegisterLater();
                } // GSO Front FPV
                {
                    var cockpit_l = new BlockPrefabBuilder(11, Vector3.one * 0.5f, true) /*"GSOLightStud(111)"*/
                                    .SetBlockID(9001)
                                    .SetName("GSO Observatory")
                                    .SetDescription("Mount this gigantic hamsterball to your tech to be right in the action!\nThis reorients itself to the direction of the cab\n\nRight click and drag to look and Cycle views with R (and backwards with Shift held down)\n\nAnother recovery from the original Nuterra API, along with the FPV Top Cockpit. This model remains intact.")
                                    .SetPrice(500)
                                    .SetHP(2500)
                                    .SetGrade(1)
                                    .SetFaction(FactionSubTypes.GSO)
                                    .SetCategory(BlockCategories.Accessories)
                                    .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.cockpit_large), true, GSOMain)
                                    .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.cockpit_large_icon_png)))
                                    .SetSize(IntVector3.one * 2, BlockPrefabBuilder.AttachmentPoints.Bottom)
                                    .SetRecipe(new Dictionary <ChunkTypes, int> {
                        { ChunkTypes.PlumbiaIngot, 6 },
                        { ChunkTypes.RodiusCapsule, 3 },
                        { ChunkTypes.ErudianCrystal, 2 },
                        { ChunkTypes.RubberJelly, 3 }
                    });

                    var view2 = new GameObject("FirstPersonAnchor");
                    view2.AddComponent <ModuleFirstPerson>().AdaptToMainRot = true;
                    view2.transform.parent        = cockpit_l.TankBlock.transform;
                    view2.transform.localPosition = Vector3.one * 0.5f;

                    cockpit_l.RegisterLater();
                } // GSO Dome FPV
                {
                    var cockpit_ven = new BlockPrefabBuilder(BlockTypes.VENLightStud_111, Vector3.forward * 0.5f, true)
                                      .SetBlockID(9002)//, "517376c14c30592c")
                                      .SetName("VEN Observatory")
                                      .SetDescription("A slim, lower observatory that could fit nice on top or below a plane\nThis reorients itself to the direction of the cab\n\nRight click and drag to look and Cycle views with R (and backwards with Shift held down)\n\nRedesign provided by <b>Mr. Starch</b>")
                                      .SetPrice(500)
                                      .SetHP(2500)
                                      .SetGrade(1)
                                      .SetFaction(FactionSubTypes.VEN)
                                      .SetCategory(BlockCategories.Accessories)
                                      .SetModel(GameObjectJSON.MeshFromData(Properties.Resources.cockpit_ven), true, GameObjectJSON.GetObjectFromGameResources <Material>("VEN_Main"))
                                      .SetIcon(GameObjectJSON.SpriteFromImage(GameObjectJSON.ImageFromFile(Properties.Resources.cockpit_ven_icon_png)))
                                      .SetSize(new IntVector3(1, 1, 2), BlockPrefabBuilder.AttachmentPoints.Bottom)
                                      .SetRecipe(new Dictionary <ChunkTypes, int> {
                        { ChunkTypes.PlumbiaIngot, 2 },
                        { ChunkTypes.RodiusCapsule, 1 },
                        { ChunkTypes.TitaniaIngot, 1 },
                        { ChunkTypes.RubberJelly, 3 }
                    });

                    var view3 = new GameObject("FirstPersonAnchor");
                    view3.AddComponent <ModuleFirstPerson>().AdaptToMainRot = true;
                    view3.transform.parent        = cockpit_ven.TankBlock.transform;
                    view3.transform.localPosition = Vector3.forward * 0.5f + Vector3.down * 0.1f;

                    cockpit_ven.RegisterLater();
                } // VEN Slim FPV
            }
            #endregion

            var thng  = new GameObject();
            var thnng = thng.AddComponent <FirstPersonCamera>();
            BlockLoader.DelayAfterSingleton(thnng.Manual_Awake);
        }
 public static Material SetTexturesToMaterial(this Material material, Texture2D Alpha = null, Texture2D MetallicGloss = null, Texture2D Emission = null, bool MakeCopy = false) => GameObjectJSON.SetTexturesToMaterial(MakeCopy, material, Alpha, MetallicGloss, Emission);
Ejemplo n.º 13
0
        private static void CreateJSONCorp(FileInfo Json, bool l = false)
        {
            try
            {
                L("Get locals for " + Json.Name, l);
                JObject     jObject = JObject.Parse(DirectoryBlockLoader.StripComments(File.ReadAllText(Json.FullName)));
                CorpBuilder jCorp   = jObject.ToObject <CorpBuilder>(new JsonSerializer()
                {
                    MissingMemberHandling = MissingMemberHandling.Ignore
                });

                L("Read JSON", l);
                bool CorpAlreadyExists = BlockLoader.CustomCorps.TryGetValue(jCorp.ID, out var ExistingJSONCorp);
                if (CorpAlreadyExists)
                {
                    string name = ExistingJSONCorp.Name;
                    Console.WriteLine("Could not read corp " + Json.Name + "\n at " + Json.FullName + "\n\nCorp ID collides with " + name);
                    return;
                }

                CustomCorporation corp = new CustomCorporation(jCorp.ID, jCorp.Name);

                if (jCorp.GradesAmount != 0)
                {
                    L("Set GradesAmount", l);
                    corp.GradesAmount = jCorp.GradesAmount;
                }

                if (jCorp.XPLevels != null)
                {
                    L("Set XPLevels", l);
                    corp.XPLevels = jCorp.XPLevels;
                }

                corp.HasLicense = false;// jCorp.HasLicense;

                if (!jCorp.CorpIconName.NullOrEmpty())
                {
                    L("Set CorpIcon", l);
                    var Spr = GameObjectJSON.GetObjectFromUserResources <Sprite>(jCorp.CorpIconName);
                    if (Spr != null)
                    {
                        corp.CorpIcon = Spr;
                    }
                }

                if (!jCorp.SelectedCorpIconName.NullOrEmpty())
                {
                    L("Set SelectedCorpIcon", l);
                    var Spr = GameObjectJSON.GetObjectFromUserResources <Sprite>(jCorp.SelectedCorpIconName);
                    if (Spr != null)
                    {
                        corp.SelectedCorpIcon = Spr;
                    }
                }

                if (!jCorp.ModernCorpIconName.NullOrEmpty())
                {
                    L("Set ModernCorpIcon", l);
                    var Spr = GameObjectJSON.GetObjectFromUserResources <Sprite>(jCorp.ModernCorpIconName);
                    if (Spr != null)
                    {
                        corp.ModernCorpIcon = Spr;
                    }
                }

                /*if (!jCorp.Material.Equals(default(CorpMaterial)))
                 * {
                 *  L("Set Material");
                 *  Console.WriteLine(jCorp.Material.TextureName + " " + jCorp.Material.MetallicTextureName + " " + jCorp.Material.EmissionTextureName);
                 *  Material corpMat = GameObjectJSON.GetObjectFromGameResources<Material>("GSO_Main");
                 *  corpMat = GameObjectJSON.SetTexturesToMaterial(true, corpMat,
                 *          jCorp.Material.TextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources<Texture2D>(jCorp.Material.TextureName),
                 *          jCorp.Material.MetallicTextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources<Texture2D>(jCorp.Material.MetallicTextureName),
                 *          jCorp.Material.EmissionTextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources<Texture2D>(jCorp.Material.EmissionTextureName));
                 *  corpMat.name = corp.Name + "_Main";
                 *  GameObjectJSON.AddToResourceCache(corpMat, corpMat.name);
                 *  corp.Material = corpMat;
                 * }*/

                if (!jCorp.SkinInfo.Equals(default(CorpSkinInfo)))
                {
                    var Material = jCorp.SkinInfo.Material;
                    if (!Material.Equals(default(CorpMaterial)))
                    {
                        var Albedo   = Material.TextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(Material.TextureName);
                        var Metallic = Material.MetallicTextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(Material.MetallicTextureName);
                        var Emissive = Material.EmissionTextureName.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(Material.EmissionTextureName);


                        L("Set Material", l);
                        Material corpMat = GameObjectJSON.GetObjectFromGameResources <Material>("GSO_Main");
                        corpMat      = GameObjectJSON.SetTexturesToMaterial(true, corpMat, Albedo, Metallic, Emissive);
                        corpMat.name = corp.Name + "_Main";
                        GameObjectJSON.AddToResourceCache(corpMat, corpMat.name);
                        corp.Material = corpMat;

                        L("Set Skin basis", l);
                        corp.SkinInfo = ScriptableObject.CreateInstance <CorporationSkinInfo>();
                        corp.SkinInfo.m_Corporation     = (FactionSubTypes)corp.CorpID;
                        corp.SkinInfo.m_SkinUniqueID    = 0;
                        corp.SkinInfo.m_SkinTextureInfo = new SkinTextures
                        {
                            m_Albedo   = Albedo,
                            m_Emissive = Emissive,
                            m_Metal    = Metallic,
                        };

                        var SkinUIInfo = jCorp.SkinInfo.SkinUIInfo;

                        var Preview    = SkinUIInfo.PreviewImage.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(SkinUIInfo.PreviewImage);
                        var Button     = SkinUIInfo.ButtonImage.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(SkinUIInfo.ButtonImage);
                        var ButtonMini = SkinUIInfo.MiniPaletteImage.NullOrEmpty() ? null : GameObjectJSON.GetObjectFromUserResources <Texture2D>(SkinUIInfo.MiniPaletteImage);

                        var preview = Preview != null?GameObjectJSON.SpriteFromImage(Preview) : GameObjectJSON.SpriteFromImage(Albedo);

                        var button = Button != null?GameObjectJSON.SpriteFromImage(Button) : preview;

                        var buttonMini = ButtonMini != null?GameObjectJSON.SpriteFromImage(ButtonMini) : button;

                        corp.SkinInfo.m_SkinUIInfo = new CorporationSkinUIInfo()
                        {
                            m_LocalisedString = new LocalisedString()
                            {
                                m_Bank = corp.Name
                            },
                            m_PreviewImage         = preview,
                            m_SkinButtonImage      = button,
                            m_SkinMiniPaletteImage = buttonMini,
                            m_SkinLocked           = false
                        };
                    }
                }

                corp.Register();
            }
            catch (Exception E)
            {
                Console.WriteLine("Could not read corp " + Json.Name + "\n at " + Json.FullName + "\n\n" + E);
                BlockLoader.Timer.Log($" ! Could not read #{Json.Name} - \"{E.Message}\"");
            }
        }