private static GolfHelper.ShotStrength CalculateShotStrength( Vector2 shotVector, GolfHelper.ClubProperties clubProperties) { Vector2.Normalize(shotVector); double num1 = (double)shotVector.Length(); float num2 = GolfHelper.FindVectorOnOval(shotVector, clubProperties.MaximumStrength).Length(); float num3 = GolfHelper.FindVectorOnOval(shotVector, clubProperties.MinimumStrength).Length(); double num4 = (double)num3; double num5 = (double)num2; double num6 = (double)MathHelper.Clamp((float)num1, (float)num4, (float)num5); return(new GolfHelper.ShotStrength((float)(num6 * 32.0), Math.Max((float)((num6 - (double)num3) / ((double)num2 - (double)num3)), 1f / 1000f), clubProperties.RoughLandResistance)); }
public void Update(Entity golfBall, Vector2 impactVelocity, float roughLandResistance) { bool flag = Main.tileSolid[379]; Main.tileSolid[379] = false; this._positions.Clear(); this._time += 0.01666667f; this._entity.position = golfBall.position; this._entity.width = golfBall.width; this._entity.height = golfBall.height; GolfHelper.HitGolfBall(this._entity, impactVelocity, roughLandResistance); this._positions.Add(this._entity.position); float angularVelocity = 0.0f; for (int index = 0; index < this._iterations; ++index) { GolfHelper.StepGolfBall(this._entity, ref angularVelocity); this._positions.Add(this._entity.position); } Main.tileSolid[379] = flag; }
public static GolfHelper.ShotStrength CalculateShotStrength( Projectile golfHelper, Entity golfBall) { int num1 = Main.screenWidth; if (num1 > Main.screenHeight) { num1 = Main.screenHeight; } int num2 = 150; int num3 = (num1 - num2) / 2; if (num3 < 200) { num3 = 200; } float num4 = 300f; return((double)golfHelper.ai[0] != 0.0 ? new GolfHelper.ShotStrength() : GolfHelper.CalculateShotStrength((golfHelper.Center - golfBall.Center) / num4, GolfHelper.GetClubPropertiesFromGolfHelper(golfHelper))); }
public void Update(Entity golfBall, Vector2 impactVelocity, float roughLandResistance) { bool flag = Main.tileSolid[379]; Main.tileSolid[379] = false; _positions.Clear(); _time += 0.0166666675f; _entity.position = golfBall.position; _entity.width = golfBall.width; _entity.height = golfBall.height; GolfHelper.HitGolfBall(_entity, impactVelocity, roughLandResistance); _positions.Add(_entity.position); float angularVelocity = 0f; for (int i = 0; i < _iterations; i++) { GolfHelper.StepGolfBall(_entity, angularVelocity); _positions.Add(_entity.position); } Main.tileSolid[379] = flag; }
public static Projectile FindGolfBallForHelper(Projectile golfHelper) { for (int index = 0; index < 1000; ++index) { Projectile projectile = Main.projectile[index]; Vector2 shotVector = golfHelper.Center - projectile.Center; if (projectile.active && ProjectileID.Sets.IsAGolfBall[projectile.type] && (projectile.owner == golfHelper.owner && GolfHelper.ValidateShot((Entity)projectile, Main.player[golfHelper.owner], ref shotVector))) { return(Main.projectile[index]); } } return((Projectile)null); }
private static GolfHelper.ClubProperties GetClubPropertiesFromGolfHelper( Projectile golfHelper) { return(GolfHelper.GetClubProperties((short)Main.player[golfHelper.owner].HeldItem.type)); }