moved most render bits to ra
This commit is contained in:
@@ -81,12 +81,16 @@
|
||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
|
||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||
<Compile Include="Traits\Player\TechTreeCache.cs" />
|
||||
<Compile Include="Traits\Player\ConquestVictoryConditions.cs" />
|
||||
<Compile Include="Traits\Modifiers\HiddenUnderFog.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuilding.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitTurreted.cs" />
|
||||
<Compile Include="Traits\World\Shroud.cs" />
|
||||
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
|
||||
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />
|
||||
@@ -157,9 +161,7 @@
|
||||
<Compile Include="Graphics\LineRenderer.cs" />
|
||||
<Compile Include="Graphics\WorldRenderer.cs" />
|
||||
<Compile Include="Traits\Activities\Idle.cs" />
|
||||
<Compile Include="Traits\Activities\Rearm.cs" />
|
||||
<Compile Include="Traits\Activities\RemoveSelf.cs" />
|
||||
<Compile Include="Traits\Activities\Repair.cs" />
|
||||
<Compile Include="Traits\Activities\Sell.cs" />
|
||||
<Compile Include="Orders\IOrderGenerator.cs" />
|
||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||
@@ -185,7 +187,6 @@
|
||||
<Compile Include="Traits\Activities\Move.cs" />
|
||||
<Compile Include="Traits\Activities\Follow.cs" />
|
||||
<Compile Include="Traits\Activities\Turn.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\Attack\AttackBase.cs" />
|
||||
<Compile Include="Traits\Attack\AttackInfo.cs" />
|
||||
<Compile Include="Traits\Modifiers\BelowUnits.cs" />
|
||||
@@ -202,26 +203,16 @@
|
||||
<Compile Include="Traits\World\ResourceType.cs" />
|
||||
<Compile Include="Traits\SupportPower.cs" />
|
||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||
<Compile Include="Traits\Repairable.cs" />
|
||||
<Compile Include="Traits\Reservable.cs" />
|
||||
<Compile Include="Traits\Selectable.cs" />
|
||||
<Compile Include="Traits\Player\ProductionQueue.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
|
||||
<Compile Include="Traits\TransformsOnDeploy.cs" />
|
||||
<Compile Include="Traits\Mobile.cs" />
|
||||
<Compile Include="Traits\Production.cs" />
|
||||
<Compile Include="Traits\RallyPoint.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuilding.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingOre.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWarFactory.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnit.cs" />
|
||||
<Compile Include="Traits\Modifiers\WithMuzzleFlash.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitReload.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitRotor.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitSpinner.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitTurreted.cs" />
|
||||
<Compile Include="Traits\StoresOre.cs" />
|
||||
<Compile Include="Traits\Cloak.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
@@ -239,7 +230,6 @@
|
||||
<Compile Include="World.cs" />
|
||||
<Compile Include="WorldUtils.cs" />
|
||||
<Compile Include="Traits\Wall.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
<Compile Include="Traits\Player\EvaAlerts.cs" />
|
||||
<Compile Include="Traits\World\ScreenShaker.cs" />
|
||||
<Compile Include="Traits\LineBuild.cs" />
|
||||
@@ -252,7 +242,6 @@
|
||||
<Compile Include="Widgets\CheckboxWidget.cs" />
|
||||
<Compile Include="Traits\Activities\Wait.cs" />
|
||||
<Compile Include="Traits\World\GlobalDefaults.cs" />
|
||||
<Compile Include="Traits\RepairsUnits.cs" />
|
||||
<Compile Include="Traits\World\BibLayer.cs" />
|
||||
<Compile Include="Traits\World\SmudgeLayer.cs" />
|
||||
<Compile Include="Widgets\Delegates\IngameChromeDelegate.cs" />
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits.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; }
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits.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; }
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,9 @@ namespace OpenRA.Traits.Activities
|
||||
{
|
||||
if( !started )
|
||||
{
|
||||
framesRemaining = (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation) ? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
framesRemaining = self.traits.Get<RenderSimple>().anim.HasSequence("make")
|
||||
? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
|
||||
foreach( var ns in self.traits.WithInterface<INotifySold>() )
|
||||
ns.Selling( self );
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
class UndeployMcv : IActivity
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
@@ -52,4 +52,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ namespace OpenRA.Traits
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
|
||||
}
|
||||
|
||||
/* todo: reimpl this properly */
|
||||
|
||||
var facts = w.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<ConstructionYard>().Select(x => x.Actor);
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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 ) { }
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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 Activities.Attack;
|
||||
|
||||
var attack = self.traits.GetOrDefault<AttackBase>();
|
||||
|
||||
if (attack != null)
|
||||
anim.ReplaceAnim((attack.IsReloading() ? "empty-" : "")
|
||||
+ (isAttacking ? "aim" : "idle"));
|
||||
base.Tick(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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 } );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,4 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#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.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class RepairsUnitsInfo : TraitInfo<RepairsUnits>
|
||||
{
|
||||
public readonly float URepairPercent = 0.2f;
|
||||
public readonly int URepairStep = 10;
|
||||
}
|
||||
|
||||
public class RepairsUnits { }
|
||||
}
|
||||
@@ -21,8 +21,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user