Make RenderUnit require IFacing; RenderSimple can be used for crates, mines, etc; fix husk facing init
This commit is contained in:
@@ -92,7 +92,7 @@ namespace OpenRA
|
|||||||
while (t.Count != 0)
|
while (t.Count != 0)
|
||||||
{
|
{
|
||||||
var prereqs = PrerequisitesOf(t[index]);
|
var prereqs = PrerequisitesOf(t[index]);
|
||||||
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || x.GetType().IsSubclassOf(n)));
|
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || n.IsAssignableFrom(x.GetType())));
|
||||||
if (!unsatisfied.Any())
|
if (!unsatisfied.Any())
|
||||||
{
|
{
|
||||||
ret.Add(t[index]);
|
ret.Add(t[index]);
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ using OpenRA.Graphics;
|
|||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public abstract class RenderSimpleInfo : ITraitInfo
|
public class RenderSimpleInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string Image = null;
|
public readonly string Image = null;
|
||||||
public readonly string Palette = null;
|
public readonly string Palette = null;
|
||||||
public readonly string PlayerPalette = "player";
|
public readonly string PlayerPalette = "player";
|
||||||
public readonly float Scale = 1f;
|
public readonly float Scale = 1f;
|
||||||
public abstract object Create(ActorInitializer init);
|
|
||||||
|
public virtual object Create(ActorInitializer init) { return new RenderSimple(init.self); }
|
||||||
|
|
||||||
public virtual IEnumerable<Renderable> RenderPreview(ActorInfo building, Player owner)
|
public virtual IEnumerable<Renderable> RenderPreview(ActorInfo building, Player owner)
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class RenderSimple : IRender, ITick
|
public class RenderSimple : IRender, ITick
|
||||||
{
|
{
|
||||||
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
|
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
|
||||||
|
|
||||||
@@ -70,6 +71,11 @@ namespace OpenRA.Traits
|
|||||||
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RenderSimple(Actor self) : this( self, MakeFacingFunc(self) )
|
||||||
|
{
|
||||||
|
anim.PlayRepeating("idle");
|
||||||
|
}
|
||||||
|
|
||||||
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; }
|
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; }
|
||||||
|
|
||||||
public virtual IEnumerable<Renderable> Render(Actor self)
|
public virtual IEnumerable<Renderable> Render(Actor self)
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ namespace OpenRA.Traits
|
|||||||
int InitialFacing { get; }
|
int InitialFacing { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IFacingInfo {} /* tag interface for infoclasses whose corresponding trait has IFacing */
|
||||||
|
|
||||||
public interface ICrushable
|
public interface ICrushable
|
||||||
{
|
{
|
||||||
void OnCrush(Actor crusher);
|
void OnCrush(Actor crusher);
|
||||||
@@ -181,7 +183,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
|
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
|
||||||
|
|
||||||
public interface Requires<T> where T : ITraitInfo { }
|
public interface Requires<T> where T : class { }
|
||||||
|
|
||||||
public interface INotifySelection { void SelectionChanged(); }
|
public interface INotifySelection { void SelectionChanged(); }
|
||||||
public interface IWorldLoaded { void WorldLoaded(World w); }
|
public interface IWorldLoaded { void WorldLoaded(World w); }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public class PlayerColorPaletteInfo : ITraitInfo
|
public class PlayerColorPaletteInfo : ITraitInfo
|
||||||
@@ -25,6 +26,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
readonly Player owner;
|
readonly Player owner;
|
||||||
readonly PlayerColorPaletteInfo info;
|
readonly PlayerColorPaletteInfo info;
|
||||||
|
|
||||||
public PlayerColorPalette( Player owner, PlayerColorPaletteInfo info )
|
public PlayerColorPalette( Player owner, PlayerColorPaletteInfo info )
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new DebugAircraftFacing(init.self); }
|
public object Create(ActorInitializer init) { return new DebugAircraftFacing(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebugAircraftFacing : ISync
|
public class DebugAircraftFacing : ISync
|
||||||
{
|
{
|
||||||
readonly Aircraft a;
|
readonly Aircraft a;
|
||||||
@@ -34,6 +35,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new DebugAircraftSubPxX(init.self); }
|
public object Create(ActorInitializer init) { return new DebugAircraftSubPxX(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebugAircraftSubPxX : ISync
|
public class DebugAircraftSubPxX : ISync
|
||||||
{
|
{
|
||||||
readonly Aircraft a;
|
readonly Aircraft a;
|
||||||
@@ -45,6 +47,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new DebugAircraftSubPxY(init.self); }
|
public object Create(ActorInitializer init) { return new DebugAircraftSubPxY(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebugAircraftSubPxY : ISync
|
public class DebugAircraftSubPxY : ISync
|
||||||
{
|
{
|
||||||
readonly Aircraft a;
|
readonly Aircraft a;
|
||||||
@@ -56,6 +59,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new DebugAircraftAltitude(init.self); }
|
public object Create(ActorInitializer init) { return new DebugAircraftAltitude(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebugAircraftAltitude : ISync
|
public class DebugAircraftAltitude : ISync
|
||||||
{
|
{
|
||||||
readonly Aircraft a;
|
readonly Aircraft a;
|
||||||
@@ -63,7 +67,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
[Sync] public int foo { get { return a.Altitude; } }
|
[Sync] public int foo { get { return a.Altitude; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AircraftInfo : ITraitInfo
|
public class AircraftInfo : ITraitInfo, IFacingInfo
|
||||||
{
|
{
|
||||||
public readonly int CruiseAltitude = 30;
|
public readonly int CruiseAltitude = 30;
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using OpenRA.Traits.Activities;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class HuskInfo : ITraitInfo
|
class HuskInfo : ITraitInfo, IFacingInfo
|
||||||
{
|
{
|
||||||
public object Create( ActorInitializer init ) { return new Husk( init ); }
|
public object Create( ActorInitializer init ) { return new Husk( init ); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using OpenRA.Traits.Activities;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Move
|
namespace OpenRA.Mods.RA.Move
|
||||||
{
|
{
|
||||||
public class MobileInfo : ITraitInfo
|
public class MobileInfo : ITraitInfo, IFacingInfo
|
||||||
{
|
{
|
||||||
[FieldLoader.LoadUsing("LoadSpeeds")]
|
[FieldLoader.LoadUsing("LoadSpeeds")]
|
||||||
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
|
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Render
|
namespace OpenRA.Mods.RA.Render
|
||||||
{
|
{
|
||||||
public class RenderUnitInfo : RenderSimpleInfo
|
public class RenderUnitInfo : RenderSimpleInfo, Requires<IFacingInfo>
|
||||||
{
|
{
|
||||||
public override object Create(ActorInitializer init) { return new RenderUnit(init.self); }
|
public override object Create(ActorInitializer init) { return new RenderUnit(init.self); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ CRATE:
|
|||||||
SelectionShares: 2
|
SelectionShares: 2
|
||||||
NoBaseSelectionShares: 9001
|
NoBaseSelectionShares: 9001
|
||||||
Unit: mcv
|
Unit: mcv
|
||||||
RenderUnit:
|
RenderSimple:
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
|
|
||||||
mpspawn:
|
mpspawn:
|
||||||
|
|||||||
@@ -267,11 +267,12 @@
|
|||||||
Types:Tree
|
Types:Tree
|
||||||
|
|
||||||
^Husk:
|
^Husk:
|
||||||
|
Husk:
|
||||||
|
RenderUnit:
|
||||||
Health:
|
Health:
|
||||||
HP: 140
|
HP: 140
|
||||||
Armor:
|
Armor:
|
||||||
Type: Heavy
|
Type: Heavy
|
||||||
Husk:
|
|
||||||
Selectable:
|
Selectable:
|
||||||
Priority: -1
|
Priority: -1
|
||||||
HiddenUnderFog:
|
HiddenUnderFog:
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ MINP:
|
|||||||
AvoidFriendly: yes
|
AvoidFriendly: yes
|
||||||
Health:
|
Health:
|
||||||
HP: 1
|
HP: 1
|
||||||
RenderUnit:
|
RenderSimple:
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
InvisibleToEnemy:
|
InvisibleToEnemy:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
@@ -220,7 +220,7 @@ MINV:
|
|||||||
AvoidFriendly: yes
|
AvoidFriendly: yes
|
||||||
Health:
|
Health:
|
||||||
HP: 1
|
HP: 1
|
||||||
RenderUnit:
|
RenderSimple:
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
InvisibleToEnemy:
|
InvisibleToEnemy:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
@@ -283,7 +283,7 @@ CRATE:
|
|||||||
GiveUnitCrateAction@4tnk:
|
GiveUnitCrateAction@4tnk:
|
||||||
SelectionShares: 3
|
SelectionShares: 3
|
||||||
Unit: 4tnk
|
Unit: 4tnk
|
||||||
RenderUnit:
|
RenderSimple:
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Crate
|
Types:Crate
|
||||||
|
|||||||
Reference in New Issue
Block a user