most of the support for boats
This commit is contained in:
@@ -188,9 +188,11 @@ namespace OpenRa.Game
|
|||||||
new VoicePool("await1", "ready", "report1", "yessir1"));
|
new VoicePool("await1", "ready", "report1", "yessir1"));
|
||||||
|
|
||||||
public static void BuildUnit(Player player, string name)
|
public static void BuildUnit(Player player, string name)
|
||||||
{
|
{
|
||||||
|
var producerTypes = Rules.UnitInfo[name].BuiltAt;
|
||||||
var producer = world.Actors
|
var producer = world.Actors
|
||||||
.FirstOrDefault(a => a.unitInfo != null && a.unitInfo.Name == "weap" && a.Owner == player);
|
.FirstOrDefault(a => a.unitInfo != null
|
||||||
|
&& producerTypes.Contains(a.unitInfo.Name) && a.Owner == player);
|
||||||
|
|
||||||
if (producer == null)
|
if (producer == null)
|
||||||
throw new InvalidOperationException("BuildUnit without suitable production structure!");
|
throw new InvalidOperationException("BuildUnit without suitable production structure!");
|
||||||
@@ -202,7 +204,6 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
world.AddFrameEndTask(_ => world.Add(unit));
|
world.AddFrameEndTask(_ => world.Add(unit));
|
||||||
|
|
||||||
// todo: make the producing building play `build`
|
|
||||||
if (producer.traits.Contains<RenderWarFactory>())
|
if (producer.traits.Contains<RenderWarFactory>())
|
||||||
producer.traits.Get<RenderWarFactory>().EjectUnit();
|
producer.traits.Get<RenderWarFactory>().EjectUnit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRa.Game.GameRules
|
|||||||
public readonly bool Invisible = false;
|
public readonly bool Invisible = false;
|
||||||
public readonly string Owner = "allies,soviet"; // TODO: make this an enum
|
public readonly string Owner = "allies,soviet"; // TODO: make this an enum
|
||||||
public readonly int Points = 0;
|
public readonly int Points = 0;
|
||||||
public readonly string[] Prerequisite = new string[ 0 ];
|
public readonly string[] Prerequisite = { };
|
||||||
public readonly string Primary = null;
|
public readonly string Primary = null;
|
||||||
public readonly string Secondary = null;
|
public readonly string Secondary = null;
|
||||||
public readonly int ROT = 0;
|
public readonly int ROT = 0;
|
||||||
@@ -45,6 +45,8 @@ namespace OpenRa.Game.GameRules
|
|||||||
public readonly int Sight = 1;
|
public readonly int Sight = 1;
|
||||||
public readonly int Strength = 1;
|
public readonly int Strength = 1;
|
||||||
public readonly int TechLevel = -1;
|
public readonly int TechLevel = -1;
|
||||||
|
public readonly bool WaterBound = false;
|
||||||
|
public readonly string[] BuiltAt = { };
|
||||||
|
|
||||||
public UnitInfo(string name) { Name = name; }
|
public UnitInfo(string name) { Name = name; }
|
||||||
|
|
||||||
@@ -89,7 +91,6 @@ namespace OpenRa.Game.GameRules
|
|||||||
public readonly bool Repairable = true;
|
public readonly bool Repairable = true;
|
||||||
public readonly int Storage = 0;
|
public readonly int Storage = 0;
|
||||||
public readonly bool Unsellable = false;
|
public readonly bool Unsellable = false;
|
||||||
public readonly bool WaterBound = false;
|
|
||||||
|
|
||||||
public BuildingInfo(string name) : base(name) { }
|
public BuildingInfo(string name) : base(name) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
class Animation
|
class Animation
|
||||||
{
|
{
|
||||||
readonly string name;
|
readonly string name;
|
||||||
Sequence currentSequence;
|
public Sequence CurrentSequence { get; private set; }
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
bool backwards = false;
|
bool backwards = false;
|
||||||
bool tickAlways;
|
bool tickAlways;
|
||||||
@@ -21,12 +21,12 @@ namespace OpenRa.Game.Graphics
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
return backwards
|
return backwards
|
||||||
? currentSequence.GetSprite(currentSequence.End - frame - 1)
|
? CurrentSequence.GetSprite(CurrentSequence.End - frame - 1)
|
||||||
: currentSequence.GetSprite(frame);
|
: CurrentSequence.GetSprite(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float2 Center { get { return 0.25f * new float2(currentSequence.GetSprite(0).bounds.Size); } }
|
public float2 Center { get { return 0.25f * new float2(CurrentSequence.GetSprite(0).bounds.Size); } }
|
||||||
|
|
||||||
public void Play( string sequenceName )
|
public void Play( string sequenceName )
|
||||||
{
|
{
|
||||||
@@ -47,14 +47,14 @@ namespace OpenRa.Game.Graphics
|
|||||||
{
|
{
|
||||||
backwards = false;
|
backwards = false;
|
||||||
tickAlways = false;
|
tickAlways = false;
|
||||||
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
CurrentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
||||||
frame = 0;
|
frame = 0;
|
||||||
tickFunc = () =>
|
tickFunc = () =>
|
||||||
{
|
{
|
||||||
++frame;
|
++frame;
|
||||||
if( frame >= currentSequence.Length )
|
if( frame >= CurrentSequence.Length )
|
||||||
{
|
{
|
||||||
frame = currentSequence.Length - 1;
|
frame = CurrentSequence.Length - 1;
|
||||||
tickFunc = () => { };
|
tickFunc = () => { };
|
||||||
after();
|
after();
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
{
|
{
|
||||||
backwards = false;
|
backwards = false;
|
||||||
tickAlways = true;
|
tickAlways = true;
|
||||||
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
CurrentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
||||||
frame = func();
|
frame = func();
|
||||||
tickFunc = () => frame = func();
|
tickFunc = () => frame = func();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,10 +70,9 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public UnitMovementType GetMovementType()
|
public UnitMovementType GetMovementType()
|
||||||
{
|
{
|
||||||
/* todo: boats */
|
|
||||||
|
|
||||||
var vi = self.unitInfo as UnitInfo.VehicleInfo;
|
var vi = self.unitInfo as UnitInfo.VehicleInfo;
|
||||||
if (vi == null) return UnitMovementType.Foot;
|
if (vi == null) return UnitMovementType.Foot;
|
||||||
|
if (vi.WaterBound) return UnitMovementType.Float;
|
||||||
return vi.Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
return vi.Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ namespace OpenRa.Game.Traits
|
|||||||
public RenderUnit(Actor self)
|
public RenderUnit(Actor self)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
anim.PlayFetchIndex("idle", () => self.traits.Get<Mobile>().facing / 8);
|
anim.PlayFetchIndex("idle",
|
||||||
|
() => self.traits.Get<Mobile>().facing
|
||||||
|
/ (256/anim.CurrentSequence.Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Pair<Sprite, float2> Centered(Sprite s, float2 location)
|
protected static Pair<Sprite, float2> Centered(Sprite s, float2 location)
|
||||||
|
|||||||
@@ -327,6 +327,11 @@
|
|||||||
<sequence name="idle" start="0" length="32"/>
|
<sequence name="idle" start="0" length="32"/>
|
||||||
<sequence name="turret" start="32" length="8"/>
|
<sequence name="turret" start="32" length="8"/>
|
||||||
</unit>
|
</unit>
|
||||||
|
|
||||||
|
<!-- submarine -->
|
||||||
|
<unit name="ss">
|
||||||
|
<sequence name="idle" start="0" length="16" />
|
||||||
|
</unit>
|
||||||
|
|
||||||
<!-- build clock - hacked in -->
|
<!-- build clock - hacked in -->
|
||||||
<unit name="clock">
|
<unit name="clock">
|
||||||
|
|||||||
28
units.ini
28
units.ini
@@ -16,42 +16,55 @@ MNLY
|
|||||||
[V2RL]
|
[V2RL]
|
||||||
Description=V2 Rocket
|
Description=V2 Rocket
|
||||||
Traits=Mobile, RenderUnit
|
Traits=Mobile, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
[1TNK]
|
[1TNK]
|
||||||
Description=Light Tank
|
Description=Light Tank
|
||||||
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||||
|
BuiltAt=weap
|
||||||
[2TNK]
|
[2TNK]
|
||||||
Description=Medium Tank
|
Description=Medium Tank
|
||||||
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||||
|
BuiltAt=weap
|
||||||
[3TNK]
|
[3TNK]
|
||||||
Description=Heavy Tank
|
Description=Heavy Tank
|
||||||
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||||
|
BuiltAt=weap
|
||||||
[4TNK]
|
[4TNK]
|
||||||
Description=Mammoth Tank
|
Description=Mammoth Tank
|
||||||
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||||
|
BuiltAt=weap
|
||||||
[MRJ]
|
[MRJ]
|
||||||
Description=Radar Jammer
|
Description=Radar Jammer
|
||||||
Traits=Mobile, Turreted, RenderUnitTurreted ; temporary. It's not a turret, it's a spinney-thing
|
Traits=Mobile, Turreted, RenderUnitTurreted ; temporary. It's not a turret, it's a spinney-thing
|
||||||
|
BuiltAt=weap
|
||||||
[MGG]
|
[MGG]
|
||||||
Description=Mobile Gap Generator
|
Description=Mobile Gap Generator
|
||||||
Traits=Mobile, Turreted, RenderUnitTurreted ; temporary. It's not a turret, it's a spinney-thing
|
Traits=Mobile, Turreted, RenderUnitTurreted ; temporary. It's not a turret, it's a spinney-thing
|
||||||
|
BuiltAt=weap
|
||||||
[ARTY]
|
[ARTY]
|
||||||
Description=Artillery
|
Description=Artillery
|
||||||
Traits=Mobile, RenderUnit
|
Traits=Mobile, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
[HARV]
|
[HARV]
|
||||||
Description=Ore Truck
|
Description=Ore Truck
|
||||||
Traits=Mobile, RenderUnit
|
Traits=Mobile, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
[MCV]
|
[MCV]
|
||||||
Description=Mobile Construction Vehicle
|
Description=Mobile Construction Vehicle
|
||||||
Traits=Mobile, McvDeploy, RenderUnit
|
Traits=Mobile, McvDeploy, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
[JEEP]
|
[JEEP]
|
||||||
Description=Ranger
|
Description=Ranger
|
||||||
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||||
|
BuiltAt=weap
|
||||||
[APC]
|
[APC]
|
||||||
Description=Armored Personnel Carrier
|
Description=Armored Personnel Carrier
|
||||||
Traits=Mobile, RenderUnit
|
Traits=Mobile, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
[MNLY]
|
[MNLY]
|
||||||
Description=Minelayer
|
Description=Minelayer
|
||||||
Traits=Mobile, RenderUnit
|
Traits=Mobile, RenderUnit
|
||||||
|
BuiltAt=weap
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -66,14 +79,29 @@ PT
|
|||||||
|
|
||||||
[SS]
|
[SS]
|
||||||
Description=Submarine
|
Description=Submarine
|
||||||
|
WaterBound=yes
|
||||||
|
BuiltAt=spen
|
||||||
|
Traits=Mobile, RenderUnit
|
||||||
[DD]
|
[DD]
|
||||||
Description=Destroyer
|
Description=Destroyer
|
||||||
|
WaterBound=yes
|
||||||
|
BuiltAt=syrd
|
||||||
|
Traits=Mobile, RenderUnit
|
||||||
[CA]
|
[CA]
|
||||||
Description=Cruiser
|
Description=Cruiser
|
||||||
|
WaterBound=yes
|
||||||
|
BuiltAt=syrd
|
||||||
|
Traits=Mobile, RenderUnit
|
||||||
[LST]
|
[LST]
|
||||||
Description=Transport
|
Description=Transport
|
||||||
|
WaterBound=yes
|
||||||
|
BuiltAt=syrd,spen
|
||||||
|
Traits=Mobile, RenderUnit
|
||||||
[PT]
|
[PT]
|
||||||
Description=Gunboat
|
Description=Gunboat
|
||||||
|
WaterBound=yes
|
||||||
|
BuiltAt=syrd
|
||||||
|
Traits=Mobile, RenderUnit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user