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