Esempio n. 1
0
 WarpDrivePluginManager()
 {
     VanillaWarpDriveMaxType = Enum.GetValues(typeof(EWarpDriveType)).Length;
     Logger.Info($"MaxTypeint = {VanillaWarpDriveMaxType - 1}");
     foreach (PulsarPlugin plugin in PluginManager.Instance.GetAllPlugins())
     {
         Assembly asm             = plugin.GetType().Assembly;
         Type     WarpDrivePlugin = typeof(WarpDrivePlugin);
         foreach (Type t in asm.GetTypes())
         {
             if (WarpDrivePlugin.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
             {
                 Logger.Info("Loading WarpDrive from assembly");
                 WarpDrivePlugin WarpDrivePluginHandler = (WarpDrivePlugin)Activator.CreateInstance(t);
                 if (GetWarpDriveIDFromName(WarpDrivePluginHandler.Name) == -1)
                 {
                     WarpDriveTypes.Add(WarpDrivePluginHandler);
                     Logger.Info($"Added WarpDrive: '{WarpDrivePluginHandler.Name}' with ID '{GetWarpDriveIDFromName(WarpDrivePluginHandler.Name)}'");
                 }
                 else
                 {
                     Logger.Info($"Could not add WarpDrive from {plugin.Name} with the duplicate name of '{WarpDrivePluginHandler.Name}'");
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public static PLWarpDrive CreateWarpDrive(int Subtype, int level)
        {
            PLWarpDrive InWarpDrive;

            if (Subtype >= Instance.VanillaWarpDriveMaxType)
            {
                InWarpDrive = new PLWarpDrive(EWarpDriveType.E_MAX, level);
                int subtypeformodded = Subtype - Instance.VanillaWarpDriveMaxType;
                if (Global.DebugLogging)
                {
                    Logger.Info($"Subtype for modded is {subtypeformodded}");
                }
                if (subtypeformodded <= Instance.WarpDriveTypes.Count && subtypeformodded > -1)
                {
                    if (Global.DebugLogging)
                    {
                        Logger.Info("Creating WarpDrive from list info");
                    }
                    WarpDrivePlugin WarpDriveType = Instance.WarpDriveTypes[Subtype - Instance.VanillaWarpDriveMaxType];
                    InWarpDrive.SubType = Subtype;
                    InWarpDrive.Name    = WarpDriveType.Name;
                    InWarpDrive.Desc    = WarpDriveType.Description;
                    InWarpDrive.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, WarpDriveType.IconTexture);
                    InWarpDrive.ChargeSpeed           = WarpDriveType.ChargeSpeed;
                    InWarpDrive.WarpRange             = WarpDriveType.WarpRange;
                    InWarpDrive.EnergySignatureAmt    = WarpDriveType.EnergySignature;
                    InWarpDrive.NumberOfChargingNodes = WarpDriveType.NumberOfChargesPerFuel;
                    InWarpDrive.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, (ObscuredInt)WarpDriveType.MarketPrice);
                    InWarpDrive.CargoVisualPrefabID     = WarpDriveType.CargoVisualID;
                    InWarpDrive.CanBeDroppedOnShipDeath = WarpDriveType.CanBeDroppedOnShipDeath;
                    InWarpDrive.Experimental            = WarpDriveType.Experimental;
                    InWarpDrive.Unstable   = WarpDriveType.Unstable;
                    InWarpDrive.Contraband = WarpDriveType.Contraband;
                    InWarpDrive.GetType().GetField("Price_LevelMultiplierExponent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InWarpDrive, (ObscuredFloat)WarpDriveType.Price_LevelMultiplierExponent);
                }
            }
            else
            {
                InWarpDrive = new PLWarpDrive((EWarpDriveType)Subtype, level);
            }
            return(InWarpDrive);
        }