Speed up checks for IOccupySpace trait.

Eagerly load the trait (if it exists) in Actor, and use this reference to avoid having to perform self.Info.HasTraitInfo<IOccupySpaceInfo>() checks.
This commit is contained in:
RoosterDragon
2015-10-14 20:36:32 +01:00
parent 410f121a1e
commit 262ab408b5
5 changed files with 13 additions and 18 deletions

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
{
public AmbientSound(Actor self, AmbientSoundInfo info)
{
if (self.Info.HasTraitInfo<IOccupySpaceInfo>())
if (self.OccupiesSpace != null)
Game.Sound.PlayLooped(info.SoundFile, self.CenterPosition);
else
Game.Sound.PlayLooped(info.SoundFile);