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" />
|
||||
|
||||
@@ -1,55 +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.Activities
|
||||
{
|
||||
class UndeployMcv : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool started;
|
||||
|
||||
void DoUndeploy(World w,Actor self)
|
||||
{
|
||||
w.Remove(self);
|
||||
|
||||
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
||||
mcv.traits.Get<Unit>().Facing = 96;
|
||||
}
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
var rb = self.traits.Get<RenderBuilding>();
|
||||
rb.PlayCustomAnimBackwards(self, "make",
|
||||
() => self.World.AddFrameEndTask(w => DoUndeploy(w,self)));
|
||||
|
||||
foreach (var s in self.Info.Traits.Get<BuildingInfo>().SellSounds)
|
||||
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
||||
|
||||
started = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) {}
|
||||
}
|
||||
}
|
||||
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 { }
|
||||
}
|
||||
@@ -1,53 +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.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ConstructionYardInfo : TraitInfo<ConstructionYard> { }
|
||||
|
||||
public class ConstructionYard : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left) return null;
|
||||
|
||||
if (underCursor == self)
|
||||
return new Order("Deploy", self);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Deploy")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new UndeployMcv());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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.
|
||||
|
||||
Reference in New Issue
Block a user