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

Streamline turret render traits - part 2 #14036

Closed
wants to merge 6 commits into from

Conversation

reaperrr
Copy link
Contributor

@reaperrr reaperrr commented Sep 16, 2017

My idea for making #13619 more flexible is to use integer priority values instead of a single boolean, but even independently from that, our current turret render traits are a bit of a mess, especially when it comes to anything dealing with "aiming" at a target.
This needs to be sorted out first to avoid problems and work-arounds in #13619.

This PR straightens out that mess, so that both #13619 as well as any future additional WithTurret*Animation traits should have an easier time to do what they're intended to do without implicit conflicts or compatibility issues.

var sequence = Attack.IsAttacking ? Info.AimSequence : Info.Sequence;
DefaultAnimation.ReplaceAnim(sequence);
}
protected virtual void Tick(Actor self) { }
Copy link
Member

Choose a reason for hiding this comment

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

Better to remove ITick completely, and if a subclass wants to tick then they can implement the interface themselves.

}

void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Attack)
Copy link
Member

Choose a reason for hiding this comment

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

This appears to be almost completely duplicated with INotifyAttack.PreparingAttack.
Could you split out a void NotifyAttack(Actor self, AttackDelayType type) method that is called from each?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

PlayAttackAnimation(self);

if (string.IsNullOrEmpty(info.AimSequence) && string.IsNullOrEmpty(info.ReloadPrefix))
if (IsTraitDisabled)
Copy link
Member

Choose a reason for hiding this comment

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

Not much point having this as an early return. Just add !IsTraitDisabled to the if statement below.

@@ -235,3 +235,10 @@ Cursors:
Length: 8
attackoutsiderange-minimap:
Start: 8
mouse8.shp: cursor
Copy link
Member

Choose a reason for hiding this comment

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

Rebase error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops.


public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
var matches = ai.TraitInfos<WithTurretAimAnimationInfo>().Count(t => t.Turret == Turret);
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: .Any(t => t.Turret == Turret) instead of Count != 0.


public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
var turretAttackAnim = ai.TraitInfos<WithTurretAttackAnimationInfo>().Any();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be checking the turret the same way as WithTurretAmmoReloadAnimationInfo?

@reaperrr
Copy link
Contributor Author

Basically depends on #13538 due to
#13538 (review)

@reaperrr
Copy link
Contributor Author

Updated and rebased.

Note: Added a testcase commit that needs to be removed before merging (makes cnc mobile sam able to attack ground, for easier testing).

@reaperrr reaperrr force-pushed the refactor-turret-rendertraits2 branch 2 times, most recently from 8e8dda8 to 40ef9c6 Compare November 15, 2017 18:20
@reaperrr
Copy link
Contributor Author

Rebased and updated.

Moved testcase here (TD Nod Mobile SAM):
https://github.com/reaperrr/OpenRA/tree/refact-tur-render2-testcase

@penev92
Copy link
Member

penev92 commented Nov 27, 2017

Has merge conflicts again with god-knows-what.

@GraionDilach
Copy link
Contributor

With #14202.

@reaperrr reaperrr force-pushed the refactor-turret-rendertraits2 branch from 40ef9c6 to 18a1196 Compare November 28, 2017 18:52
@reaperrr
Copy link
Contributor Author

Rebased.

With #14202.

And #14425.

@reaperrr
Copy link
Contributor Author

Rebased.

@abcdefg30
Copy link
Member

And needs another rebase.

@reaperrr
Copy link
Contributor Author

reaperrr commented Jan 4, 2018

I guess there's no point in rebasing this until the upgrade rule refactor is merged.

@Arular101
Copy link
Contributor

Please don't forget to update the copyright notice year.

WithReloadingSpriteTurret was bound to run into conflicts with any WithTurret*Animation traits due to overriding the turret sequence constantly via ITick.
Using (stacked) conditions instead avoids that.
@reaperrr reaperrr force-pushed the refactor-turret-rendertraits2 branch from c0c2e06 to 045b186 Compare February 23, 2018 03:10
These two didn't interact and actually even conflicted when used at the same time, so splitting them is the sensible thing to do.
We can now use WithTurretAimAnimation instead.
@reaperrr
Copy link
Contributor Author

Rebased and updated.

@reaperrr
Copy link
Contributor Author

reaperrr commented Mar 6, 2018

Superseded by #14845, #14846 and a future third PR that will contain the rest of the changes from this one.

@reaperrr reaperrr closed this Mar 6, 2018
@reaperrr reaperrr deleted the refactor-turret-rendertraits2 branch March 9, 2018 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants