diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index 40076f2a3b..b09e7ac4d5 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -195,7 +195,7 @@ namespace OpenRA.Traits public int2 TopLeft { get { return toCell; } } - public virtual IEnumerable OccupiedCells() + public IEnumerable OccupiedCells() { return (fromCell == toCell) ? new[] { fromCell } @@ -209,7 +209,7 @@ namespace OpenRA.Traits return CanEnterCell( p, null, true); } - public virtual bool CanEnterCell( int2 cell, Actor ignoreActor, bool checkTransientActors ) + public bool CanEnterCell( int2 cell, Actor ignoreActor, bool checkTransientActors ) { return CanEnterCell( Info, self.World, cell, ignoreActor, checkTransientActors ); } @@ -238,23 +238,22 @@ namespace OpenRA.Traits } // Check mobile actors - if (checkTransientActors && uim.AnyUnitsAt(cell)) + var blockingActors = uim.GetUnitsAt( cell ).Where( x => x != ignoreActor ).ToList(); + if (checkTransientActors && blockingActors.Count > 0) { - var actors = uim.GetUnitsAt(cell).Where(a => a != ignoreActor).ToArray(); // We can enter a cell with nonshareable units only if we can crush all of them - if (mobileInfo.Crushes == null && actors.Length > 0) + if (mobileInfo.Crushes == null) return false; - if (actors.Length > 0 && actors.Any(a => !(a.HasTrait() && + if (blockingActors.Any(a => !(a.HasTrait() && a.TraitsImplementing().Any(b => b.CrushClasses.Intersect(mobileInfo.Crushes).Any())))) return false; } - return true; } - public virtual void FinishedMoving(Actor self) + public void FinishedMoving(Actor self) { var crushable = uim.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait()); foreach (var a in crushable) @@ -282,7 +281,7 @@ namespace OpenRA.Traits return info.TerrainSpeeds[type].Cost; } - public virtual float MovementSpeedForCell(Actor self, int2 cell) + public float MovementSpeedForCell(Actor self, int2 cell) { var type = self.World.GetTerrainType(cell); @@ -304,12 +303,12 @@ namespace OpenRA.Traits return Enumerable.Reverse(move.path).Select( c => Util.CenterOfCell(c) ); } - public virtual void AddInfluence() + public void AddInfluence() { uim.Add( self, this ); } - public virtual void RemoveInfluence() + public void RemoveInfluence() { uim.Remove( self, this ); } diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index 9fc983915c..44422fde9f 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -271,7 +271,7 @@ namespace OpenRA.Traits var sp = self.TraitsImplementing().Where(p => p.Info.Produces.Contains(Info.Type)).FirstOrDefault(); if (sp != null && !IsDisabledBuilding(self) && sp.Produce(self, Rules.Info[ name ])) FinishProduction(); - } + } } } diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index 8b983ca380..f62885380a 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -33,26 +33,17 @@ namespace OpenRA.Mods.Cnc public void Tick(Actor self) { - if (--poisonTicks <= 0) - { - var rl = self.World.WorldActor.Trait(); - var r = rl.GetResource(self.Location); + if (--poisonTicks > 0) return; - if (r != null && info.Resources.Contains(r.info.Name)) - Combat.DoImpacts(new ProjectileArgs - { - src = self.CenterLocation.ToInt2(), - dest = self.CenterLocation.ToInt2(), - srcAltitude = 0, - destAltitude = 0, - facing = 0, - firedBy = self, - target = Target.FromActor(self), - weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()] - }); + var rl = self.World.WorldActor.Trait(); + var r = rl.GetResource(self.Location); + if( r == null ) return; + if( !info.Resources.Contains(r.info.Name) ) return; - poisonTicks = Rules.Weapons[info.Weapon.ToLowerInvariant()].ROF; - } + var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]; + + self.InflictDamage( self.World.WorldActor, weapon.Warheads[ 0 ].Damage, weapon.Warheads[ 0 ] ); + poisonTicks = weapon.ROF; } } }