Introduced the interfaces IActor, ICacheStorage, ILog, IMap, IWorld a
nd IMobileInfo to separate concrete implementations and abstractions
This commit is contained in:
@@ -22,14 +22,36 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>
|
||||
public interface IActor
|
||||
{
|
||||
public readonly ActorInfo Info;
|
||||
ActorInfo Info { get; }
|
||||
IWorld World { get; }
|
||||
uint ActorID { get; }
|
||||
Player Owner { get; set; }
|
||||
|
||||
T TraitOrDefault<T>();
|
||||
T Trait<T>();
|
||||
IEnumerable<T> TraitsImplementing<T>();
|
||||
|
||||
T TraitInfo<T>();
|
||||
|
||||
IEnumerable<IRenderable> Render(WorldRenderer wr);
|
||||
}
|
||||
|
||||
public class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>, IActor
|
||||
{
|
||||
public ActorInfo Info { get; private set; }
|
||||
public readonly World World;
|
||||
public readonly uint ActorID;
|
||||
|
||||
IWorld IActor.World
|
||||
{
|
||||
get { return World; }
|
||||
}
|
||||
|
||||
public uint ActorID { get; private set; }
|
||||
|
||||
[Sync]
|
||||
public Player Owner;
|
||||
public Player Owner { get; set; }
|
||||
|
||||
public bool IsInWorld { get; internal set; }
|
||||
public bool Destroyed { get; private set; }
|
||||
@@ -202,6 +224,11 @@ namespace OpenRA
|
||||
return World.TraitDict.WithInterface<T>(this);
|
||||
}
|
||||
|
||||
public T TraitInfo<T>()
|
||||
{
|
||||
return Info.Traits.Get<T>();
|
||||
}
|
||||
|
||||
public bool HasTrait<T>()
|
||||
{
|
||||
return World.TraitDict.Contains<T>(this);
|
||||
@@ -235,7 +262,7 @@ namespace OpenRA
|
||||
{
|
||||
World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (this.Destroyed)
|
||||
if (Destroyed)
|
||||
return;
|
||||
|
||||
var oldOwner = Owner;
|
||||
|
||||
Reference in New Issue
Block a user