internal static void SetDefaults(NPC npc, bool createModNPC = true) { if (IsModNPC(npc)) { if (createModNPC) { npc.ModNPC = GetNPC(npc.type).NewInstance(npc); } else //the default NPCs created and bound to ModNPCs are initialized before ResizeArrays. They come here during SetupContent. { Array.Resize(ref npc.buffImmune, BuffLoader.BuffCount); } } GlobalNPC Instantiate(GlobalNPC g) => g.InstancePerEntity ? g.NewInstance(npc) : g; LoaderUtils.InstantiateGlobals(npc, globalNPCs, ref npc.globalNPCs, Instantiate, () => { npc.ModNPC?.SetDefaults(); }); foreach (GlobalNPC g in HookSetDefaults.Enumerate(npc.globalNPCs)) { g.SetDefaults(npc); } }
internal static void SetDefaults(Projectile projectile, bool createModProjectile = true) { if (IsModProjectile(projectile) && createModProjectile) { projectile.ModProjectile = GetProjectile(projectile.type).NewInstance(projectile); } GlobalProjectile Instantiate(GlobalProjectile g) => g.InstancePerEntity ? g.NewInstance(projectile) : g; LoaderUtils.InstantiateGlobals(projectile, globalProjectiles, ref projectile.globalProjectiles, Instantiate, () => { projectile.ModProjectile?.SetDefaults(); }); foreach (GlobalProjectile g in HookSetDefaults.Enumerate(projectile.globalProjectiles)) { g.SetDefaults(projectile); } }