moved most render bits to ra
This commit is contained in:
58
OpenRA.Mods.RA/Activities/Rearm.cs
Normal file
58
OpenRA.Mods.RA/Activities/Rearm.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Rearm : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool isCanceled;
|
||||
int remainingTicks = ticksPerPip;
|
||||
|
||||
const int ticksPerPip = 25 * 2;
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
if (limitedAmmo == null) return NextActivity;
|
||||
|
||||
if (--remainingTicks == 0)
|
||||
{
|
||||
if (!limitedAmmo.GiveAmmo()) return NextActivity;
|
||||
|
||||
var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
||||
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
|
||||
|
||||
if (hostBuilding != null)
|
||||
hostBuilding.traits.Get<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
|
||||
|
||||
remainingTicks = ticksPerPip;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
71
OpenRA.Mods.RA/Activities/Repair.cs
Normal file
71
OpenRA.Mods.RA/Activities/Repair.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Repair : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool isCanceled;
|
||||
int remainingTicks;
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
if (remainingTicks == 0)
|
||||
{
|
||||
var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
||||
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
|
||||
|
||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
|
||||
var costPerHp = (hostBuilding.Info.Traits.Get<RepairsUnitsInfo>().URepairPercent * unitCost) / hp;
|
||||
var hpToRepair = Math.Min(hostBuilding.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, hp - self.Health);
|
||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||
if (!self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeCash(cost))
|
||||
{
|
||||
remainingTicks = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
self.InflictDamage(self, -hpToRepair, null);
|
||||
if (self.Health == hp)
|
||||
return NextActivity;
|
||||
|
||||
if (hostBuilding != null)
|
||||
hostBuilding.traits.Get<RenderBuilding>()
|
||||
.PlayCustomAnim(hostBuilding, "active");
|
||||
|
||||
remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25);
|
||||
}
|
||||
else
|
||||
--remainingTicks;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,8 @@
|
||||
<Compile Include="Activities\Land.cs" />
|
||||
<Compile Include="Activities\LayMine.cs" />
|
||||
<Compile Include="Activities\Leap.cs" />
|
||||
<Compile Include="Activities\Rearm.cs" />
|
||||
<Compile Include="Activities\Repair.cs" />
|
||||
<Compile Include="Activities\ReturnToBase.cs" />
|
||||
<Compile Include="Activities\Steal.cs" />
|
||||
<Compile Include="Activities\Teleport.cs" />
|
||||
@@ -123,8 +125,17 @@
|
||||
<Compile Include="Passenger.cs" />
|
||||
<Compile Include="Plane.cs" />
|
||||
<Compile Include="ProductionSurround.cs" />
|
||||
<Compile Include="RenderBuildingCharge.cs" />
|
||||
<Compile Include="RenderBuildingOre.cs" />
|
||||
<Compile Include="RenderBuildingWall.cs" />
|
||||
<Compile Include="RenderBuildingWarFactory.cs" />
|
||||
<Compile Include="RenderFlare.cs" />
|
||||
<Compile Include="RenderInfantry.cs" />
|
||||
<Compile Include="RenderUnitReload.cs" />
|
||||
<Compile Include="RenderUnitRotor.cs" />
|
||||
<Compile Include="RenderUnitSpinner.cs" />
|
||||
<Compile Include="Repairable.cs" />
|
||||
<Compile Include="RepairsUnits.cs" />
|
||||
<Compile Include="RequiresPower.cs" />
|
||||
<Compile Include="Mine.cs" />
|
||||
<Compile Include="Minelayer.cs" />
|
||||
|
||||
46
OpenRA.Mods.RA/RenderBuildingCharge.cs
Normal file
46
OpenRA.Mods.RA/RenderBuildingCharge.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderBuildingChargeInfo : RenderBuildingInfo
|
||||
{
|
||||
public readonly string ChargeAudio = "tslachg2.aud";
|
||||
public override object Create(Actor self) { return new RenderBuildingCharge(self); }
|
||||
}
|
||||
|
||||
/* used for tesla */
|
||||
public class RenderBuildingCharge : RenderBuilding
|
||||
{
|
||||
public RenderBuildingCharge(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
}
|
||||
|
||||
public void PlayCharge(Actor self)
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<RenderBuildingChargeInfo>().ChargeAudio, self.CenterLocation);
|
||||
anim.PlayThen(GetPrefix(self) + "active",
|
||||
() => anim.PlayRepeating(GetPrefix(self) + "idle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
43
OpenRA.Mods.RA/RenderBuildingOre.cs
Normal file
43
OpenRA.Mods.RA/RenderBuildingOre.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderBuildingOreInfo : RenderBuildingInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new RenderBuildingOre(self); }
|
||||
}
|
||||
|
||||
class RenderBuildingOre : RenderBuilding, INotifyBuildComplete
|
||||
{
|
||||
public RenderBuildingOre(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
}
|
||||
|
||||
public void BuildingComplete( Actor self )
|
||||
{
|
||||
anim.PlayFetchIndex( "idle",
|
||||
() => (int)( 4.9 * self.Owner.PlayerActor.traits.Get<PlayerResources>().GetSiloFullness() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
128
OpenRA.Mods.RA/RenderBuildingWall.cs
Normal file
128
OpenRA.Mods.RA/RenderBuildingWall.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderBuildingWallInfo : RenderBuildingInfo
|
||||
{
|
||||
public readonly int DamageStates = 2;
|
||||
public override object Create(Actor self) { return new RenderBuildingWall(self); }
|
||||
}
|
||||
|
||||
class RenderBuildingWall : RenderBuilding
|
||||
{
|
||||
string seqName;
|
||||
int adjacentWalls = 0;
|
||||
|
||||
public RenderBuildingWall(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
seqName = "idle";
|
||||
anim.PlayFetchIndex(seqName, () => adjacentWalls);
|
||||
}
|
||||
|
||||
enum ExtendedDamageState { Normal, ThreeQuarter, Half, Quarter, Dead };
|
||||
|
||||
ExtendedDamageState GetExtendedState( Actor self, int damage )
|
||||
{
|
||||
var effectiveHealth = self.Health + damage;
|
||||
|
||||
if (effectiveHealth <= 0)
|
||||
return ExtendedDamageState.Dead;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionRed)
|
||||
return ExtendedDamageState.Quarter;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionYellow)
|
||||
return ExtendedDamageState.Half;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * 0.75)
|
||||
return ExtendedDamageState.ThreeQuarter;
|
||||
|
||||
return ExtendedDamageState.Normal;
|
||||
}
|
||||
|
||||
public override void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
var oldState = GetExtendedState(self, e.Damage);
|
||||
var newState = GetExtendedState(self, 0);
|
||||
|
||||
var numStates = self.Info.Traits.Get<RenderBuildingWallInfo>().DamageStates;
|
||||
|
||||
if (oldState == newState) return;
|
||||
|
||||
switch (newState)
|
||||
{
|
||||
case ExtendedDamageState.Normal:
|
||||
seqName = "idle";
|
||||
break;
|
||||
case ExtendedDamageState.ThreeQuarter:
|
||||
if (numStates >= 4)
|
||||
seqName = "minor-damaged-idle";
|
||||
break;
|
||||
case ExtendedDamageState.Half:
|
||||
seqName = "damaged-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
|
||||
break;
|
||||
case ExtendedDamageState.Quarter:
|
||||
if (numStates >= 3)
|
||||
{
|
||||
seqName = "critical-idle";
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
anim.PlayFetchIndex(seqName, () => adjacentWalls);
|
||||
}
|
||||
|
||||
bool hasTicked = false;
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
if (!hasTicked)
|
||||
{
|
||||
var oneCell = new float2(Game.CellSize, Game.CellSize);
|
||||
var adjWalls = self.World.FindUnits(self.CenterLocation - oneCell, self.CenterLocation + oneCell)
|
||||
.Where(a => a.Info == self.Info && a != self);
|
||||
|
||||
foreach (var w in adjWalls)
|
||||
{
|
||||
w.traits.Get<RenderBuildingWall>().AddAdjacentWall(w, self);
|
||||
AddAdjacentWall(self, w);
|
||||
}
|
||||
hasTicked = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AddAdjacentWall(Actor self, Actor other)
|
||||
{
|
||||
if (other.Location == self.Location + new int2(0, -1)) adjacentWalls |= 1;
|
||||
if (other.Location == self.Location + new int2(+1, 0)) adjacentWalls |= 2;
|
||||
if (other.Location == self.Location + new int2(0, +1)) adjacentWalls |= 4;
|
||||
if (other.Location == self.Location + new int2(-1, 0)) adjacentWalls |= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
90
OpenRA.Mods.RA/RenderBuildingWarFactory.cs
Normal file
90
OpenRA.Mods.RA/RenderBuildingWarFactory.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderWarFactoryInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
|
||||
{
|
||||
public object Create(Actor self) { return new RenderWarFactory(self); }
|
||||
}
|
||||
|
||||
class RenderWarFactory : INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction, INotifySold
|
||||
{
|
||||
public Animation roof;
|
||||
[Sync]
|
||||
bool isOpen;
|
||||
|
||||
string GetPrefix(Actor self)
|
||||
{
|
||||
return self.GetDamageState() == DamageState.Half ? "damaged-" : "";
|
||||
}
|
||||
|
||||
public RenderWarFactory(Actor self)
|
||||
{
|
||||
roof = new Animation(self.traits.Get<RenderSimple>().GetImage(self));
|
||||
}
|
||||
|
||||
public void BuildingComplete( Actor self )
|
||||
{
|
||||
roof.Play( GetPrefix(self) + "idle-top" );
|
||||
self.traits.Get<RenderSimple>().anims.Add( "roof", new RenderSimple.AnimationWithOffset( roof ) { ZOffset = 2 } );
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (isOpen && !self.World.WorldActor.traits.Get<UnitInfluence>()
|
||||
.GetUnitsAt(((1f/Game.CellSize) * self.CenterLocation).ToInt2()).Any())
|
||||
{
|
||||
isOpen = false;
|
||||
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.DamageStateChanged) return;
|
||||
switch (e.DamageState)
|
||||
{
|
||||
case DamageState.Normal:
|
||||
roof.ReplaceAnim(roof.CurrentSequence.Name.Replace("damaged-",""));
|
||||
break;
|
||||
case DamageState.Half:
|
||||
roof.ReplaceAnim("damaged-" + roof.CurrentSequence.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UnitProduced(Actor self, Actor other)
|
||||
{
|
||||
roof.PlayThen(GetPrefix(self) + "build-top", () => isOpen = true);
|
||||
}
|
||||
|
||||
public void Selling( Actor self )
|
||||
{
|
||||
self.traits.Get<RenderSimple>().anims.Remove( "roof" );
|
||||
}
|
||||
|
||||
public void Sold( Actor self ) { }
|
||||
}
|
||||
}
|
||||
48
OpenRA.Mods.RA/RenderUnitReload.cs
Normal file
48
OpenRA.Mods.RA/RenderUnitReload.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderUnitReloadInfo : RenderUnitInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new RenderUnitReload(self); }
|
||||
}
|
||||
|
||||
class RenderUnitReload : RenderUnit
|
||||
{
|
||||
public RenderUnitReload(Actor self)
|
||||
: base(self) { }
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
var isAttacking = self.GetCurrentActivity() is Attack;
|
||||
|
||||
var attack = self.traits.GetOrDefault<AttackBase>();
|
||||
|
||||
if (attack != null)
|
||||
anim.ReplaceAnim((attack.IsReloading() ? "empty-" : "")
|
||||
+ (isAttacking ? "aim" : "idle"));
|
||||
base.Tick(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
77
OpenRA.Mods.RA/RenderUnitRotor.cs
Normal file
77
OpenRA.Mods.RA/RenderUnitRotor.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderUnitRotorInfo : RenderUnitInfo
|
||||
{
|
||||
public readonly int[] PrimaryOffset = { 0, 0 };
|
||||
public readonly int[] SecondaryOffset = null;
|
||||
|
||||
public override object Create(Actor self) { return new RenderUnitRotor(self); }
|
||||
}
|
||||
|
||||
class RenderUnitRotor : RenderUnit
|
||||
{
|
||||
public Animation rotorAnim, secondRotorAnim;
|
||||
|
||||
public RenderUnitRotor( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var info = self.Info.Traits.Get<RenderUnitRotorInfo>();
|
||||
|
||||
rotorAnim = new Animation(GetImage(self));
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
anims.Add( "rotor_1", new AnimationWithOffset(
|
||||
rotorAnim,
|
||||
() => Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
|
||||
null ) { ZOffset = 1 } );
|
||||
|
||||
if (info.SecondaryOffset == null) return;
|
||||
|
||||
secondRotorAnim = new Animation(GetImage(self));
|
||||
secondRotorAnim.PlayRepeating( "rotor2" );
|
||||
anims.Add( "rotor_2", new AnimationWithOffset(
|
||||
secondRotorAnim,
|
||||
() => Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
|
||||
null) { ZOffset = 1 });
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
var isFlying = unit.Altitude > 0;
|
||||
|
||||
if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor"))
|
||||
return;
|
||||
|
||||
rotorAnim.ReplaceAnim(isFlying ? "rotor" : "slow-rotor");
|
||||
if (secondRotorAnim != null)
|
||||
secondRotorAnim.ReplaceAnim(isFlying ? "rotor2" : "slow-rotor2");
|
||||
}
|
||||
}
|
||||
}
|
||||
48
OpenRA.Mods.RA/RenderUnitSpinner.cs
Normal file
48
OpenRA.Mods.RA/RenderUnitSpinner.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderUnitSpinnerInfo : RenderUnitInfo
|
||||
{
|
||||
public readonly int[] Offset = { 0, 0 };
|
||||
public override object Create(Actor self) { return new RenderUnitSpinner(self); }
|
||||
}
|
||||
|
||||
class RenderUnitSpinner : RenderUnit
|
||||
{
|
||||
public RenderUnitSpinner( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();
|
||||
|
||||
var spinnerAnim = new Animation( GetImage(self) );
|
||||
spinnerAnim.PlayRepeating( "spinner" );
|
||||
anims.Add( "spinner", new AnimationWithOffset(
|
||||
spinnerAnim,
|
||||
() => Util.GetTurretPosition( self, unit, info.Offset, 0 ),
|
||||
null ) { ZOffset = 1 } );
|
||||
}
|
||||
}
|
||||
}
|
||||
62
OpenRA.Mods.RA/Repairable.cs
Normal file
62
OpenRA.Mods.RA/Repairable.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RepairableInfo : TraitInfo<Repairable> { public readonly string[] RepairBuildings = { "fix" }; }
|
||||
|
||||
class Repairable : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
if (underCursor == null) return null;
|
||||
|
||||
if (self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains(underCursor.Info.Name)
|
||||
&& underCursor.Owner == self.Owner)
|
||||
return new Order("Enter", self, underCursor);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
|
||||
if (order.OrderString == "Enter")
|
||||
{
|
||||
var rp = order.TargetActor.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(((1 / 24f) * order.TargetActor.CenterLocation).ToInt2(), order.TargetActor));
|
||||
self.QueueActivity(new Rearm());
|
||||
self.QueueActivity(new Repair());
|
||||
|
||||
if (rp != null)
|
||||
self.QueueActivity(new CallFunc(
|
||||
() => self.QueueActivity(new Move(rp.rallyPoint, order.TargetActor))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
|
||||
32
OpenRA.Mods.RA/RepairsUnits.cs
Normal file
32
OpenRA.Mods.RA/RepairsUnits.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class RepairsUnitsInfo : TraitInfo<RepairsUnits>
|
||||
{
|
||||
public readonly float URepairPercent = 0.2f;
|
||||
public readonly int URepairStep = 10;
|
||||
}
|
||||
|
||||
public class RepairsUnits { }
|
||||
}
|
||||
Reference in New Issue
Block a user