private void VoidPortalUpdateHand(ref VoidEmissaryHand hand, Vector2 target) { Vector2 offset = target - hand.offset; float distance = offset.Length(); if (distance != 0f) { if (distance > 0.5f) { offset.Normalize(); if (distance <= 4f) { offset *= 0.5f; } } hand.offset += offset; } hand.velocity = Vector2.Zero; hand.rotation = 0f; }
private void IdleUpdateHand(ref VoidEmissaryHand hand, Vector2 target) { if (hand.velocity == Vector2.Zero) { float rotation = MathHelper.TwoPi * (float)Main.rand.NextDouble(); hand.velocity = 0.5f * rotation.ToRotationVector2(); } if (Vector2.Distance(hand.offset, target) >= 4f) { float dirToTarget = (target - hand.offset).ToRotation(); float disturb = MathHelper.Pi * (float)Main.rand.NextDouble() - MathHelper.PiOver2; hand.velocity = (dirToTarget + disturb).ToRotationVector2(); if (Vector2.Distance(hand.offset, target) < 5f) { hand.velocity *= 0.5f; } } hand.offset += hand.velocity; hand.rotation = 0f; }
private void DrawHand(VoidEmissaryHand hand, SpriteBatch spriteBatch) { Texture2D texture = mod.GetTexture("Items/PuritySpirit/Projectiles/VoidEmissary/VoidEmissaryHand"); Vector2 position = hand.offset; Rectangle frame = new Rectangle(0, 0, texture.Width, texture.Height / 2 - 2); if (handsOpen) { frame.Y += texture.Height / 2; } float rotation = hand.rotation + projectile.rotation; SpriteEffects effects = SpriteEffects.None; if (projectile.spriteDirection == -1) { position.X = -hand.offset.X; rotation = MathHelper.Pi - rotation; } position = position.RotatedBy(projectile.rotation); position += projectile.Center - Main.screenPosition; Vector2 origin = new Vector2(frame.Width / 2, frame.Height / 2); spriteBatch.Draw(texture, position, frame, Color.White, rotation, origin, 1f, effects, 0f); }