move render{building,buildingturreted,unit} into mods.ra; move all render traits into mods.ra.render

This commit is contained in:
Bob
2010-07-08 17:24:12 +12:00
parent 281d013c3b
commit fb6c44bce3
34 changed files with 71 additions and 60 deletions

View File

@@ -18,6 +18,7 @@
*/
#endregion
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;

View File

@@ -19,7 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;

View File

@@ -18,8 +18,10 @@
*/
#endregion
using OpenRA.Traits;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class Leap : IActivity

View File

@@ -19,6 +19,7 @@
#endregion
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities

View File

@@ -19,7 +19,7 @@
#endregion
using System;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities

View File

@@ -18,6 +18,7 @@
*/
#endregion
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities

View File

@@ -19,7 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;

View File

@@ -19,6 +19,7 @@
#endregion
using System;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -22,6 +22,7 @@ using System;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -82,7 +82,10 @@
<Compile Include="Hazardous.cs" />
<Compile Include="Player\ActorGroupProxy.cs" />
<Compile Include="Aircraft.cs" />
<Compile Include="RenderUnitTurreted.cs" />
<Compile Include="Render\RenderBuilding.cs" />
<Compile Include="Render\RenderBuildingTurreted.cs" />
<Compile Include="Render\RenderUnit.cs" />
<Compile Include="Render\RenderUnitTurreted.cs" />
<Compile Include="SupportPowers\AirstrikePower.cs" />
<Compile Include="AttackFrontal.cs" />
<Compile Include="AttackHeli.cs" />
@@ -150,22 +153,22 @@
<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="Render\RenderBuildingCharge.cs" />
<Compile Include="Render\RenderBuildingOre.cs" />
<Compile Include="Render\RenderBuildingWall.cs" />
<Compile Include="Render\RenderBuildingWarFactory.cs" />
<Compile Include="Render\RenderFlare.cs" />
<Compile Include="Render\RenderInfantry.cs" />
<Compile Include="Render\RenderUnitReload.cs" />
<Compile Include="Render\RenderUnitRotor.cs" />
<Compile Include="Render\RenderUnitSpinner.cs" />
<Compile Include="Repairable.cs" />
<Compile Include="RepairsUnits.cs" />
<Compile Include="RequiresPower.cs" />
<Compile Include="Mine.cs" />
<Compile Include="Minelayer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RenderSpy.cs" />
<Compile Include="Render\RenderSpy.cs" />
<Compile Include="RepairableNear.cs" />
<Compile Include="Crates\SpeedUpgradeCrateAction.cs" />
<Compile Include="Reservable.cs" />

View File

@@ -18,8 +18,9 @@
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA

View File

@@ -0,0 +1,100 @@
#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 OpenRA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
public class RenderBuildingInfo : RenderSimpleInfo
{
public readonly bool HasMakeAnimation = true;
public override object Create(ActorInitializer init) { return new RenderBuilding(init.self);}
}
public class RenderBuilding : RenderSimple, INotifyDamage, INotifySold
{
public RenderBuilding( Actor self )
: this( self, () => 0 )
{
}
public RenderBuilding(Actor self, Func<int> baseFacing)
: base(self, baseFacing)
{
if( Game.skipMakeAnims || !self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation )
anim.PlayThen( "idle", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
else
anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
}
void Complete( Actor self )
{
anim.PlayRepeating( GetPrefix(self) + "idle" );
foreach( var x in self.traits.WithInterface<INotifyBuildComplete>() )
x.BuildingComplete( self );
}
public void PlayCustomAnimThen(Actor self, string name, Action a)
{
anim.PlayThen(GetPrefix(self) + name,
() => { anim.PlayRepeating(GetPrefix(self) + "idle"); a(); });
}
public void PlayCustomAnimBackwards(Actor self, string name, Action a)
{
var hasSequence = anim.HasSequence(GetPrefix(self) + name);
anim.PlayBackwardsThen(hasSequence ? GetPrefix(self) + name : name,
() => { anim.PlayRepeating(GetPrefix(self) + "idle"); a(); });
}
public virtual void Damaged(Actor self, AttackInfo e)
{
if (!e.DamageStateChanged)
return;
switch( e.DamageState )
{
case DamageState.Normal:
anim.ReplaceAnim("idle");
break;
case DamageState.Half:
anim.ReplaceAnim("damaged-idle");
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
break;
case DamageState.Dead:
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.CenterLocation.ToInt2(), "building", false)));
break;
}
}
public void Selling( Actor self )
{
if( !Game.skipMakeAnims && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation )
anim.PlayBackwardsThen( "make", null );
foreach (var s in self.Info.Traits.Get<BuildingInfo>().SellSounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
}
public void Sold(Actor self) {}
}
}

