Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Gun Contests #1638

Merged
merged 4 commits into from
Jan 23, 2025
Merged

Conversation

sleepyyapril
Copy link
Contributor

No description provided.

@github-actions github-actions bot added Status: Needs Review Someone please review this Changes: C# Changes any cs files Changes: YML Changes any yml files labels Jan 22, 2025
@SimpleStation14 SimpleStation14 changed the title fix gun contests Fix Gun Contests Jan 22, 2025
{
var timeSinceLastFire = (curTime - component.LastFire).TotalSeconds;
var newTheta = MathHelper.Clamp(component.CurrentAngle.Theta + component.AngleIncreaseModified.Theta - component.AngleDecayModified.Theta * timeSinceLastFire, component.MinAngleModified.Theta, component.MaxAngleModified.Theta);
component.CurrentAngle = new Angle(newTheta);
component.LastFire = component.NextFire;

// Convert it so angle can go either side.
var random = Random.NextFloat(-0.5f, 0.5f);
var random = user != null ? Random.NextFloat(-0.5f, 0.5f) / _contests.MassContest(user) : Random.NextFloat(-0.5f, 0.5f);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var random = user != null ? Random.NextFloat(-0.5f, 0.5f) / _contests.MassContest(user) : Random.NextFloat(-0.5f, 0.5f);
var random = Random.NextFloat(-0.5f, 0.5f) / _contests.MassContest(user);

Actually it is capable of accepting Nullable UIDs as inputs, and will simply return 1 if the EntityUid is null. Making it safe to multiply or divide by without checking if the user is null in the first place since x / 1 = x

@VMSolidus VMSolidus merged commit 46c8540 into Simple-Station:master Jan 23, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: C# Changes any cs files Changes: YML Changes any yml files Status: Needs Review Someone please review this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants