push turret facing check down to turret

This commit is contained in:
Chris Forbes
2011-08-21 21:32:39 +12:00
parent 6a092dbfda
commit c11b7041f4
3 changed files with 8 additions and 6 deletions

View File

@@ -70,9 +70,7 @@ namespace OpenRA.Mods.RA
return false; return false;
} }
Turret.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, Turret.turretFacing ); if (!Turret.FaceTarget(self,target)) return false;
if( Turret.desiredFacing != Turret.turretFacing )
return false;
return true; return true;
} }

View File

@@ -39,9 +39,7 @@ namespace OpenRA.Mods.RA
return false; return false;
if (!target.IsValid) return false; if (!target.IsValid) return false;
turret.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turret.turretFacing ); if (!turret.FaceTarget(self, target)) return false;
if( turret.desiredFacing != turret.turretFacing )
return false;
return base.CanAttack( self, target ); return base.CanAttack( self, target );
} }

View File

@@ -50,5 +50,11 @@ namespace OpenRA.Mods.RA
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing ); var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
turretFacing = Util.TickFacing(turretFacing, df, info.ROT); turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
} }
public bool FaceTarget( Actor self, Target target )
{
desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turretFacing );
return turretFacing == desiredFacing;
}
} }
} }