more. doesn't run. may not compile
This commit is contained in:
@@ -212,14 +212,16 @@ namespace OpenRA
|
|||||||
World.traitDict.AddTrait( this, trait );
|
World.traitDict.AddTrait( this, trait );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Destroyed { get; private set; }
|
||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
World.AddFrameEndTask( w => World.Remove( this ) );
|
World.AddFrameEndTask( w =>
|
||||||
}
|
|
||||||
|
|
||||||
~Actor()
|
|
||||||
{
|
{
|
||||||
|
World.Remove( this );
|
||||||
World.traitDict.RemoveActor( this );
|
World.traitDict.RemoveActor( this );
|
||||||
|
Destroyed = true;
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,27 +47,35 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool Contains<T>( Actor actor )
|
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;
|
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID ).Count() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Get<T>( Actor actor )
|
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 );
|
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).Get( actor.ActorID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetOrDefault<T>( Actor actor )
|
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 );
|
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetOrDefault( actor.ActorID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T> WithInterface<T>( Actor actor )
|
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 );
|
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<TraitPair<T>> ActorsWithTraitMultiple<T>( World world )
|
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 )
|
public void RemoveActor( Actor a )
|
||||||
|
|||||||
@@ -88,20 +88,6 @@ namespace OpenRA.Traits
|
|||||||
damage = (int)(damage * modifier);
|
damage = (int)(damage * modifier);
|
||||||
|
|
||||||
hp -= damage;
|
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>())
|
foreach (var nd in self.TraitsImplementing<INotifyDamage>())
|
||||||
nd.Damaged(self, new AttackInfo
|
nd.Damaged(self, new AttackInfo
|
||||||
@@ -113,6 +99,21 @@ namespace OpenRA.Traits
|
|||||||
DamageStateChanged = this.DamageState != oldState,
|
DamageStateChanged = this.DamageState != oldState,
|
||||||
Warhead = warhead
|
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)
|
return ActorsInBins(a.X / scale, b.X / scale, a.Y / scale, b.Y / scale)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.Where(u => u.GetBounds(true).IntersectsWith(r));
|
.Where(u => u.IsInWorld && u.GetBounds(true).IntersectsWith(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user