コード例 #1
0
 public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
 {
     globalProjectile.mod         = this;
     globalProjectile.Name        = name;
     this.globalProjectiles[name] = globalProjectile;
     ProjectileLoader.globalProjectiles.Add(globalProjectile);
 }
コード例 #2
0
ファイル: ModInternals.cs プロジェクト: re4prr/tModLoader
        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);
            }
        }
コード例 #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);
        }
コード例 #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");
                }
            }
        }
コード例 #5
0
ファイル: Mod.cs プロジェクト: popovn/tModLoader
 public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
 {
     globalProjectile.mod = this;
     globalProjectile.Name = name;
     this.globalProjectiles[name] = globalProjectile;
     ProjectileLoader.globalProjectiles.Add(globalProjectile);
 }