コード例 #1
0
        // Token: 0x06000D5C RID: 3420 RVA: 0x0005B1A0 File Offset: 0x000593A0
        public static bool LoadMod(ModContainer mod)
        {
            bool result = true;

            foreach (ModInfo.AssemblyInfo assemblyInfo in mod.Info.Assemblies)
            {
                assemblyInfo.Mod = mod;
                assemblyInfo.Resolve();
                ModAssembly item;
                if (!ValidateAssembly(assemblyInfo, out item))
                {
                    MLog.Error(string.Concat(new string[]
                    {
                        "Assembly for ",
                        mod.Info.Name,
                        " did not validate, not loading it! (",
                        assemblyInfo.Path,
                        ")"
                    }));
                    result = false;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("[SUCSESS] Mod Loaded :D");
                }
            }
            return(result);
        }
コード例 #2
0
 public ScriptLoader(ModContainer <ScriptLoader> modContainer)
 {
     ScriptsPath = Path.Combine(modContainer.Directory, "scripts");
     Directory.CreateDirectory(ScriptsPath);
     Utilities.KnownPaths["Scripts"] = ScriptsPath;
     Instance = this;
 }
コード例 #3
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
        private static void RegisterOverrideService(string service, ModContainer mod)
        {
            if (OverrideServices.ContainsKey(service))
            {
                Utils.Log($"Competing services of type {service} from {mod.GetModInfo.ModName} and {OverrideServices[service].GetModInfo.ModName}");
            }

            OverrideServices[service] = mod;
        }
コード例 #4
0
 // Token: 0x06000F8A RID: 3978 RVA: 0x00066EA8 File Offset: 0x000650A8
 public static string GetAssemblyPath(ModContainer mod, string assemblyName)
 {
     return(Path.Combine(ModPaths.GetAssemblyDirectory(), string.Concat(new object[]
     {
         mod.Info.Id,
         "_",
         assemblyName,
         ".dll"
     })));
 }
コード例 #5
0
        public DrawableScore(Score score, double?weight = null)
        {
            this.score  = score;
            this.weight = weight;

            Children = new Drawable[]
            {
                new DrawableRank(score.Rank)
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = 60,
                    FillMode         = FillMode.Fit,
                },
                stats = new FillFlowContainer <OsuSpriteText>
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Anchor           = Anchor.CentreRight,
                    Origin           = Anchor.CentreRight,
                    Direction        = FillDirection.Vertical,
                },
                metadata = new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Anchor           = Anchor.CentreLeft,
                    Origin           = Anchor.CentreLeft,
                    Margin           = new MarginPadding {
                        Left = 70
                    },
                    Direction = FillDirection.Vertical,
                    Child     = new OsuSpriteText
                    {
                        Text     = score.Date.LocalDateTime.ToShortDateString(),
                        TextSize = 11,
                        Colour   = OsuColour.Gray(0xAA),
                        Depth    = -1,
                    },
                },
                modContainer = new ModContainer
                {
                    AutoSizeAxes = Axes.Y,
                    Anchor       = Anchor.CentreRight,
                    Origin       = Anchor.CentreRight,
                    Width        = 60,
                    Margin       = new MarginPadding {
                        Right = 150
                    }
                }
            };
        }
コード例 #6
0
ファイル: ModEngine.cs プロジェクト: egg82/Egg82LibEnhanced
        public ModContainer GetMod(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            ModContainer retVal = null;

            if (mods.TryGetValue(name, out retVal))
            {
                return(retVal);
            }
            return(null);
        }
