move CYard trait and UndeployMCV activity into mod
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\BaseBuilding.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
<Compile Include="Traits\LintAttributes.cs" />
|
||||
<Compile Include="Traits\Modifiers\FrozenUnderFog.cs" />
|
||||
@@ -184,7 +184,6 @@
|
||||
<Compile Include="Traits\Buildable.cs" />
|
||||
<Compile Include="Traits\Building.cs" />
|
||||
<Compile Include="Traits\World\BuildingInfluence.cs" />
|
||||
<Compile Include="Traits\ConstructionYard.cs" />
|
||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||
<Compile Include="Traits\Player\PlaceBuilding.cs" />
|
||||
<Compile Include="Traits\World\PlayerColorPalette.cs" />
|
||||
|
||||
11
OpenRA.Game/Traits/BaseBuilding.cs
Executable file
11
OpenRA.Game/Traits/BaseBuilding.cs
Executable file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
/* tag trait for "bases": mcv/fact */
|
||||
class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
|
||||
class BaseBuilding { }
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -63,16 +64,7 @@ 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);
|
||||
|
||||
var primaryFact = facts.Where(y => y.traits.Get<Production>().IsPrimary);
|
||||
var fact = (primaryFact.Count() > 0) ? primaryFact.FirstOrDefault() : facts.FirstOrDefault();
|
||||
|
||||
if (fact != null)
|
||||
fact.traits.Get<RenderBuilding>().PlayCustomAnim(fact, "build");
|
||||
PlayBuildAnim( self, unit );
|
||||
|
||||
queue.FinishProduction(unit.Category);
|
||||
|
||||
@@ -84,6 +76,20 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
|
||||
// finds a construction yard (or equivalent) and runs its "build" animation.
|
||||
static void PlayBuildAnim( Actor self, ActorInfo unit )
|
||||
{
|
||||
var producers = self.World.Queries.OwnedBy[ self.Owner ].WithTrait<Production>()
|
||||
.Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( unit.Category ) )
|
||||
.ToList();
|
||||
var producer = producers.Where( x => x.Trait.IsPrimary ).Concat( producers )
|
||||
.Select( x => x.Actor )
|
||||
.FirstOrDefault();
|
||||
|
||||
if( producer != null )
|
||||
producer.traits.Get<RenderBuilding>().PlayCustomAnim( producer, "build" );
|
||||
}
|
||||
|
||||
static int GetNumBuildables(Player p)
|
||||
{
|
||||
if (p != p.World.LocalPlayer) return 0; // this only matters for local players.
|
||||
|
||||
6
OpenRA.Game/Traits/Activities/UndeployMcv.cs → OpenRA.Mods.RA/Activities/UndeployMcv.cs
Normal file → Executable file
6
OpenRA.Game/Traits/Activities/UndeployMcv.cs → OpenRA.Mods.RA/Activities/UndeployMcv.cs
Normal file → Executable file
@@ -18,9 +18,11 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class UndeployMcv : IActivity
|
||||
public class UndeployMcv : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool started;
|
||||
@@ -46,9 +46,8 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
get
|
||||
{
|
||||
return !info.RequiresConstructionYard ||
|
||||
Game.world.Queries.OwnedBy[Game.world.LocalPlayer]
|
||||
.WithTrait<ConstructionYard>().Any();
|
||||
// WTF: why are these buttons even traits?
|
||||
return RepairOrderGenerator.PlayerIsAllowedToRepair( Game.world );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
OpenRA.Game/Traits/ConstructionYard.cs → OpenRA.Mods.RA/ConstructionYard.cs
Normal file → Executable file
10
OpenRA.Game/Traits/ConstructionYard.cs → OpenRA.Mods.RA/ConstructionYard.cs
Normal file → Executable file
@@ -18,9 +18,10 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ConstructionYardInfo : TraitInfo<ConstructionYard> { }
|
||||
|
||||
@@ -45,9 +46,4 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* tag trait for "bases": mcv/fact */
|
||||
|
||||
class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
|
||||
class BaseBuilding { }
|
||||
}
|
||||
@@ -67,8 +67,10 @@
|
||||
<Compile Include="Activities\Repair.cs" />
|
||||
<Compile Include="Activities\ReturnToBase.cs" />
|
||||
<Compile Include="Activities\Teleport.cs" />
|
||||
<Compile Include="Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Activities\UnloadCargo.cs" />
|
||||
<Compile Include="Activities\Wait.cs" />
|
||||
<Compile Include="ConstructionYard.cs" />
|
||||
<Compile Include="Player\ActorGroupProxy.cs" />
|
||||
<Compile Include="Aircraft.cs" />
|
||||
<Compile Include="SupportPowers\AirstrikePower.cs" />
|
||||
|
||||
@@ -52,14 +52,20 @@ namespace OpenRA.Mods.RA.Orders
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
var hasFact = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<ConstructionYard>()
|
||||
.Any();
|
||||
|
||||
if (!hasFact)
|
||||
if( PlayerIsAllowedToRepair( world ) )
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public static bool PlayerIsAllowedToRepair( World world )
|
||||
{
|
||||
if( !world.WorldActor.Info.Traits.Get<RepairButtonInfo>().RequiresConstructionYard )
|
||||
return true;
|
||||
|
||||
return Game.world.Queries.OwnedBy[ Game.world.LocalPlayer ]
|
||||
.WithTrait<Production>().Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( "Building" ) )
|
||||
.Any();
|
||||
}
|
||||
|
||||
public void Render( World world ) {}
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ActorGroupProxyInfo : TraitInfo<ActorGroupProxy> { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user