Beispiel #1
0
        public static object GetModGlobalProjConditions(string modname, Projectile proj, string globalprojname, string ConditionName, bool nopub = false, bool sta = false)
        {
            object condition = null;

            if (ModLoader.GetMod(modname) != null)
            {
                Mod mod = ModLoader.GetMod(modname);
                try
                {
                    GlobalProjectile global = proj.GetGlobalProjectile(mod, globalprojname);
                    if (global != null)
                    {
                        BindingFlags binding = (sta? BindingFlags.Static : BindingFlags.Instance) | (nopub? BindingFlags.NonPublic : BindingFlags.Public);
                        return(global.GetType().GetField(ConditionName, binding).GetValue(global));
                    }
                }
                catch
                {
                    return(null);

                    throw new Exception("Error in reading globalproj data.");
                }
            }
            return(condition);
        }
Beispiel #2
0
        private bool GlobalProjectileAction(int pWhoAmI)
        {
            try
            {
                GlobalProjectile gProj = ProjectileObject(pWhoAmI).GetGlobalProjectile(modInstance, internalName);
                try
                {
                    FieldInfo field = gProj.GetType().GetField(damageType, BindingFlags.Public | BindingFlags.Instance);
                    return((bool)field.GetValue(gProj));
                }
                catch
                {
                    string msg = $"{modInstance.Name}'s {internalName} does not " +
                                 $"have {damageType} custom damage type variable.";
                    modInstance.Logger.Warn($"Failed integration with ChensGradiusMod. {msg}");

                    return(false);
                }
            }
            catch
            {
                modInstance.Logger.Warn($"Failed integration with ChensGradiusMod. The mod seems to exist, but it is unloaded. Skipping check.");
                return(false);
            }
        }
Beispiel #3
0
 public static void SetModGlobalProjConditions(string modname, Projectile proj, string globalprojname, string ConditionName, object Set_value, bool nopub = false, bool sta = false)
 {
     if (ModLoader.GetMod(modname) != null)
     {
         Mod mod = ModLoader.GetMod(modname);
         try
         {
             GlobalProjectile global = proj.GetGlobalProjectile(mod, globalprojname);
             if (global != null)
             {
                 BindingFlags binding = (sta? BindingFlags.Static : BindingFlags.Instance) | (nopub? BindingFlags.NonPublic : BindingFlags.Public);
                 FieldInfo    field   = global.GetType().GetField(ConditionName, binding);
                 if (field.FieldType == Set_value.GetType())
                 {
                     field.SetValue(global, Set_value);
                 }
             }
         }
         catch
         {
             throw new Exception("Error in setting globalitem data.");
         }
     }
 }