コード例 #7
0
        static void testFile(string fn)
        {
            if (File.Exists(fn))
            {
                //var mc = LoadModInfoFrom(new DirectoryInfo(fn));
                //Console.WriteLine(mc.Info);
                //Console.WriteLine(mc.HadLoadOrActivateErrors);
                //Console.WriteLine(mc.IsActive.ToString());
                //Console.WriteLine(mc.CurrentState);
                //foreach (var assembly in mc.Assemblies)
                //{
                //    Console.WriteLine("[AssemblyInfo] " + assembly.Info);
                //    Console.WriteLine("[AssemblyInfo] " + assembly.HasModEntryPoint.ToString());
                //    Console.WriteLine("[AssemblyInfo] " + assembly.Assembly.FullName);
                //}
                //Console.ReadLine();

                ModInfo mi = new ModInfo();
                mi.Author     = "Testing";
                mi.Assemblies = new List <ModInfo.AssemblyInfo>();
                mi.Assemblies.Add(new ModInfo.AssemblyInfo()
                {
                    FileName = fn.Split('\\').Last(),
                    Path     = fn,
                });
                mi.DebugEnabled          = true;
                mi.FromWorkshop          = false;
                mi.Name                  = fn.Split('\\').Last().Replace(".dll", "");
                mi.MultiplayerCompatible = true;
                Guid guid;
                Guid.TryParse("df4de75b-fa7d-42ca-aa6c-fa512ffb5729", out guid);
                mi.Id = guid;

                ModContainer mc = new ModContainer(mi);
                mc.IsEnabled = true;


                AssemblyLoader.LoadMod(mc); //C:\Program Files (x86)\Steam\steamapps\common\Besiege\Besiege_Data\Mods\testtings Project\testtings\testingtings.dll
                Console.ForegroundColor = ConsoleColor.Magenta;
                //Console.WriteLine($"[INFO] ModIO Path: {GetFilePath(mi.Directory,  )}");

                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Path doesnt exist!");
            }
        }
コード例 #8
0
ファイル: ModEngine.cs プロジェクト: egg82/Egg82LibEnhanced
        //public
        public void LoadMod(string name, string path)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (!FileUtil.PathExists(path))
            {
                throw new Exception("path does not exist.");
            }
            if (!FileUtil.PathIsFile(path))
            {
                throw new Exception("path is not a file.");
            }

            AppDomain domain = AppDomain.CreateDomain(name);

            ServiceLocator.GetService <IExceptionHandler>().AddDomain(domain);
            Type    t   = typeof(ModBase);
            ModBase mod = null;

            try {
                mod = (ModBase)domain.CreateInstanceFromAndUnwrap(path, t.Name);
            } catch (Exception ex) {
                throw new Exception("Cannot create instance of mod.", ex);
            }
            if (mod == null)
            {
                throw new Exception("Cannot create instance of mod.");
            }

            mod.Load();

            if (mods.ContainsKey(name))
            {
                mods[name].Dispose();
                mods[name] = new ModContainer(domain, mod);
            }
            else
            {
                mods.TryAdd(name, new ModContainer(domain, mod));
            }
        }
コード例 #9
0
ファイル: ModEngine.cs プロジェクト: egg82/Egg82LibEnhanced
        public void RemoveMod(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            ModContainer retVal = null;

            if (mods.TryGetValue(name, out retVal))
            {
                retVal.Dispose();
                ServiceLocator.GetService <IExceptionHandler>().RemoveDomain(retVal.Domain);
                AppDomain.Unload(retVal.Domain);
                mods.TryRemove(name, out _);
            }
        }
コード例 #10
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
        /// <summary>
        /// Registers a mod as a worker for the given <typeparamref name="workType"/>
        /// Creates a new worktype when passed a type not yet in the list.
        /// </summary>
        /// <param name="mod">Mod.</param>
        /// <typeparam name="workType">Exported from HardTimes: BaseItem, Shop, BaseNPCManager</typeparam>
        public static void RegisterWorker <workType>(ModContainer mod)
        {
            if (!Workers.ContainsKey(typeof(workType)))
            {
                Utils.Log($"New worktype {typeof(workType)} being sideloaded.", "Experimental");
                Workers.Add(typeof(workType), new List <ModContainer>());
            }

            List <ModContainer> typeWorkers = Workers[typeof(workType)];

            if (typeWorkers.Contains(mod))
            {
                Utils.Log($"{mod.GetModInfo.ModName} has registered as workerType {typeof(workType)} multiple times.");
                return;
            }

            Utils.Log($"Registered new worker {mod.GetModInfo.ModName}|{typeof(workType)}", "WorkerReg");

            typeWorkers.Add(mod);
        }
