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

◆ AI_195_JimsDrone()

void Terraria.Projectile.AI_195_JimsDrone ( )
inlineprivate

Definition at line 33308 of file Projectile.cs.

33309 {
33310 //IL_0240: Unknown result type (might be due to invalid IL or missing references)
33311 //IL_027c: Unknown result type (might be due to invalid IL or missing references)
33312 //IL_0281: Unknown result type (might be due to invalid IL or missing references)
33313 //IL_0293: Unknown result type (might be due to invalid IL or missing references)
33314 Player player = Main.player[owner];
33315 bool flag = false;
33316 if (player.dead)
33317 {
33318 flag = true;
33319 }
33320 if (owner == Main.myPlayer)
33321 {
33322 if (position.Y - (float)height <= (float)(16 * Main.offScreenRange / 2))
33323 {
33324 Kill();
33325 return;
33326 }
33327 if (player.HeldItem.type != 5451)
33328 {
33329 flag = true;
33330 }
33331 bool flag2 = player.gravDir == -1f;
33332 BitsByte bitsByte = (byte)0;
33333 Player.DirectionalInputSyncCache localInputCache = player.LocalInputCache;
33334 bitsByte[0] = localInputCache.controlLeft ^ flag2;
33335 bitsByte[1] = localInputCache.controlRight ^ flag2;
33336 bitsByte[2] = localInputCache.controlUp;
33337 bitsByte[3] = localInputCache.controlDown;
33338 float num = (int)(byte)bitsByte;
33339 if (ai[0] != num)
33340 {
33341 ai[0] = num;
33342 netUpdate = true;
33343 }
33344 Main.DroneCameraTracker.Track(this);
33345 }
33346 if (flag)
33347 {
33348 Kill();
33349 return;
33350 }
33351 BitsByte bitsByte2 = (byte)ai[0];
33352 rotation = ai[1];
33353 bool flag3 = bitsByte2[0];
33354 bool flag4 = bitsByte2[1];
33355 bool flag5 = bitsByte2[2];
33356 _ = bitsByte2[3];
33357 localAI[0] += 1f;
33358 if (!flag3 && !flag4)
33359 {
33360 localAI[0] = 0f;
33361 }
33362 bool flag6 = velocity.Y == 0f;
33363 int num2 = 0;
33364 if (!flag6)
33365 {
33366 num2 = 10;
33367 }
33368 if (flag5)
33369 {
33370 num2 = 100;
33371 }
33372 localAI[1] = MathHelper.Lerp(localAI[1], num2, 0.2f);
33373 float num3 = Utils.Remap(localAI[0], 0f, 5f, 0f, 1f) * Utils.Remap(localAI[0], 5f, 15f, 1f, 0f);
33374 float num4 = Utils.Clamp(MathHelper.Max(Utils.Remap(localAI[1], 0f, 100f, 0f, 25f), num3 * 12f), 0f, 100f);
33376 if (activeSound == null && num4 != 0f)
33377 {
33378 float[] array = localAI;
33380 array[2] = ((SlotId)(ref val)).ToFloat();
33382 }
33383 if (activeSound != null)
33384 {
33385 activeSound.Volume = num4;
33386 activeSound.Position = base.Center;
33387 activeSound.Pitch = Utils.Clamp(Utils.Remap(localAI[1], 0f, 100f, -1f, 1f) + num3, -1f, 1f);
33388 }
33389 float num5 = 0.15f;
33390 if (flag6)
33391 {
33393 velocity.X *= 0.97f;
33394 if (flag5)
33395 {
33396 Vector2 vector = (rotation - (float)Math.PI / 2f).ToRotationVector2();
33397 velocity += vector * 0.5f;
33398 num5 = 0.05f;
33399 }
33400 }
33401 else
33402 {
33403 float num6 = (float)Math.PI / 15f;
33404 num6 = Utils.Remap(localAI[0], 0f, 10f, num6 * 0.1f, num6);
33405 int num7 = flag4.ToInt() - flag3.ToInt();
33406 rotation += (float)num7 * num6;
33407 if (flag5)
33408 {
33409 Vector2 vector2 = (rotation - (float)Math.PI / 2f).ToRotationVector2();
33410 velocity.X *= 0.97f;
33411 velocity += vector2 * 0.5f;
33412 }
33413 }
33414 velocity.Y += num5;
33415 ai[1] = rotation;
33416 if (!flag5 && velocity.Y > 12f)
33417 {
33418 velocity.Y *= 0.95f;
33419 }
33420 if (velocity.Length() > 16f)
33421 {
33422 velocity *= 16f / velocity.Length();
33423 }
33424 Lighting.AddLight(base.Center, Vector3.One * 0.3f);
33425 timeLeft = 2;
33426 if (!flag6)
33427 {
33429 float num8 = 0f;
33430 int num9 = 3;
33431 int num10 = 16 * num9;
33432 for (int i = 0; i < num9; i++)
33433 {
33434 Vector2 vector4 = new Vector2(0f, 16f);
33435 Vector2 vector5 = Collision.TileCollision(vector3 + vector4 * i, vector4, width, height);
33436 num8 += vector5.Y;
33437 if (vector5 != vector4)
33438 {
33439 break;
33440 }
33441 }
33442 if (num8 != (float)num10)
33443 {
33444 for (int j = 0; j < 2; j++)
33445 {
33446 if (!(Main.rand.NextFloat() < 0.66f))
33447 {
33448 Vector2 vector6 = vector3 + new Vector2(0f, num8) + new Vector2((float)width / 2f, height);
33449 Vector2 value = Main.rand.NextVector2CircularEdge(2.5f, 1f) * 0.5f;
33450 if (value.Y > 0f)
33451 {
33452 value.Y *= -1f;
33453 }
33454 Dust.NewDustPerfect(vector6, (Main.rand.Next(2) == 0) ? 31 : 16, value, 127);
33455 }
33456 }
33457 }
33458 }
33459 if (Main.netMode == 2 && Main.player.IndexInRange(owner) && Main.player[owner].active)
33460 {
33461 RemoteClient.CheckSection(owner, position);
33462 }
33463 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static float WrapAngle(float angle)
Definition MathHelper.cs:87
static float Max(float value1, float value2)
Definition MathHelper.cs:41
const double PI
Definition Math.cs:16
static SlotId PlayTrackedLoopedSound(SoundStyle style, Vector2 position, ActiveSound.LoopedPlayCondition loopingCondition=null)
static ActiveSound GetActiveSound(SlotId id)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static readonly LegacySoundStyle JimsDrone
Definition SoundID.cs:990
static SlotId FromFloat(float value)
Definition SlotId.cs:80

References Terraria.Lighting.AddLight(), System.array, Terraria.RemoteClient.CheckSection(), Terraria.Player.dead, Terraria.Main.DroneCameraTracker, ReLogic.Utilities.SlotId.FromFloat(), Terraria.Audio.SoundEngine.GetActiveSound(), Terraria.Player.HeldItem, Terraria.Audio.ProjectileAudioTracker.IsActiveAndInGame(), Terraria.ID.SoundID.JimsDrone, Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Player.LocalInputCache, Microsoft.Xna.Framework.MathHelper.Max(), Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Dust.NewDustPerfect(), Terraria.Main.offScreenRange, Microsoft.Xna.Framework.Vector3.One, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlayTrackedLoopedSound(), Terraria.Main.rand, Terraria.Utils.Remap(), Terraria.Collision.TileCollision(), Terraria.Item.type, System.value, Microsoft.Xna.Framework.MathHelper.WrapAngle(), and Microsoft.Xna.Framework.Vector2.Y.