Create a mod dll for cnc

This commit is contained in:
Paul Chote
2010-02-05 19:40:39 +13:00
parent 9cdefee403
commit 1ea8e212c4
9 changed files with 12 additions and 112 deletions

View File

@@ -256,7 +256,6 @@
<Compile Include="Traits\StoresOre.cs" />
<Compile Include="Traits\Submarine.cs" />
<Compile Include="Traits\TakeCover.cs" />
<Compile Include="Traits\TiberiumRefinery.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Turreted.cs" />
<Compile Include="Traits\Unit.cs" />

View File

@@ -2,7 +2,7 @@
namespace OpenRa.Traits.Activities
{
class Harvest : IActivity
public class Harvest : IActivity
{
public IActivity NextActivity { get; set; }
bool isHarvesting = false;

View File

@@ -1,7 +1,7 @@

namespace OpenRa.Traits.Activities
{
class Turn : IActivity
public class Turn : IActivity
{
public IActivity NextActivity { get; set; }

View File

@@ -8,7 +8,7 @@ namespace OpenRa.Traits
public object Create(Actor self) { return new Harvester(); }
}
class Harvester : IIssueOrder, IResolveOrder, IPips
public class Harvester : IIssueOrder, IResolveOrder, IPips
{
[Sync]
public int oreCarried = 0; /* sum of these must not exceed capacity */

View File

@@ -1,42 +0,0 @@
using OpenRa.Traits.Activities;
namespace OpenRa.Traits
{
class TiberiumRefineryInfo : ITraitInfo
{
public object Create(Actor self) { return new TiberiumRefinery(self); }
}
class TiberiumRefinery : IAcceptOre
{
Actor self;
public TiberiumRefinery(Actor self)
{
this.self = self;
self.World.AddFrameEndTask(
w =>
{ /* create the free harvester! */
var harvester = w.CreateActor("harv", self.Location + new int2(0, 2), self.Owner);
var unit = harvester.traits.Get<Unit>();
var mobile = harvester.traits.Get<Mobile>();
unit.Facing = 64;
harvester.QueueActivity(new Harvest());
});
}
public int2 DeliverOffset { get { return new int2(0, 2); } }
public void OnDock(Actor harv, DeliverOre dockOrder)
{
// Todo: need to be careful about cancellation and multiple harvs
var unit = harv.traits.Get<Unit>();
harv.QueueActivity(new Move(self.Location + new int2(1,1), self));
harv.QueueActivity(new Turn(96));
harv.QueueActivity( new CallFunc( () =>
self.traits.Get<RenderBuilding>().PlayCustomAnimThen(self, "active", () => {
harv.traits.Get<Harvester>().Deliver(harv, self);
harv.QueueActivity(new Move(self.Location + DeliverOffset, self));
harv.QueueActivity(new Harvest());
})));
}
}
}

View File

@@ -51,7 +51,6 @@
<Compile Include="Activities\Infiltrate.cs" />
<Compile Include="Activities\LayMine.cs" />
<Compile Include="Activities\Steal.cs" />
<Compile Include="ProductionAirdrop.cs" />
<Compile Include="C4Demolition.cs" />
<Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\GpsSatellite.cs" />

View File

@@ -1,63 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using OpenRa.GameRules;
using OpenRa.Traits.Activities;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
public class ProductionAirdropInfo : ProductionInfo
{
public override object Create(Actor self) { return new ProductionAirdrop(self); }
}
class ProductionAirdrop : Production
{
public ProductionAirdrop(Actor self) : base(self) { }
public override bool Produce( Actor self, ActorInfo producee )
{
var location = CreationLocation(self, producee);
var owner = self.Owner;
// Start at the edge of the map, to the right of the airfield
var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width, self.Location.Y);
var endPos = new int2(owner.World.Map.XOffset, self.Location.Y);
var unloadOffset = new int2(1,1);
var exitOffset = new int2(3,1);
var rp = self.traits.GetOrDefault<RallyPoint>();
owner.World.AddFrameEndTask(w =>
{
var a = w.CreateActor("C17", startPos, owner);
var cargo = a.traits.Get<Cargo>();
var newUnit = new Actor(self.World, producee.Name, new int2(0, 0), self.Owner);
cargo.Load(a, newUnit);
a.CancelActivity();
a.QueueActivity(new Land(self.CenterLocation));
a.QueueActivity(new CallFunc(() =>
{
var actor = cargo.Unload(self);
self.World.AddFrameEndTask(ww =>
{
ww.Add(actor);
actor.traits.Get<Mobile>().TeleportTo(actor, self.Location + unloadOffset);
newUnit.traits.Get<Unit>().Facing = 192;
actor.CancelActivity();
actor.QueueActivity(new Move(self.Location + exitOffset, self));
actor.QueueActivity(new Move(rp.rallyPoint, 0));
foreach (var t in self.traits.WithInterface<INotifyProduction>())
t.UnitProduced(self, actor);
});
}));
a.QueueActivity(new Fly(endPos));
a.QueueActivity(new RemoveSelf());
});
return true;
}
}
}

View File

@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.RA", "OpenRa.Mo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.Aftermath", "OpenRa.Mods.Aftermath\OpenRa.Mods.Aftermath.csproj", "{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.Cnc", "OpenRa.Mods.Cnc\OpenRa.Mods.Cnc.csproj", "{2881135D-4D62-493E-8F83-5EEE92CCC6BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -61,6 +63,10 @@ Global
{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}.Release|Any CPU.Build.0 = Release|Any CPU
{2881135D-4D62-493E-8F83-5EEE92CCC6BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2881135D-4D62-493E-8F83-5EEE92CCC6BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2881135D-4D62-493E-8F83-5EEE92CCC6BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2881135D-4D62-493E-8F83-5EEE92CCC6BE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -8,7 +8,7 @@ Packages:
mods/cnc/packages/cclocal.mix
mods/cnc/packages/speech.mix
mods/cnc/packages/conquer.mix
mods/cnc/packages/general.mix
# mods/cnc/packages/general.mix
mods/cnc/packages/sounds.mix
mods/cnc/packages/tempicnh.mix
~main.mix
@@ -47,7 +47,8 @@ Sequences:
mods/cnc/sequences.xml: Obsolete; will disappear once done converting
Assemblies:
mods/ra/OpenRa.Mods.RA.dll: Use the red alert traits
mods/cnc/OpenRa.Mods.Cnc.dll: Cnc mod traits
mods/ra/OpenRa.Mods.RA.dll: Red alert mod traits
Maps: