示例#1
0
        /// <summary>
        /// Creates a substance from the given element entry
        /// </summary>
        /// <param name="entry">The entry</param>
        /// <returns></returns>
        public static Substance CreateSubstance(ElementLoader.ElementEntry entry)
        {
            var state = entry.state;
            var id    = GetElementID(entry);
            var ext   = entry is ElementEntryExtended ? (ElementEntryExtended)entry : null;

            var material         = ElementManager.GetBaseMaterialForState(state, substanceTable);
            var materialOverride = ext != null ? ext.material : null;

            if (material == null)
            {
                string materialName = id.ToLower();
                var    tex          = Assets.GetTexture(materialOverride ?? materialName);
                if (tex != null)
                {
                    material.mainTexture = tex;
                }
                else
                {
                    ElementManager.Logger.Verbose("No material texture '{0}', using default: {1}", materialName, material.mainTexture.name);
                }
                material.name = materialName;
            }

            // get anim
            var       animName = ((ext != null ? ext.anim : null) ?? id.ToLower()) + PLUtil.SUFFIX_ANIM;
            KAnimFile animFile = Assets.Anims.Find(a => a.name == animName);

            if (animFile == null)
            {
                animFile = ElementManager.GetDefaultKAnimForState(state, substanceTable);
                if (state == Element.State.Solid)
                {
                    Logger.Verbose("No anim '{0}' found for {1}, using default: {2}", animName, id, animFile.name);
                }
            }

            // colors
            var color        = CreateColor32(ext != null ? ext.color : null);
            var uiColor      = CreateColor32(ext != null ? ext.colorUI ?? ext.color : null);
            var conduitColor = CreateColor32(ext != null ? ext.colorUI ?? ext.color : null);

            Logger.Verbose("Created Substance: {0}({1})", id, (int)GetElementHash(entry));
            return(ModUtil.CreateSubstance(id, state, animFile, material, color, uiColor, conduitColor));
        }
示例#2
0
        internal static void LoadTypes(Assembly assembly)
        {
            bool isPipModAssembly = false;
            var  types            = assembly.GetTypes();

            foreach (var type in types)
            {
                if (PipMod.TypeCollector.IsImpl(typeof(IPipMod), type))
                {
                    PipLib.Logger.Verbose("Found PipLib mod at: {0}, {1}", type.FullName, assembly.FullName);
                    mods.Add(assembly, new Tuple <IPipMod, Type>(null, type));
                    isPipModAssembly = true;
                }

                foreach (var method in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    var p = method.GetParameters();
                    if (p.Length != 1 || !p[0].ParameterType.Equals(typeof(Type)))
                    {
                        continue;
                    }

                    var collectorAttrs = (PipMod.TypeCollector[])method.GetCustomAttributes(typeof(PipMod.TypeCollector), true);
                    if (collectorAttrs.Length > 0)
                    {
                        foreach (var c in collectorAttrs)
                        {
                            Logger.Verbose("Registed type collector {0} for type: {1}", method.DeclaringType.FullName, c.Predicate.FullName);
                            collectors.Add(c, method);
                        }
                    }
                }
            }

            assemblies.Add(new Tuple <bool, Assembly>(isPipModAssembly, assembly));
            CollectTypes(types, isPipModAssembly);
            CollectSteps(assembly);
        }
示例#3
0
        public void ResetArrangement()
        {
            Logger.Verbose("Resetting tech tree arrangement...");

            // clear titles
            db.TechTreeTitles.resources.Clear();

            // set all nodes to 0,0
            foreach (var tech in Techs.resources)
            {
                var node = GetNode(tech);
                node.nodeX = 0;
                node.nodeY = 0;
            }
        }
示例#4
0
        public async Task InitAsync(CancellationToken ct)
        {
            _logger.Verbose("Preparing to init {windowName} window (id: {windowId}) with url {windowUrl}", Name, Id, Url);
            using (_logger.Timed("Initiating {windowName} window", Name))
            {
                Window = await ElectronNET.API.Electron.WindowManager.CreateWindowAsync(Options, Url);
                await OnCreatedAsync(Window, ct);

                Window.OnClosed += () =>
                {
                    _logger.Debug("Window {windowName} has been closed.", Name);
                    if (_isDisposing)
                    {
                        _logger.Information("Disposing {windowName}. Window wont be recreated", Name);
                        return;
                    }
                    _logger.Information("Recreating window {windowName}", Name);
                    InitAsync(CancellationToken.None).GetAwaiter().GetResult();
                };
            }
        }