Beispiel #1
0
 ShieldModManager()
 {
     VanillaShieldMaxType = Enum.GetValues(typeof(EShieldGeneratorType)).Length;
     Logger.Info($"MaxTypeint = {VanillaShieldMaxType - 1}");
     foreach (PulsarMod mod in ModManager.Instance.GetAllMods())
     {
         Assembly asm       = mod.GetType().Assembly;
         Type     ShieldMod = typeof(ShieldMod);
         foreach (Type t in asm.GetTypes())
         {
             if (ShieldMod.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
             {
                 Logger.Info("Loading Shield from assembly");
                 ShieldMod ShieldModHandler = (ShieldMod)Activator.CreateInstance(t);
                 if (GetShieldIDFromName(ShieldModHandler.Name) == -1)
                 {
                     ShieldTypes.Add(ShieldModHandler);
                     Logger.Info($"Added Shield: '{ShieldModHandler.Name}' with ID '{GetShieldIDFromName(ShieldModHandler.Name)}'");
                 }
                 else
                 {
                     Logger.Info($"Could not add Shield from {mod.Name} with the duplicate name of '{ShieldModHandler.Name}'");
                 }
             }
         }
     }
 }
Beispiel #2
0
        public static PLShieldGenerator CreateShield(int Subtype, int level)
        {
            PLShieldGenerator InShield;

            if (Subtype >= Instance.VanillaShieldMaxType)
            {
                InShield = new PLShieldGenerator(EShieldGeneratorType.E_SG_ID_MAX, level);
                int subtypeformodded = Subtype - Instance.VanillaShieldMaxType;
                if (subtypeformodded <= Instance.ShieldTypes.Count && subtypeformodded > -1)
                {
                    ShieldMod ShieldType = Instance.ShieldTypes[Subtype - Instance.VanillaShieldMaxType];
                    InShield.SubType       = Subtype;
                    InShield.Name          = ShieldType.Name;
                    InShield.Desc          = ShieldType.Description;
                    InShield.m_IconTexture = ShieldType.IconTexture;
                    InShield.Max           = ShieldType.ShieldMax;
                    InShield.ChargeRateMax = ShieldType.ChargeRateMax;
                    InShield.RecoveryRate  = ShieldType.RecoveryRate;
                    InShield.Deflection    = ShieldType.Deflection;
                    InShield.MinIntegrityPercentForQuantumShield = ShieldType.MinIntegrityPercentForQuantumShield;
                    InShield.MinIntegrityAfterDamage             = ShieldType.MinIntegrityAfterDamage;
                    InShield.m_MaxPowerUsage_Watts   = (ShieldType.MaxPowerUsage_Watts * 1.4f);
                    InShield.m_MarketPrice           = ShieldType.MarketPrice;
                    InShield.CargoVisualPrefabID     = ShieldType.CargoVisualID;
                    InShield.CanBeDroppedOnShipDeath = ShieldType.CanBeDroppedOnShipDeath;
                    InShield.Experimental            = ShieldType.Experimental;
                    InShield.Unstable   = ShieldType.Unstable;
                    InShield.Contraband = ShieldType.Contraband;
                    InShield.Price_LevelMultiplierExponent = ShieldType.Price_LevelMultiplierExponent;
                    if (InShield.MinIntegrityAfterDamage == -1)
                    {
                        InShield.MinIntegrityAfterDamage = Mathf.RoundToInt(InShield.Max * 0.15f);
                    }
                    InShield.MinIntegrityAfterDamage = Mathf.RoundToInt(InShield.MinIntegrityAfterDamage * (1f - Mathf.Clamp(0.05f * InShield.Level, 0f, 0.8f)));
                    InShield.CurrentMax = InShield.Max;
                    InShield.Current    = InShield.Max;
                }
            }
            else
            {
                InShield = new PLShieldGenerator((EShieldGeneratorType)Subtype, level);
            }
            return(InShield);
        }