コード例 #11
0
        public T setRegistryName(ResourceLocation name)
        {
            if (getRegistryName() != null)
            {
                throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());
            }

            int    index     = name.ToString().LastIndexOf(':');
            String oldPrefix = index == -1 ? "" : name.ToString().Substring(0, index).ToLower();

            name = index == -1 ? name : name.ToString().Substring(index + 1);
            ModContainer mc     = Loader.instance().activeModContainer();
            String       prefix = mc == null || (mc.GetType() == typeof(InjectedModContainer) && ((InjectedModContainer)mc).wrappedContainer == FMLContainer) ? "minecraft" : mc.getModId().ToLower();

            if (!oldPrefix.Equals(prefix) && oldPrefix.Length > 0)
            {
                //FMLLog.log.info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
                prefix = oldPrefix;
            }
            registryName = new ResourceLocation(prefix, name.ToString());
            return(this);
        }
コード例 #12
0
        // Token: 0x06000D5D RID: 3421 RVA: 0x0005B280 File Offset: 0x00059480
        public bool ActivateMod(ModContainer mod)
        {
            bool result = true;

            foreach (ModAssembly modAssembly in mod.Assemblies)
            {
                if (!this.LoadAssembly(modAssembly))
                {
                    result = false;
                }
                else if (modAssembly.HasModEntryPoint)
                {
                    modAssembly.ModEntryPoint.ModContainer = mod;
                    if (!this.InitializeAssembly(modAssembly))
                    {
                        result = false;
                        MLog.Error("There was an error activating assembly: " + modAssembly.Assembly.GetName().Name);
                    }
                }
            }
            return(result);
        }
コード例 #13
0
        // Token: 0x06000D55 RID: 3413 RVA: 0x0005AF34 File Offset: 0x00059134
        public static string ResolveScriptAssembly(string codeDir, ModContainer mod)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(codeDir);

            if (!directoryInfo.Exists)
            {
                MLog.Error("Code directory " + codeDir + " does not exist!");
                return(string.Empty);
            }
            string assemblyPath = ModPaths.GetAssemblyPath(mod, directoryInfo.Name);

            if (File.Exists(assemblyPath))
            {
                return(assemblyPath);
            }
            CompilerParameters compilerParameters = new CompilerParameters
            {
                GenerateExecutable = false,
                GenerateInMemory   = false,
                OutputAssembly     = assemblyPath
            };

            compilerParameters.ReferencedAssemblies.AddRange((from a in AppDomain.CurrentDomain.GetAssemblies().Where(delegate(Assembly a)
            {
                bool result;
                try
                {
                    result = !string.IsNullOrEmpty(a.Location);
                }
                catch (NotSupportedException)
                {
                    result = false;
                }
                return(result);
            })
                                                              select a.Location).ToArray <string>());
            string[] array = (from f in directoryInfo.GetFiles("*.cs", SearchOption.AllDirectories)
                              select f.FullName).ToArray <string>();
            if (array.Length == 0)
            {
                MLog.Error("Code directory " + codeDir + " does not contain any source files!");
            }
            CSharpCompiler.CodeCompiler codeCompiler    = new CSharpCompiler.CodeCompiler();
            CompilerResults             compilerResults = codeCompiler.CompileAssemblyFromFileBatch(compilerParameters, array);

            foreach (object obj in compilerResults.Errors)
            {
                CompilerError compilerError = (CompilerError)obj;
                string        message       = compilerError.ToString();
                if (compilerError.IsWarning)
                {
                    MLog.Warn(message);
                }
                else
                {
                    MLog.Error(message);
                }
            }
            if (compilerResults.Errors.HasErrors)
            {
                MLog.Error("There were errors compiling the ScriptAssembly at " + codeDir + "!");
            }
            return(assemblyPath);
        }
コード例 #14
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RegisterForTickUpdate(ModContainer mod)
 {
     UpdateOnTick.Add(mod);
 }
コード例 #15
0
        // This method should add a module to the TankBlock prefab
        public override bool CreateModuleForBlock(int blockID, ModdedBlockDefinition def, TankBlock block, JToken jToken)
        {
            try
            {
                Debug.Log("[Nuterra] Loading CustomBlock module");

                if (jToken.Type == JTokenType.Object)
                {
                    JObject jData = (JObject)jToken;

                    // Get the mod contents so we can search for additional assets
                    ModContainer container = ManMods.inst.FindMod(def);
                    ModContents  mod       = container != null ? container.Contents : null;
                    if (mod == null)
                    {
                        Debug.LogError("[Nuterra] Could not find mod that this unoffical block is part of");
                        return(false);
                    }

                    // ------------------------------------------------------
                    // Basics like name, desc etc. The Official Mod Tool lets us set these already, but we might want to override
                    def.m_BlockDisplayName = TryParse(jData, "Name", def.m_BlockDisplayName);
                    def.m_BlockDescription = TryParse(jData, "Description", def.m_BlockDescription);
                    // Ignore block ID. Official loader handles IDs automatically.
                    // Ignore corporation. Custom corps no longer have a fixed ID, so we should use the official tool to set corp IDs.
                    //def.m_Corporation = TryParse(jData, "Corporation", def.m_Corporation);
                    block.m_BlockCategory = def.m_Category = TryParseEnum(jData, "Category", def.m_Category);
                    def.m_Rarity          = TryParseEnum(jData, "Rarity", def.m_Rarity);
                    def.m_Grade           = TryParse(jData, "Grade", def.m_Grade);

                    // Recipe
                    if (jData.TryGetValue("Recipe", out JToken jRecipe))
                    {
                        RecipeTable.Recipe recipe = new RecipeTable.Recipe();
                        Dictionary <ChunkTypes, RecipeTable.Recipe.ItemSpec> dictionary = new Dictionary <ChunkTypes, RecipeTable.Recipe.ItemSpec>();

                        int RecipePrice = 0;
                        if (jRecipe is JValue rString)
                        {
                            string[] recipeString = rString.ToObject <string>().Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string item in recipeString)
                            {
                                RecipePrice += AppendToRecipe(dictionary, item, 1);
                            }
                        }
                        else if (jRecipe is JObject rObject)
                        {
                            foreach (var item in rObject)
                            {
                                RecipePrice += AppendToRecipe(dictionary, item.Key, item.Value.ToObject <int>());
                            }
                        }
                        else if (jRecipe is JArray rArray)
                        {
                            foreach (var item in rArray)
                            {
                                RecipePrice += AppendToRecipe(dictionary, item.ToString(), 1);
                            }
                        }


                        recipe.m_InputItems = new RecipeTable.Recipe.ItemSpec[dictionary.Count];
                        dictionary.Values.CopyTo(recipe.m_InputItems, 0);
                        recipe.m_OutputItems[0] = new RecipeTable.Recipe.ItemSpec(new ItemTypeInfo(ObjectTypes.Block, blockID), 1);
                        Singleton.Manager <RecipeManager> .inst.RegisterCustomBlockFabricatorRecipe(blockID, def.m_Corporation, recipe);

                        def.m_Price = RecipePrice;
                    }
                    // TODO: RecipeTable

                    def.m_Price     = TryParseEnum(jData, "Price", def.m_Price);
                    def.m_MaxHealth = TryParse(jData, "HP", def.m_MaxHealth);

                    // ------------------------------------------------------
                    #region Reference - Copy a vanilla block
                    Debug.Log("[Nuterra] Starting references");
                    bool keepRenderers          = TryParse(jData, "KeepRenderers", true);
                    bool keepReferenceRenderers = TryParse(jData, "KeepReferenceRenderers", true);
                    bool keepColliders          = TryParse(jData, "KeepColliders", true);

                    if (TryGetStringMultipleKeys(jData, out string referenceBlock, "GamePrefabReference", "PrefabReference"))
                    {
                        // This code block copies our chosen reference block
                        // TTQMM REF: BlockPrefabBuilder.Initialize

                        GameObject originalGameObject = TTReferences.FindBlockFromString(referenceBlock);
                        if (originalGameObject != null)
                        {
                            GameObject newObject = UnityEngine.Object.Instantiate(originalGameObject);
                            // Assign this back to block for further processing
                            block = GetOrAddComponent <TankBlock>(newObject.transform);
                            //TankBlock original = originalGameObject.GetComponent<TankBlock>();
                            //TankBlock copy = UnityEngine.Object.Instantiate(original);
                            TankBlockTemplate fakeTemplate = newObject.AddComponent <TankBlockTemplate>();
                            // Cheeky hack to swap the prefab
                            // The official block loader doesn't expect this to happen, but I will assume
                            // for now that you are making 100% official or 100% unofficial JSONs
                            def.m_PhysicalPrefab = fakeTemplate;

                            Debug.Log($"[Nuterra] Found game prefab reference as {newObject}");

                            // TTQMM REF: DirectoryBlockLoader.CreateJSONBlock, the handling of these flags is a bit weird
                            if (keepRenderers && !keepColliders)
                            {
                                RemoveChildren <Collider>(block);
                            }
                            if (!keepRenderers && !keepReferenceRenderers)
                            {
                                RemoveChildren <MeshRenderer>(block);
                                RemoveChildren <TankTrack>(block);
                                RemoveChildren <SkinnedMeshRenderer>(block);
                                RemoveChildren <MeshFilter>(block);

                                if (!keepColliders)
                                {
                                    RemoveChildren <Collider>(block);
                                }
                            }

                            newObject.layer = Globals.inst.layerTank;
                            newObject.tag   = "TankBlock";


                            bool hasRefOffset   = TryGetTokenMultipleKeys(jData, out JToken jOffset, "ReferenceOffset", "PrefabOffset", "PrefabPosition");
                            bool hasRefRotation = TryGetTokenMultipleKeys(jData, out JToken jEuler, "ReferenceRotationOffset", "PrefabRotation");
                            bool hasRefScale    = TryGetTokenMultipleKeys(jData, out JToken jScale, "ReferenceScale", "PrefabScale");

                            if (hasRefOffset || hasRefRotation || hasRefScale)
                            {
                                Vector3 offset = hasRefOffset ? GetVector3(jOffset) : Vector3.zero;
                                Vector3 scale  = hasRefScale ? GetVector3(jScale) : Vector3.one;
                                Vector3 euler  = hasRefRotation ? GetVector3(jEuler) : Vector3.zero;

                                foreach (Transform child in newObject.transform)
                                {
                                    if (hasRefOffset)
                                    {
                                        child.localPosition += offset;
                                    }
                                    if (hasRefRotation)
                                    {
                                        child.localEulerAngles += euler;
                                    }
                                    if (hasRefScale)
                                    {
                                        child.localScale += scale;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Debug.LogError($"[Nuterra] Failed to find GamePrefabReference {referenceBlock}");
                        }
                    }
                    #endregion
                    // ------------------------------------------------------

                    // ------------------------------------------------------
                    // Get some references set up for the next phase, now our prefab is setup
                    Damageable   damageable   = GetOrAddComponent <Damageable>(block);
                    ModuleDamage moduleDamage = GetOrAddComponent <ModuleDamage>(block);
                    Visible      visible      = GetOrAddComponent <Visible>(block);
                    Transform    transform    = block.transform;
                    transform.position   = Vector3.zero;
                    transform.rotation   = Quaternion.identity;
                    transform.localScale = Vector3.one;

                    // ------------------------------------------------------
                    #region Additional References
                    if (TryGetStringMultipleKeys(jData, out string referenceExplosion, "DeathExplosionReference", "ExplosionReference"))
                    {
                        GameObject refBlock = TTReferences.FindBlockFromString(referenceExplosion);
                        if (refBlock != null)
                        {
                            moduleDamage.deathExplosion = refBlock.GetComponent <ModuleDamage>().deathExplosion;
                            Debug.Log($"[Nuterra] Swapped death explosion for {refBlock}");
                        }
                    }
                    #endregion
                    // ------------------------------------------------------

                    // ------------------------------------------------------
                    #region Tweaks
                    // BlockExtents is a way of quickly doing a cuboid Filled Cell setup
                    if (jData.TryGetValue("BlockExtents", out JToken jExtents) && jExtents.Type == JTokenType.Object)
                    {
                        List <IntVector3> filledCells = new List <IntVector3>();
                        int x = ((JObject)jExtents).GetValue("x").ToObject <int>();
                        int y = ((JObject)jExtents).GetValue("y").ToObject <int>();
                        int z = ((JObject)jExtents).GetValue("z").ToObject <int>();
                        for (int i = 0; i < x; i++)
                        {
                            for (int j = 0; j < y; j++)
                            {
                                for (int k = 0; k < z; k++)
                                {
                                    filledCells.Add(new IntVector3(i, j, k));
                                }
                            }
                        }
                        block.filledCells = filledCells.ToArray();
                        Debug.Log("[Nuterra] Overwrote BlockExtents");
                    }
                    // CellMap / CellsMap
                    if (TryGetTokenMultipleKeys(jData, out JToken jCellMap, "CellMap", "CellsMap"))
                    {
                        string[][]        ZYXCells = jCellMap.ToObject <string[][]>();
                        List <IntVector3> cells    = new List <IntVector3>();
                        for (int z = 0; z < ZYXCells.Length; z++)
                        {
                            string[] YXslice = ZYXCells[z];
                            if (YXslice == null)
                            {
                                continue;
                            }

                            for (int y = 0, ry = YXslice.Length - 1; ry >= 0; y++, ry--)
                            {
                                string Xline = YXslice[ry];
                                if (Xline == null)
                                {
                                    continue;
                                }

                                for (int x = 0; x < Xline.Length; x++)
                                {
                                    char cell = Xline[x];
                                    if (cell != ' ')
                                    {
                                        cells.Add(new IntVector3(x, y, z));
                                    }
                                }
                            }
                        }
                        block.filledCells = cells.ToArray();
                    }
                    // TODO: APsOnlyAtBottom / MakeAPsAtBottom
                    if (jData.TryGetValue("Cells", out JToken jCells) && jCells.Type == JTokenType.Array)
                    {
                        List <IntVector3> filledCells = new List <IntVector3>();
                        foreach (JObject jCell in (JArray)jCells)
                        {
                            filledCells.Add(GetVector3Int(jCell));
                        }
                        block.filledCells = filledCells.ToArray();
                    }
                    // APs
                    if (jData.TryGetValue("APs", out JToken jAPList) && jAPList.Type == JTokenType.Array)
                    {
                        List <Vector3> aps = new List <Vector3>();
                        foreach (JToken token in (JArray)jAPList)
                        {
                            aps.Add(GetVector3(token));
                        }
                        block.attachPoints = aps.ToArray();
                    }
                    // Some basic block stats
                    damageable.DamageableType = (ManDamage.DamageableType)TryParse(jData, "DamageableType", (int)damageable.DamageableType);
                    if (TryGetFloatMultipleKeys(jData, out float fragility, moduleDamage.m_DamageDetachFragility, "DetachFragility", "Fragility"))
                    {
                        moduleDamage.m_DamageDetachFragility = fragility;
                    }

                    block.m_DefaultMass = TryParse(jData, "Mass", block.m_DefaultMass);

                    // Center of Mass
                    JArray jComVector = null;
                    if (jData.TryGetValue("CenterOfMass", out JToken com1) && com1.Type == JTokenType.Array)
                    {
                        jComVector = (JArray)com1;
                    }
                    if (jData.TryGetValue("CentreOfMass ", out JToken com2) && com2.Type == JTokenType.Array)
                    {
                        jComVector = (JArray)com2;
                    }
                    if (jComVector != null)
                    {
                        Transform comTrans = block.transform.Find("CentreOfMass");
                        if (comTrans == null)
                        {
                            comTrans = new GameObject("CentreOfMass").transform;
                            comTrans.SetParent(block.transform);
                            comTrans.localScale    = Vector3.one;
                            comTrans.localRotation = Quaternion.identity;
                        }
                        comTrans.localPosition = new Vector3(jComVector[0].ToObject <float>(), jComVector[1].ToObject <float>(), jComVector[2].ToObject <float>());

                        // TODO: Weird thing about offseting colliders from Nuterra
                        //for (int i = 0; i < Prefab.transform.childCount; i++)
                        //{
                        //	transform = Prefab.transform.GetChild(i);
                        //	if (transform.name.Length < 5 && transform.name.EndsWith("col")) // "[a-z]col"
                        //		transform.localPosition = CenterOfMass;
                        //}
                    }

                    // TODO: RotationGroup

                    // IconName override
                    if (jData.TryGetValue("IconName", out JToken jIconName) && jIconName.Type == JTokenType.String)
                    {
                        UnityEngine.Object obj = mod.FindAsset(jIconName.ToString());
                        if (obj != null)
                        {
                            if (obj is Sprite sprite)
                            {
                                def.m_Icon = sprite.texture;
                            }
                            else if (obj is Texture2D texture)
                            {
                                def.m_Icon = texture;
                            }
                            else
                            {
                                Debug.LogWarning($"Found unknown object type {obj.GetType()} for icon override for {block.name}");
                            }
                        }
                    }

                    // TODO: Emission Mode
                    // Filepath? For reparse?
                    #endregion
                    // ------------------------------------------------------

                    // Start recursively adding objects with the root.
                    // Calling it this way and treating the root as a sub-object prevents a lot of code duplication
                    RecursivelyAddSubObject(block, mod, block.transform, jData, TTReferences.kMissingTextureTankBlock, false);

                    // Weird export fix up for meshes
                    // Flip everything in x
                    foreach (MeshRenderer mr in block.GetComponentsInChildren <MeshRenderer>())
                    {
                        mr.transform.localScale = new Vector3(-mr.transform.localScale.x, mr.transform.localScale.y, mr.transform.localScale.z);
                    }
                    foreach (MeshCollider mc in block.GetComponentsInChildren <MeshCollider>())
                    {
                        if (mc.GetComponent <MeshRenderer>() == null)                       // Skip ones with both. Don't want to double flip
                        {
                            mc.transform.localScale = new Vector3(-mc.transform.localScale.x, mc.transform.localScale.y, mc.transform.localScale.z);
                        }
                    }

                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                Debug.LogError($"[Nuterra] Caught exception {e}");
                return(false);
            }
        }
コード例 #16
0
        protected DrawableScore(Score score)
        {
            Score = score;

            RelativeSizeAxes = Axes.X;
            Height           = 60;
            Children         = new Drawable[]
            {
                background = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Masking          = true,
                    CornerRadius     = 3,
                    Alpha            = 0,
                    EdgeEffect       = new EdgeEffectParameters
                    {
                        Type   = EdgeEffectType.Shadow,
                        Offset = new Vector2(0f, 1f),
                        Radius = 1f,
                        Colour = Color4.Black.Opacity(0.2f),
                    },
                    Child = coloredBackground = new Box {
                        RelativeSizeAxes = Axes.Both
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Width            = 0.97f,
                    Children         = new Drawable[]
                    {
                        underscoreLine = new Box
                        {
                            Anchor           = Anchor.BottomCentre,
                            Origin           = Anchor.BottomCentre,
                            RelativeSizeAxes = Axes.X,
                            Height           = 1,
                        },
                        new DrawableRank(score.Rank)
                        {
                            RelativeSizeAxes = Axes.Y,
                            Width            = 60,
                            FillMode         = FillMode.Fit,
                        },
                        Stats = new FillFlowContainer <OsuSpriteText>
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Anchor           = Anchor.CentreRight,
                            Origin           = Anchor.CentreRight,
                            Direction        = FillDirection.Vertical,
                        },
                        metadata = new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            Margin           = new MarginPadding {
                                Left = 70
                            },
                            Direction = FillDirection.Vertical,
                            Child     = new OsuSpriteText
                            {
                                Text     = score.Date.LocalDateTime.ToShortDateString(),
                                TextSize = 11,
                                Colour   = OsuColour.Gray(0xAA),
                                Depth    = -1,
                            },
                        },
                        modContainer = new ModContainer
                        {
                            AutoSizeAxes = Axes.Y,
                            Anchor       = Anchor.CentreRight,
                            Origin       = Anchor.CentreRight,
                            Width        = 60,
                            Margin       = new MarginPadding {
                                Right = 160
                            }
                        }
                    }
                },
            };
        }
コード例 #17
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RegisterForNewGameUpdate(ModContainer mod)
 {
     UpdateOnNewGame.Add(mod);
 }
コード例 #18
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RegisterForPlayerSpawnUpdate(ModContainer mod)
 {
     UpdateOnPlayerSpawn.Add(mod);
 }
コード例 #19
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RemoveFromTickUpdate(ModContainer mod)
 {
     UpdateOnTick.Remove(mod);
 }
コード例 #20
0
 // Token: 0x06000D65 RID: 3429 RVA: 0x0005B688 File Offset: 0x00059888
 public void UnregisterPrefabs(ModContainer mod)
 {
 }
コード例 #21
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RegisterItemOverrideService(ModContainer mod) => RegisterOverrideService("items", mod);
コード例 #22
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RegisterShopOverrideService(ModContainer mod) => RegisterOverrideService("shops", mod);
コード例 #23
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RemoveFromNewGameUpdate(ModContainer mod)
 {
     UpdateOnNewGame.Remove(mod);
 }
コード例 #24
0
ファイル: QTLoader.cs プロジェクト: Crunchepillar/MomLoader
 public static void RemoveFromPlayerSpawnUpdate(ModContainer mod)
 {
     UpdateOnPlayerSpawn.Remove(mod);
 }