more. doesn't run. may not compile
This commit is contained in:
@@ -212,14 +212,16 @@ namespace OpenRA
|
||||
World.traitDict.AddTrait( this, trait );
|
||||
}
|
||||
|
||||
public bool Destroyed { get; private set; }
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
World.AddFrameEndTask( w => World.Remove( this ) );
|
||||
}
|
||||
|
||||
~Actor()
|
||||
World.AddFrameEndTask( w =>
|
||||
{
|
||||
World.Remove( this );
|
||||
World.traitDict.RemoveActor( this );
|
||||
Destroyed = true;
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,27 +47,35 @@ namespace OpenRA
|
||||
|
||||
public bool Contains<T>( Actor actor )
|
||||
{
|
||||
if( actor.Destroyed )
|
||||
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID ).Count() != 0;
|
||||
}
|
||||
|
||||
public T Get<T>( Actor actor )
|
||||
{
|
||||
if( actor.Destroyed )
|
||||
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).Get( actor.ActorID );
|
||||
}
|
||||
|
||||
public T GetOrDefault<T>( Actor actor )
|
||||
{
|
||||
if( actor.Destroyed )
|
||||
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetOrDefault( actor.ActorID );
|
||||
}
|
||||
|
||||
public IEnumerable<T> WithInterface<T>( Actor actor )
|
||||
{
|
||||
if( actor.Destroyed )
|
||||
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID );
|
||||
}
|
||||
|
||||
public IEnumerable<TraitPair<T>> ActorsWithTraitMultiple<T>( World world )
|
||||
{
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).All().Where( x => x.Actor.IsInWorld );
|
||||
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).All();//.Where( x => x.Actor.IsInWorld );
|
||||
}
|
||||
|
||||
public void RemoveActor( Actor a )
|
||||
|
||||
@@ -88,20 +88,6 @@ namespace OpenRA.Traits
|
||||
damage = (int)(damage * modifier);
|
||||
|
||||
hp -= damage;
|
||||
if (hp <= 0)
|
||||
{
|
||||
hp = 0;
|
||||
|
||||
attacker.Owner.Kills++;
|
||||
self.Owner.Deaths++;
|
||||
|
||||
if (RemoveOnDeath)
|
||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
Log.Write("debug", "{0} #{1} killed by {2} #{3}", self.Info.Name, self.ActorID, attacker.Info.Name, attacker.ActorID);
|
||||
}
|
||||
|
||||
if (hp > MaxHP) hp = MaxHP;
|
||||
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDamage>())
|
||||
nd.Damaged(self, new AttackInfo
|
||||
@@ -113,6 +99,21 @@ namespace OpenRA.Traits
|
||||
DamageStateChanged = this.DamageState != oldState,
|
||||
Warhead = warhead
|
||||
});
|
||||
|
||||
if (hp <= 0)
|
||||
{
|
||||
hp = 0;
|
||||
|
||||
attacker.Owner.Kills++;
|
||||
self.Owner.Deaths++;
|
||||
|
||||
if( RemoveOnDeath )
|
||||
self.Destroy();
|
||||
|
||||
Log.Write("debug", "{0} #{1} killed by {2} #{3}", self.Info.Name, self.ActorID, attacker.Info.Name, attacker.ActorID);
|
||||
}
|
||||
|
||||
if (hp > MaxHP) hp = MaxHP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Traits
|
||||
|
||||
return ActorsInBins(a.X / scale, b.X / scale, a.Y / scale, b.Y / scale)
|
||||
.Distinct()
|
||||
.Where(u => u.GetBounds(true).IntersectsWith(r));
|
||||
.Where(u => u.IsInWorld && u.GetBounds(true).IntersectsWith(r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user