Kill Util.Centered
This commit is contained in:
@@ -70,7 +70,7 @@ namespace OpenRA.Traits
|
||||
foreach( var a in anims.Values )
|
||||
if( a.DisableFunc == null || !a.DisableFunc() )
|
||||
{
|
||||
Renderable ret = a.Image( self ).WithPalette(Palette(self.Owner));
|
||||
Renderable ret = a.Image(self, Palette(self.Owner));
|
||||
if (Info.Scale != 1f)
|
||||
ret = ret.WithScale(Info.Scale).WithPos(ret.Pos + 0.5f*ret.Sprite.size*(1 - Info.Scale));
|
||||
yield return ret;
|
||||
@@ -118,10 +118,12 @@ namespace OpenRA.Traits
|
||||
this.DisableFunc = d;
|
||||
}
|
||||
|
||||
public Renderable Image( Actor self )
|
||||
public Renderable Image( Actor self, string pal )
|
||||
{
|
||||
var r = Util.Centered( self, Animation.Image, self.CenterLocation
|
||||
+ (OffsetFunc != null ? OffsetFunc() : float2.Zero) );
|
||||
var loc = self.CenterLocation - 0.5f * Animation.Image.size
|
||||
+ (OffsetFunc != null ? OffsetFunc() : float2.Zero);
|
||||
var r = new Renderable(Animation.Image, loc, pal, (int)self.CenterLocation.Y);
|
||||
|
||||
return ZOffset != 0 ? r.WithZOffset(ZOffset) : r;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,14 +96,6 @@ namespace OpenRA.Traits
|
||||
public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); }
|
||||
public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); }
|
||||
|
||||
public static Renderable Centered(Actor self, Sprite s, float2 location)
|
||||
{
|
||||
var pal = "player{0}".F(self.Owner == null ? 0 : self.Owner.Index);
|
||||
var loc = location - 0.5f * s.size;
|
||||
|
||||
return new Renderable(s, loc.Round(), pal, (int)self.CenterLocation.Y);
|
||||
}
|
||||
|
||||
public static Activity SequenceActivities(params Activity[] acts)
|
||||
{
|
||||
return acts.Reverse().Aggregate(
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class GpsDotInfo : ITraitInfo
|
||||
class GpsDotInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
|
||||
{
|
||||
public readonly string String = "Infantry";
|
||||
public object Create(ActorInitializer init)
|
||||
@@ -27,10 +27,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
class GpsDot : IEffect
|
||||
{
|
||||
int2 loc;
|
||||
Color color;
|
||||
Actor self;
|
||||
GpsWatcher watcher;
|
||||
RenderSimple rs;
|
||||
bool show = false;
|
||||
Animation anim;
|
||||
|
||||
@@ -40,8 +39,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
anim.PlayRepeating(s);
|
||||
|
||||
self = init.self;
|
||||
loc = self.CenterLocation;
|
||||
color = self.Owner.ColorRamp.GetColor(0);
|
||||
rs = self.Trait<RenderSimple>();
|
||||
self.World.AddFrameEndTask(w => w.Add(this));
|
||||
if(self.World.LocalPlayer != null)
|
||||
watcher = self.World.LocalPlayer.PlayerActor.Trait<GpsWatcher>();
|
||||
@@ -65,14 +63,13 @@ namespace OpenRA.Mods.RA.Effects
|
||||
)
|
||||
{
|
||||
show = true;
|
||||
loc = self.CenterLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (show && !self.Destroyed)
|
||||
yield return Traits.Util.Centered(self, anim.Image, self.CenterLocation.ToFloat2())
|
||||
yield return new Renderable(anim.Image, self.CenterLocation - 0.5f * anim.Image.size, rs.Palette(self.Owner), (int)self.CenterLocation.Y)
|
||||
.WithScale(1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace OpenRA.Mods.RA.Effects
|
||||
readonly float2 location;
|
||||
|
||||
readonly Actor cargo;
|
||||
readonly Player owner;
|
||||
|
||||
float altitude;
|
||||
const float fallRate = .3f;
|
||||
@@ -34,7 +33,6 @@ namespace OpenRA.Mods.RA.Effects
|
||||
this.location = location;
|
||||
this.altitude = altitude;
|
||||
this.cargo = cargo;
|
||||
this.owner = owner;
|
||||
|
||||
var rs = cargo.Trait<RenderSimple>();
|
||||
var image = rs.anim.Name;
|
||||
|
||||
Reference in New Issue
Block a user