Exemple #1
0
 public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
 {
     globalProjectile.mod         = this;
     globalProjectile.Name        = name;
     this.globalProjectiles[name] = globalProjectile;
     ProjectileLoader.globalProjectiles.Add(globalProjectile);
 }
Exemple #2
0
        private void AutoloadGlobalProjectile(Type type)
        {
            GlobalProjectile globalProjectile = (GlobalProjectile)Activator.CreateInstance(type);

            globalProjectile.mod = this;
            string name = type.Name;

            if (globalProjectile.Autoload(ref name))
            {
                AddGlobalProjectile(name, globalProjectile);
            }
        }
Exemple #3
0
        /// <summary>
        /// Create a new instance of this GlobalProjectile for a Projectile instance.
        /// Called at the end of Projectile.SetDefaults.
        /// If CloneNewInstances is true, just calls Clone()
        /// Otherwise calls the default constructor and copies fields
        /// </summary>
        public virtual GlobalProjectile NewInstance(Projectile projectile)
        {
            if (CloneNewInstances)
            {
                return(Clone());
            }
            GlobalProjectile copy = (GlobalProjectile)Activator.CreateInstance(GetType());

            copy.Mod           = Mod;
            copy.index         = index;
            copy.instanceIndex = instanceIndex;
            return(copy);
        }
Exemple #4
0
        internal static void VerifyGlobalProjectile(GlobalProjectile projectile)
        {
            var type = projectile.GetType();

            bool hasInstanceFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                     .Any(f => f.DeclaringType != typeof(GlobalProjectile));

            if (hasInstanceFields)
            {
                if (!projectile.InstancePerEntity)
                {
                    throw new Exception(type + " has instance fields but does not set InstancePerEntity to true. Either use static fields, or per instance globals");
                }
            }
        }
Exemple #5
0
 public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
 {
     globalProjectile.mod = this;
     globalProjectile.Name = name;
     this.globalProjectiles[name] = globalProjectile;
     ProjectileLoader.globalProjectiles.Add(globalProjectile);
 }