static bool AddPackages(OptionalDependencies optionalDependencies, string optDepsPath)
        {
            var packages = optionalDependencies.Packages;

            if (packages == null)
            {
                return(false);
            }

            var packageList = new List <string>(packages);
            var list        = Client.List();

            while (!list.IsCompleted)
            {
            }

            foreach (var result in list.Result)
            {
                packageList.Remove(result.name);
            }

            if (packageList.Count > 0)
            {
                var package = packageList[0];
                Debug.LogFormat("Adding optional package dependency {0} as defined in {1}", package, optDepsPath);
                Client.Add(package);
                return(true);
            }

            return(false);
        }
Exemple #2
0
        /*
         * ---------------------------------
         * Overrides: (Mostly) Autogenerated
         * ---------------------------------
         */

        public bool Equals(ModConfig other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            return(string.Equals(ModId, other.ModId) &&
                   string.Equals(ModName, other.ModName) &&
                   string.Equals(ModAuthor, other.ModAuthor) &&
                   string.Equals(ModVersion, other.ModVersion) &&
                   string.Equals(ModDescription, other.ModDescription) &&
                   string.Equals(ModDll, other.ModDll) &&
                   string.Equals(ModIcon, other.ModIcon) &&
                   ModR2RManagedDll32 == other.ModR2RManagedDll32 &&
                   ModR2RManagedDll64 == other.ModR2RManagedDll64 &&
                   ModNativeDll32 == other.ModNativeDll32 &&
                   ModNativeDll64 == other.ModNativeDll64 &&
                   ModDependencies.SequenceEqualWithNullSupport(other.ModDependencies) &&
                   OptionalDependencies.SequenceEqualWithNullSupport(other.OptionalDependencies) &&
                   SupportedAppId.SequenceEqualWithNullSupport(other.SupportedAppId));
        }
 public TStateValue GetValue <TStateValue>(string key)
     where TStateValue : class
 {
     if (Dependencies.TryGetValue(key, out var value) || OptionalDependencies.TryGetValue(key, out value) || AdditionalData.TryGetValue(key, out value))
     {
         return((TStateValue)value);
     }
     return(null);
 }
        static bool UpdateAssemblyDefinition(string asmDefPath, OptionalDependencies optionalDependencies, string optDepsPath)
        {
            var asmDef             = JsonUtility.FromJson <AssemblyDefinition>(File.ReadAllText(asmDefPath));
            var assemblies         = CompilationPipeline.GetAssemblies();
            var assemblyNames      = assemblies.Select(assembly => assembly.name).ToList();
            var optionalReferences = optionalDependencies.References;

            if (optionalReferences == null || optionalReferences.Length == 0)
            {
                return(false);
            }

            var references    = asmDef.references;
            var referenceList = references == null ? new List <string>() : references.ToList();
            var modified      = false;

            foreach (var reference in optionalReferences)
            {
                if (!assemblyNames.Contains(reference))
                {
                    continue;
                }

                if (!referenceList.Contains(reference))
                {
                    modified = true;
                    referenceList.Add(reference);
                    Debug.LogFormat("Adding optional assembly reference {0} to {1} as defined in {2}",
                                    reference, asmDefPath, optDepsPath);
                }
            }

            if (modified)
            {
                asmDef.references = referenceList.ToArray();
                File.WriteAllText(asmDefPath, JsonUtility.ToJson(asmDef, true));
            }

            return(modified);
        }
Exemple #5
0
 /// <summary>
 /// Adds an optional dependency to list. Should be called in Awake or Start methods of module
 /// </summary>
 /// <typeparam name="T"></typeparam>
 public void AddOptionalDependency <T>() where T : class, IBaseServerModule
 {
     OptionalDependencies.Add(typeof(T));
 }