renamed Actor.unitInfo to "Info"; other minor changes
This commit is contained in:
@@ -12,7 +12,7 @@ namespace OpenRa.Game
|
||||
class Actor
|
||||
{
|
||||
public readonly TypeDictionary traits = new TypeDictionary();
|
||||
public readonly UnitInfo unitInfo;
|
||||
public readonly UnitInfo Info;
|
||||
|
||||
public readonly uint ActorID;
|
||||
public int2 Location;
|
||||
@@ -20,18 +20,18 @@ namespace OpenRa.Game
|
||||
public int Health;
|
||||
IActivity currentActivity;
|
||||
|
||||
public Actor( string name, int2 location, Player owner )
|
||||
public Actor( ActorInfo info, int2 location, Player owner )
|
||||
{
|
||||
ActorID = Game.world.NextAID();
|
||||
unitInfo = Rules.UnitInfo[ name ];
|
||||
Info = (UnitInfo)info; // temporary
|
||||
Location = location;
|
||||
CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location;
|
||||
Owner = owner;
|
||||
Health = unitInfo.Strength; /* todo: handle cases where this is not true! */
|
||||
Health = Info.Strength; /* todo: handle cases where this is not true! */
|
||||
|
||||
if( unitInfo.Traits != null )
|
||||
if( Info.Traits != null )
|
||||
{
|
||||
foreach( var traitName in unitInfo.Traits )
|
||||
foreach( var traitName in Info.Traits )
|
||||
{
|
||||
var type = typeof( Traits.Mobile ).Assembly.GetType( typeof( Traits.Mobile ).Namespace + "." + traitName, true, false );
|
||||
var ctor = type.GetConstructor( new[] { typeof( Actor ) } );
|
||||
@@ -39,7 +39,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException( "No Actor traits for " + unitInfo.Name
|
||||
throw new InvalidOperationException( "No Actor traits for " + Info.Name
|
||||
+ "; add Traits= to units.ini for appropriate unit" );
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace OpenRa.Game
|
||||
|
||||
var underCursor = Game.UnitInfluence.GetUnitAt( xy )
|
||||
?? Game.BuildingInfluence.GetBuildingAt( xy );
|
||||
if (underCursor != null && !underCursor.unitInfo.Selectable)
|
||||
if (underCursor != null && !underCursor.Info.Selectable)
|
||||
underCursor = null;
|
||||
|
||||
return traits.WithInterface<Traits.IOrder>()
|
||||
@@ -117,7 +117,7 @@ namespace OpenRa.Game
|
||||
Sound.Play("kaboom22.aud");
|
||||
}
|
||||
|
||||
var halfStrength = unitInfo.Strength * Rules.General.ConditionYellow;
|
||||
var halfStrength = Info.Strength * Rules.General.ConditionYellow;
|
||||
if (Health < halfStrength && (Health + damage) >= halfStrength)
|
||||
{
|
||||
/* we just went below half health! */
|
||||
|
||||
@@ -138,13 +138,10 @@ namespace OpenRa.Game
|
||||
|
||||
float GetDamageToInflict(Actor target)
|
||||
{
|
||||
if( target.unitInfo == null ) // tree or other doodad
|
||||
return 0;
|
||||
|
||||
/* todo: some things can't be damaged AT ALL by certain weapons! */
|
||||
var distance = (target.CenterLocation - Dest).Length;
|
||||
var rawDamage = Weapon.Damage * (float)Math.Exp(-distance / Warhead.Spread);
|
||||
var multiplier = Warhead.EffectivenessAgainst(target.unitInfo.Armor);
|
||||
var multiplier = Warhead.EffectivenessAgainst(target.Info.Armor);
|
||||
|
||||
return rawDamage * multiplier;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRa.Game
|
||||
UnitInfluence = new UnitInfluenceMap();
|
||||
|
||||
foreach (TreeReference treeReference in Rules.Map.Trees)
|
||||
world.Add(new Actor(treeReference.Image,
|
||||
world.Add(new Actor(Rules.UnitInfo[treeReference.Image],
|
||||
new int2(treeReference.Location),
|
||||
null));
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRa.Game
|
||||
//num=owner,type,health,location,facing,trigger,unknown,shouldRepair
|
||||
var parts = s.Value.ToLowerInvariant().Split(',');
|
||||
var loc = int.Parse(parts[3]);
|
||||
world.Add(new Actor(parts[1], new int2(loc % 128, loc / 128), players[0]));
|
||||
world.Add(new Actor(Rules.UnitInfo[parts[1]], new int2(loc % 128, loc / 128), players[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ namespace OpenRa.Game
|
||||
foreach (var s in mapfile.GetSection("UNITS", true))
|
||||
{
|
||||
//num=owner,type,health,location,facing,action,trigger
|
||||
var parts = s.Value.Split(',');
|
||||
var parts = s.Value.ToLowerInvariant().Split( ',' );
|
||||
var loc = int.Parse(parts[3]);
|
||||
world.Add(new Actor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128),
|
||||
world.Add(new Actor(Rules.UnitInfo[parts[1]], new int2(loc % 128, loc / 128),
|
||||
players.Values.FirstOrDefault(p => p.PlayerName == parts[0])
|
||||
?? players[0]));
|
||||
}
|
||||
@@ -244,8 +244,8 @@ namespace OpenRa.Game
|
||||
public static IEnumerable<Actor> SelectActorsInBox(float2 a, float2 b)
|
||||
{
|
||||
return FindUnits(a, b)
|
||||
.Where( x => x.unitInfo.Selectable )
|
||||
.GroupBy(x => (x.Owner == LocalPlayer) ? x.unitInfo.SelectionPriority : 0)
|
||||
.Where( x => x.Info.Selectable )
|
||||
.GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.SelectionPriority : 0)
|
||||
.OrderByDescending(g => g.Key)
|
||||
.Select( g => g.AsEnumerable() )
|
||||
.DefaultIfEmpty( new Actor[] {} )
|
||||
@@ -315,7 +315,7 @@ namespace OpenRa.Game
|
||||
var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType );
|
||||
// TODO: choose producer based on "primary building"
|
||||
var producer = world.Actors
|
||||
.Where( x => producerTypes.Contains( x.unitInfo ) && x.Owner == player )
|
||||
.Where( x => producerTypes.Contains( x.Info ) && x.Owner == player )
|
||||
.FirstOrDefault();
|
||||
|
||||
if (producer == null)
|
||||
|
||||
11
OpenRa.Game/GameRules/ActorInfo.cs
Executable file
11
OpenRa.Game/GameRules/ActorInfo.cs
Executable file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.GameRules
|
||||
{
|
||||
public class ActorInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ namespace OpenRa.Game.GameRules
|
||||
public Cache<string, List<Actor>> GatherBuildings( Player player )
|
||||
{
|
||||
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
||||
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.unitInfo is BuildingInfo ) )
|
||||
ret[ b.unitInfo.Name ].Add( b );
|
||||
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is BuildingInfo ) )
|
||||
ret[ b.Info.Name ].Add( b );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace OpenRa.Game.GameRules
|
||||
concrete = 4,
|
||||
}
|
||||
|
||||
public class UnitInfo
|
||||
public class UnitInfo : ActorInfo
|
||||
{
|
||||
public readonly string Name;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRa.Game.Graphics
|
||||
lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
|
||||
lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c);
|
||||
|
||||
var healthAmount = (float)selectedUnit.Health / selectedUnit.unitInfo.Strength;
|
||||
var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Strength;
|
||||
var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red
|
||||
: (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow
|
||||
: Color.LimeGreen;
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Chat.cs" />
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
<Compile Include="GameRules\ActorInfo.cs" />
|
||||
<Compile Include="GameRules\GeneralInfo.cs" />
|
||||
<Compile Include="GameRules\TechTree.cs" />
|
||||
<Compile Include="GameRules\VoiceInfo.cs" />
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
if (voicedUnit == null) return;
|
||||
|
||||
var mi = voicedUnit.unitInfo as MobileInfo;
|
||||
var mi = voicedUnit.Info as MobileInfo;
|
||||
if (mi == null) return;
|
||||
|
||||
var vi = Rules.VoiceInfo[mi.Voice];
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits
|
||||
Game.world.AddFrameEndTask(
|
||||
w =>
|
||||
{ /* create the free harvester! */
|
||||
var harvester = new Actor("harv", self.Location + new int2(1, 2), self.Owner);
|
||||
var harvester = new Actor(Rules.UnitInfo["harv"], self.Location + new int2(1, 2), self.Owner);
|
||||
var unit = harvester.traits.Get<Unit>();
|
||||
var mobile = harvester.traits.Get<Mobile>();
|
||||
unit.Facing = 64;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
Game.world.Remove( self );
|
||||
Game.world.Add( new Actor( "fact", self.Location - new int2( 1, 1 ), self.Owner ) );
|
||||
Game.world.Add( new Actor( Rules.UnitInfo["fact"], self.Location - new int2( 1, 1 ), self.Owner ) );
|
||||
} );
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
var oldFraction = moveFraction;
|
||||
var oldTotal = moveFractionTotal;
|
||||
|
||||
moveFraction += ( self.unitInfo as MobileInfo ).Speed;
|
||||
moveFraction += ( self.Info as MobileInfo ).Speed;
|
||||
UpdateCenterLocation( self, mobile );
|
||||
if( moveFraction >= moveFractionTotal )
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
if( desiredFacing == unit.Facing )
|
||||
return NextActivity;
|
||||
|
||||
Util.TickFacing( ref unit.Facing, desiredFacing, self.unitInfo.ROT );
|
||||
Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.ROT );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,18 +39,18 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
if (self.unitInfo.Primary != null && CheckFire(self, unit, self.unitInfo.Primary, ref primaryFireDelay,
|
||||
self.unitInfo.PrimaryOffset))
|
||||
if (self.Info.Primary != null && CheckFire(self, unit, self.Info.Primary, ref primaryFireDelay,
|
||||
self.Info.PrimaryOffset))
|
||||
{
|
||||
secondaryFireDelay = Math.Max(4, secondaryFireDelay);
|
||||
primaryRecoil = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.unitInfo.Secondary != null && CheckFire(self, unit, self.unitInfo.Secondary, ref secondaryFireDelay,
|
||||
self.unitInfo.SecondaryOffset ?? self.unitInfo.PrimaryOffset))
|
||||
if (self.Info.Secondary != null && CheckFire(self, unit, self.Info.Secondary, ref secondaryFireDelay,
|
||||
self.Info.SecondaryOffset ?? self.Info.PrimaryOffset))
|
||||
{
|
||||
if (self.unitInfo.SecondaryOffset != null) secondaryRecoil = 1;
|
||||
if (self.Info.SecondaryOffset != null) secondaryRecoil = 1;
|
||||
else primaryRecoil = 1;
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||
var weapon = order.Subject.unitInfo.Primary ?? order.Subject.unitInfo.Secondary;
|
||||
var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary;
|
||||
|
||||
self.QueueActivity(new Traits.Activities.Attack(order.TargetActor,
|
||||
Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance)));
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||
var weapon = order.Subject.unitInfo.Primary ?? order.Subject.unitInfo.Secondary;
|
||||
var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary;
|
||||
|
||||
self.QueueActivity( new Traits.Activities.Follow( order.TargetActor,
|
||||
Math.Max( 0, (int)Rules.WeaponInfo[ weapon ].Range - RangeTolerance ) ) );
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public Building(Actor self)
|
||||
{
|
||||
unitInfo = (BuildingInfo)self.unitInfo;
|
||||
unitInfo = (BuildingInfo)self.Info;
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace OpenRa.Game.Traits
|
||||
var dist = Game.CellSize * (targetLocation + new float2(.5f,.5f)) - self.CenterLocation;
|
||||
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
||||
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||
self.unitInfo.ROT);
|
||||
self.Info.ROT);
|
||||
|
||||
// .6f going the wrong way; .8f going sideways, 1f going forward.
|
||||
var rawSpeed = .2f * (self.unitInfo as VehicleInfo).Speed;
|
||||
var rawSpeed = .2f * (self.Info as VehicleInfo).Speed;
|
||||
var angle = (unit.Facing - desiredFacing) / 128f * Math.PI;
|
||||
var scale = .4f + .6f * (float)Math.Cos(angle);
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public InfantrySquad(Actor self)
|
||||
{
|
||||
var ii = (InfantryInfo)self.unitInfo;
|
||||
var ii = (InfantryInfo)self.Info;
|
||||
for (int i = 0; i < ii.SquadSize; i++)
|
||||
elements.Add(new Soldier(self.unitInfo.Name,
|
||||
elements.Add(new Soldier(self.Info.Name,
|
||||
self.CenterLocation.ToInt2() + elementOffsets[ii.SquadSize][i]));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public UnitMovementType GetMovementType()
|
||||
{
|
||||
switch( Rules.UnitCategory[ self.unitInfo.Name ] )
|
||||
switch( Rules.UnitCategory[ self.Info.Name ] )
|
||||
{
|
||||
case "Infantry":
|
||||
return UnitMovementType.Foot;
|
||||
case "Vehicle":
|
||||
return ( self.unitInfo as VehicleInfo ).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
||||
return ( self.Info as VehicleInfo ).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
||||
case "Ship":
|
||||
return UnitMovementType.Float;
|
||||
case "Plane":
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public virtual int CreationFacing( Actor self, Actor newUnit )
|
||||
{
|
||||
return newUnit.unitInfo.InitialFacing;
|
||||
return newUnit.Info.InitialFacing;
|
||||
}
|
||||
|
||||
public bool Produce( Actor self, UnitInfo producee )
|
||||
@@ -22,7 +22,7 @@ namespace OpenRa.Game.Traits
|
||||
if( location == null || Game.UnitInfluence.GetUnitAt( location.Value ) != null )
|
||||
return false;
|
||||
|
||||
var newUnit = new Actor( producee.Name, location.Value, self.Owner );
|
||||
var newUnit = new Actor( producee, location.Value, self.Owner );
|
||||
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
|
||||
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
@@ -37,7 +37,7 @@ namespace OpenRa.Game.Traits
|
||||
heli.targetLocation = rp.rallyPoint; // TODO: make Activity.Move work for helis.
|
||||
}
|
||||
|
||||
var bi = self.unitInfo as BuildingInfo;
|
||||
var bi = self.Info as BuildingInfo;
|
||||
if (bi != null && bi.SpawnOffset != null)
|
||||
newUnit.CenterLocation = self.CenterLocation
|
||||
+ new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
this.self = self;
|
||||
|
||||
roof = new Animation(self.unitInfo.Image ?? self.unitInfo.Name);
|
||||
roof = new Animation(self.Info.Image ?? self.Info.Name);
|
||||
Make( () =>
|
||||
{
|
||||
doneBuilding = true;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public RenderSimple(Actor self)
|
||||
{
|
||||
anim = new Animation(self.unitInfo.Image ?? self.unitInfo.Name);
|
||||
anim = new Animation(self.Info.Image ?? self.Info.Name);
|
||||
}
|
||||
|
||||
public abstract IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self);
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace OpenRa.Game.Traits
|
||||
public RenderUnitMuzzleFlash(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
if (!self.unitInfo.MuzzleFlash) throw new InvalidOperationException("wtf??");
|
||||
if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??");
|
||||
|
||||
muzzleFlash = new Animation(self.unitInfo.Name);
|
||||
muzzleFlash = new Animation(self.Info.Name);
|
||||
muzzleFlash.PlayFetchIndex("muzzle",
|
||||
() =>
|
||||
{
|
||||
@@ -37,8 +37,8 @@ namespace OpenRa.Game.Traits
|
||||
if (attack.primaryRecoil > 0)
|
||||
return base.Render(self).Concat(new[] {Util.Centered(self,
|
||||
muzzleFlash.Image, self.CenterLocation + new float2(
|
||||
self.unitInfo.PrimaryOffset.ElementAtOrDefault(2),
|
||||
self.unitInfo.PrimaryOffset.ElementAtOrDefault(3)))});
|
||||
self.Info.PrimaryOffset.ElementAtOrDefault(2),
|
||||
self.Info.PrimaryOffset.ElementAtOrDefault(3)))});
|
||||
else
|
||||
return base.Render(self);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace OpenRa.Game.Traits
|
||||
public RenderUnitRotor( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
rotorAnim = new Animation(self.unitInfo.Name);
|
||||
rotorAnim = new Animation(self.Info.Name);
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
|
||||
if (self.unitInfo.SecondaryAnim != null)
|
||||
if (self.Info.SecondaryAnim != null)
|
||||
{
|
||||
secondRotorAnim = new Animation(self.unitInfo.Name);
|
||||
secondRotorAnim.PlayRepeating(self.unitInfo.SecondaryAnim);
|
||||
secondRotorAnim = new Animation(self.Info.Name);
|
||||
secondRotorAnim.PlayRepeating(self.Info.SecondaryAnim);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,20 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
yield return Util.CenteredShadow(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.CenteredShadow(self, rotorAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, 0));
|
||||
if (self.unitInfo.SecondaryOffset != null)
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0));
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.CenteredShadow(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.SecondaryOffset, 0));
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, 0));
|
||||
|
||||
var heli = self.traits.Get<Helicopter>();
|
||||
var p = self.CenterLocation - new float2( 0, heli.altitude );
|
||||
|
||||
yield return Util.Centered(self, anim.Image, p);
|
||||
yield return Util.Centered(self, rotorAnim.Image, p
|
||||
+ Util.GetTurretPosition( self, unit, self.unitInfo.PrimaryOffset, 0 ) );
|
||||
if (self.unitInfo.SecondaryOffset != null)
|
||||
+ Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ) );
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, p
|
||||
+ Util.GetTurretPosition( self, unit, self.unitInfo.SecondaryOffset, 0 ) );
|
||||
+ Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, 0 ) );
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace OpenRa.Game.Traits
|
||||
public RenderUnitSpinner( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
spinnerAnim = new Animation( self.unitInfo.Name );
|
||||
spinnerAnim = new Animation( self.Info.Name );
|
||||
spinnerAnim.PlayRepeating( "spinner" );
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.Centered( self, spinnerAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, 0));
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0));
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace OpenRa.Game.Traits
|
||||
: base(self)
|
||||
{
|
||||
self.traits.Get<Turreted>();
|
||||
turretAnim = new Animation(self.unitInfo.Name);
|
||||
turretAnim = new Animation(self.Info.Name);
|
||||
|
||||
if (self.unitInfo.MuzzleFlash)
|
||||
if (self.Info.MuzzleFlash)
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
muzzleFlash = new Animation(self.unitInfo.Name);
|
||||
muzzleFlash = new Animation(self.Info.Name);
|
||||
muzzleFlash.PlayFetchIndex("muzzle",
|
||||
() => (Util.QuantizeFacing(self.traits.Get<Turreted>().turretFacing,8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
|
||||
/* hack: recoil can be 1.0f, but don't overflow into next anim */
|
||||
@@ -35,14 +35,14 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.Centered(self, turretAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, attack.primaryRecoil));
|
||||
if (self.unitInfo.SecondaryOffset != null)
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil));
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.Centered(self, turretAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.SecondaryOffset, attack.secondaryRecoil));
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil));
|
||||
|
||||
if (muzzleFlash != null && attack.primaryRecoil > 0)
|
||||
yield return Util.Centered(self, muzzleFlash.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, attack.primaryRecoil));
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil));
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
|
||||
@@ -8,13 +8,13 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public Turreted(Actor self)
|
||||
{
|
||||
turretFacing = self.unitInfo.InitialFacing;
|
||||
turretFacing = self.Info.InitialFacing;
|
||||
}
|
||||
|
||||
public void Tick( Actor self )
|
||||
{
|
||||
var df = desiredFacing ?? ( self.traits.Contains<Unit>() ? self.traits.Get<Unit>().Facing : turretFacing );
|
||||
Util.TickFacing( ref turretFacing, df, self.unitInfo.ROT );
|
||||
Util.TickFacing( ref turretFacing, df, self.Info.ROT );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +73,14 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
static float2 GetRecoil(Actor self, float recoil)
|
||||
{
|
||||
if (self.unitInfo.Recoil == 0) return float2.Zero;
|
||||
if (self.Info.Recoil == 0) return float2.Zero;
|
||||
var rut = self.traits.WithInterface<RenderUnitTurreted>().FirstOrDefault();
|
||||
if (rut == null) return float2.Zero;
|
||||
|
||||
var facing = self.traits.Get<Turreted>().turretFacing;
|
||||
var quantizedFacing = QuantizeFacing(facing, rut.turretAnim.CurrentSequence.Length) * (256 / rut.turretAnim.CurrentSequence.Length);
|
||||
|
||||
return RotateVectorByFacing(new float2(0, recoil * self.unitInfo.Recoil), quantizedFacing, .7f);
|
||||
return RotateVectorByFacing(new float2(0, recoil * self.Info.Recoil), quantizedFacing, .7f);
|
||||
}
|
||||
|
||||
public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRa.Game
|
||||
|
||||
Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name );
|
||||
|
||||
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
|
||||
Game.world.Add( new Actor( building, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
|
||||
if (order.Player == Game.LocalPlayer)
|
||||
{
|
||||
Sound.Play("placbldg.aud");
|
||||
|
||||
Reference in New Issue
Block a user