View File

@@ -18,9 +18,7 @@
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingChargeInfo : RenderBuildingInfo
{

View File

@@ -20,7 +20,7 @@
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingOreInfo : RenderBuildingInfo
{

View 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 OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingTurretedInfo : RenderBuildingInfo
{
public override object Create(ActorInitializer init) { return new RenderBuildingTurreted(init.self); }
}
class RenderBuildingTurreted : RenderBuilding, INotifyBuildComplete
{
public RenderBuildingTurreted(Actor self)
: base(self, () => self.traits.Get<Turreted>().turretFacing)
{
}
public void BuildingComplete( Actor self )
{
anim.Play( "idle" );
}
public override void Damaged(Actor self, AttackInfo e)
{
if (!e.DamageStateChanged) return;
switch (e.DamageState)
{
case DamageState.Normal:
anim.Play( "idle" );
break;
case DamageState.Half:
anim.Play( "damaged-idle" );
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
break;
}
}
}
}

View File

@@ -19,10 +19,9 @@
#endregion
using System.Linq;
using System;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingWallInfo : RenderBuildingInfo
{

View File

@@ -22,7 +22,7 @@ using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderWarFactoryInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
{

View File

@@ -20,7 +20,7 @@
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderFlareInfo : RenderSimpleInfo
{

View File

@@ -22,7 +22,7 @@ using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
public class RenderInfantryInfo : RenderSimpleInfo
{

View File

@@ -22,7 +22,7 @@ using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderSpyInfo : RenderInfantryInfo
{

View File

@@ -0,0 +1,61 @@
#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 OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
public class RenderUnitInfo : RenderSimpleInfo
{
public override object Create(ActorInitializer init) { return new RenderUnit(init.self); }
}
public class RenderUnit : RenderSimple, INotifyDamage
{
public RenderUnit(Actor self)
: base(self, () => self.traits.Get<Unit>().Facing)
{
anim.Play("idle");
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
}
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
{
anim.PlayThen(newAnim, () => { anim.Play("idle"); if (after != null) after(); });
}
bool isSmoking;
public void Damaged(Actor self, AttackInfo e)
{
if (e.DamageState != DamageState.Half) return;
if (isSmoking) return;
isSmoking = true;
var smoke = anims[ "smoke" ].Animation;
smoke.PlayThen( "idle",
() => smoke.PlayThen( "loop",
() => smoke.PlayBackwardsThen( "end",
() => isSmoking = false ) ) );
}
}
}

View File

@@ -21,7 +21,7 @@
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitReloadInfo : RenderUnitInfo
{

View File

@@ -21,7 +21,7 @@
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitRotorInfo : RenderUnitInfo
{

View File

@@ -21,7 +21,7 @@
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitSpinnerInfo : RenderUnitInfo
{

View File

@@ -21,7 +21,7 @@
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitTurretedInfo : RenderUnitInfo
{

View File

@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -20,6 +20,7 @@
using System.Linq;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Render;
using OpenRA.Orders;
using OpenRA.Traits;

View File

@@ -19,6 +19,7 @@
#endregion
using OpenRA.Graphics;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA