Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SpawnStardustMark_StardustTower()

void Terraria.NPC.SpawnStardustMark_StardustTower ( )
inlineprivate

Definition at line 36945 of file NPC.cs.

36946 {
36947 List<int> list = new List<int>();
36948 if (CountNPCS(405) + CountNPCS(406) < 2)
36949 {
36950 list.Add(405);
36951 }
36952 if (CountNPCS(402) < 2)
36953 {
36954 list.Add(402);
36955 }
36956 if (CountNPCS(407) < 1)
36957 {
36958 list.Add(407);
36959 }
36960 if (list.Count > 0)
36961 {
36962 int num = Utils.SelectRandom(Main.rand, list.ToArray());
36963 ai[1] = 30 * Main.rand.Next(5, 16);
36964 int num2 = Main.rand.Next(3, 6);
36965 int num3 = Main.rand.Next(0, 4);
36966 int num4 = 0;
36969 list2.Add(Tuple.Create(base.Top - Vector2.UnitY * 120f, num2, 0));
36970 int num5 = 0;
36971 int num6 = list2.Count;
36972 while (list2.Count > 0)
36973 {
36974 Vector2 item = list2[0].Item1;
36975 int num7 = 1;
36976 int num8 = 1;
36977 if (num5 > 0 && num3 > 0 && (Main.rand.Next(3) != 0 || num5 == 1))
36978 {
36979 num8 = Main.rand.Next(Math.Max(1, list2[0].Item2));
36980 num7++;
36981 num3--;
36982 }
36983 for (int i = 0; i < num7; i++)
36984 {
36985 int num9 = list2[0].Item3;
36986 if (num5 == 0)
36987 {
36988 num9 = Utils.SelectRandom<int>(Main.rand, -1, 1);
36989 }
36990 else if (i == 1)
36991 {
36992 num9 *= -1;
36993 }
36994 float num10 = ((num5 % 2 == 0) ? 0f : ((float)Math.PI)) + (0.5f - Main.rand.NextFloat()) * ((float)Math.PI / 4f) + (float)num9 * ((float)Math.PI / 4f) * (float)(num5 % 2 == 0).ToDirectionInt();
36995 float num11 = 100f + 50f * Main.rand.NextFloat();
36996 int num12 = list2[0].Item2;
36997 if (i != 0)
36998 {
36999 num12 = num8;
37000 }
37001 if (num5 == 0)
37002 {
37003 num10 = (0.5f - Main.rand.NextFloat()) * ((float)Math.PI / 4f);
37004 num11 = 100f + 100f * Main.rand.NextFloat();
37005 }
37006 Vector2 vector = (-Vector2.UnitY).RotatedBy(num10) * num11;
37007 if (num12 - 1 < 0)
37008 {
37010 }
37011 num4 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), item.X, item.Y, vector.X, vector.Y, 540, 0, 0f, Main.myPlayer, (float)(-num5) * 10f, 0.5f + Main.rand.NextFloat() * 0.5f);
37012 list3.Add(item + vector);
37013 if (num5 < num2 && list2[0].Item2 > 0)
37014 {
37015 list2.Add(Tuple.Create(item + vector, num12 - 1, num9));
37016 }
37017 }
37018 list2.Remove(list2[0]);
37019 if (--num6 == 0)
37020 {
37021 num6 = list2.Count;
37022 num5++;
37023 }
37024 }
37025 Main.projectile[num4].localAI[0] = num;
37026 }
37027 else
37028 {
37029 ai[1] = 30f;
37030 }
37031 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static int CountNPCS(int Type)
Definition NPC.cs:86664
float[] ai
Definition NPC.cs:447
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.NPC.ai, System.Collections.Generic.Dictionary< TKey, TValue >.Count, Terraria.NPC.CountNPCS(), Terraria.NPC.GetSpawnSource_ForProjectile(), System.item, System.list, System.Math.Max(), Terraria.Main.myPlayer, Terraria.Projectile.NewProjectile(), System.Math.PI, Terraria.Main.projectile, Terraria.Main.rand, System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), Microsoft.Xna.Framework.Vector2.UnitY, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().