38 public ShotStrength(
float absoluteStrength,
float relativeStrength,
float roughLandResistance)
53 velocity = vector + vector2;
55 switch (collision.Tile.type)
60 float num2 = 2.5f * collision.TimeScale;
61 Vector2 vector3 =
new Vector2(0f - collision.Normal.Y, collision.Normal.X);
62 if (collision.Tile.type == 422)
75 float num = velocity.Length() / collision.TimeScale;
76 if (!(collision.Normal.Y > -0.01f) && !(num > 100f))
79 if (projectile !=
null && projectile.
active)
87 if (projectile !=
null && velocity.Y < -0.3f && velocity.Y > -2f && velocity.Length() > 1f)
92 dust.velocity = dust.velocity * 0.5f +
Main.
rand.NextVector2CircularEdge(0.5f, 0.4f);
100 Point hitLocation = (collision.ImpactPoint - collision.Normal * 0.5f).ToTileCoordinates();
101 int owner = proj.
owner;
102 int num = (int)proj.
ai[1];
113 Main.
player[owner].AccumulateGolfingScore(golfBallScore);
129 if (numberOfHits != 0)
132 string key =
"Game.BallBounceResultGolf_Single";
134 if (numberOfHits != 1)
136 key =
"Game.BallBounceResultGolf_Plural";
156 switch (collision.Type)
160 angularVelocity *= 0.91f;
164 angularVelocity *= 0.8f;
186 for (
float num = 0f; num < 1f; num += 0.085f)
190 dust.noGravity =
true;
191 dust.velocity.X *= 0.7f;
192 dust.velocity.Y -= 1.5f;
193 dust.position.Y += 8f;
194 dust.velocity.X *= 2f;
199 for (
int i = 0; (float)i < num3; i++)
205 for (
int j = 0; j < num4; j++)
210 dust2.noGravity =
true;
211 dust2.position.Y += -1f;
212 dust2.velocity *= (float)j;
213 dust2.scale += 0.2f - (float)j * 0.03f;
214 dust2.velocity +=
Main.
rand.NextVector2Circular(0.05f, 0.05f);
218 for (
float num5 = 0f; num5 < 1f; num5 += 0.2f)
222 dust3.noGravity =
true;
223 dust3.velocity.X *= 0.7f;
224 dust3.velocity.Y -= 0.5f;
225 dust3.position.Y += 8f;
226 dust3.velocity.X *= 2f;
229 float num6 =
Main.
rand.NextFloatDirection();
230 for (
float num7 = 0f; num7 < 1f; num7 += 0.15f)
234 dust4.velocity *= 0.5f + num7 * 0.8f;
235 dust4.noGravity =
true;
236 dust4.velocity.X *= 0.35f;
237 dust4.velocity.Y *= 2f;
238 dust4.velocity.Y -= 1f;
240 dust4.position += dust4.velocity * 3f;
247 for (
float num = 0f; num < 1f; num += 0.085f)
251 dust.noGravity =
true;
252 dust.velocity.X *= 0.7f;
253 dust.velocity.Y -= 1.5f;
254 dust.position.Y += 8f;
257 for (
float num2 = 0f; num2 < 1f; num2 += 0.2f)
261 dust2.noGravity =
true;
262 dust2.velocity.X *= 0.7f;
263 dust2.velocity.Y -= 0.5f;
264 dust2.position.Y += 8f;
267 float num3 =
Main.
rand.NextFloatDirection();
268 for (
float num4 = 0f; num4 < 1f; num4 += 0.15f)
272 dust3.velocity *= 0.5f + num4 * 0.8f;
273 dust3.noGravity =
true;
274 dust3.velocity.X *= 0.35f;
275 dust3.velocity.Y *= 2f;
276 dust3.velocity.Y -= 1f;
278 dust3.position += dust3.velocity * 3f;
317 float relativeStrength =
Math.
Max((num3 - num2) / (num - num2), 0.001f);
323 if (player ==
null || player.
HeldItem ==
null)
328 if (
type == 4039 || (uint)(
type - 4092) <= 2u || (uint)(
type - 4587) <= 11u)
351 if (golfHelper.
ai[0] != 0f)
355 Vector2 shotVector = (golfHelper.Center - golfBall.
Center) / num3;
392 for (
int i = 0; i < 1000; i++)
405 for (
int i = 0; i < 1000; i++)
419 if ((
int)golfBall.
localAI[1] != 0)
433 if (vector.
X >= -16f && vector.
X <= 32f && vector.
Y <= 16f)
435 return vector.Y >= -16f;
448 float num = shotVector.ToRotation();
453 else if (num < -1.5207964f)
455 shotVector = shotVector.Length() *
new Vector2((
float)
Math.
Cos(-1.5207964181900024), (
float)
Math.
Sin(-1.5207964181900024));
461 if (vector.
X >= -16f && vector.
X <= 32f && vector.
Y <= 16f)
463 return vector.Y >= -16f;
472 Point point = bottom.ToTileCoordinates();
474 if (tile !=
null && tile.
active())
479 entity.velocity = velocity;
482 projectile.timeLeft = 18000;
483 if (projectile.ai[1] < 0f)
485 projectile.ai[1] = 0f;
487 projectile.ai[1] += 1f;
488 projectile.localAI[1] = 1f;
499 PredictionLine.Update(golfBall, impactVelocity, roughLandResistance);
static float Clamp(float value, float min, float max)
static double Cos(double d)
static double Abs(double value)
static double Sin(double a)
static byte Max(byte val1, byte val2)
static void PlaySound(int type, Vector2 position, int style=1)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
static Dust NewDustPerfect(Vector2 Position, int Type, Vector2? Velocity=null, int Alpha=0, Color newColor=default(Color), float Scale=1f)
void OnCollision(PhysicsProperties properties, ref Vector2 position, ref Vector2 velocity, ref BallCollisionEvent collision)
void PutBallInCup(Projectile proj, BallCollisionEvent collision)
void OnPassThrough(PhysicsProperties properties, ref Vector2 position, ref Vector2 velocity, ref float angularVelocity, ref BallPassThroughEvent collision)
static void PutBallInCup_TextAndEffects(Point hitLocation, int plr, int numberOfHits, int projid)
static void EmitGolfballExplosion_v1(Vector2 Center)
static void EmitGolfballExplosion_Old(Vector2 Center)
static void EmitGolfballExplosion(Vector2 Center)
static readonly PhysicsProperties PhysicsProperties
const int PointsNeededForLevel1
static FancyGolfPredictionLine PredictionLine
static void HitGolfBall(Entity entity, Vector2 velocity, float roughLandResistance)
static Vector2 FindVectorOnOval(Vector2 vector, Vector2 radius)
static bool ValidateShot(Entity golfBall, Player player, ref Vector2 shotVector)
static ShotStrength CalculateShotStrength(Vector2 shotVector, ClubProperties clubProperties)
static Projectile FindGolfBallForHelper(Projectile golfHelper)
static ClubProperties GetClubPropertiesFromGolfHelper(Projectile golfHelper)
static BallStepResult StepGolfBall(Entity entity, ref float angularVelocity)
static readonly ContactListener Listener
static Projectile FindHelperFromGolfBall(Projectile golfBall)
static void DrawPredictionLine(Entity golfBall, Vector2 impactVelocity, float chargeProgress, float roughLandResistance)
static bool IsGolfBallResting(Projectile golfBall)
const int PointsNeededForLevel2
static ShotStrength CalculateShotStrength(Projectile golfHelper, Entity golfBall)
const int PointsNeededForLevel3
static ClubProperties GetClubProperties(short itemId)
static bool IsGolfShotValid(Entity golfBall, Player player)
static bool IsPlayerHoldingClub(Player player)
float SideImpactDampening
float PassThroughDampening
float ClubImpactDampening
float ImpactDampeningResistanceEfficiency
TileGolfPhysics GolfPhysics
static TileMaterial GetByTileId(ushort tileId)
static bool[] IsAGolfBall
static readonly LegacySoundStyle Item129
static LocalizedText GetProjectileName(int type)
override string ToString()
static NetworkText FromKey(string key, params object[] substitutions)
static GolfState LocalGolfState
static SpriteBatch spriteBatch
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
static Projectile[] projectile
static UnifiedRandom rand
static Microsoft.Xna.Framework.Color hslToRgb(Vector3 hslVector)
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
static BallStepResult Step(PhysicsProperties physicsProperties, Entity entity, ref float entityAngularVelocity, IBallContactListener listener)
static void HitSwitch(int i, int j)
static Color Lerp(Color value1, Color value2, float amount)
static float Dot(Vector2 value1, Vector2 value2)
static float Distance(Vector2 value1, Vector2 value2)
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
ClubProperties(Vector2 minimumStrength, Vector2 maximumStrength, float roughLandResistance)
readonly float RoughLandResistance
readonly Vector2 MinimumStrength
readonly Vector2 MaximumStrength
ShotStrength(float absoluteStrength, float relativeStrength, float roughLandResistance)
readonly float RelativeStrength
readonly float AbsoluteStrength
readonly float RoughLandResistance