diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 9023b37db3..b0540fe8dc 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -7,7 +7,7 @@ namespace OpenRa.Traits public abstract class RenderSimpleInfo : ITraitInfo { public readonly string Image = null; - + public readonly string Palette = null; public abstract object Create(Actor self); } @@ -28,9 +28,10 @@ namespace OpenRa.Traits public virtual IEnumerable Render( Actor self ) { + var palette = self.Info.Traits.Get().Palette; foreach( var a in anims.Values ) if( a.DisableFunc == null || !a.DisableFunc() ) - yield return a.Image( self ); + yield return ( palette == null ) ? a.Image( self ) : a.Image( self ).WithPalette(palette); } public virtual void Tick(Actor self) diff --git a/OpenRa.Mods.Cnc/OpenRa.Mods.Cnc.csproj b/OpenRa.Mods.Cnc/OpenRa.Mods.Cnc.csproj new file mode 100644 index 0000000000..599897c06d --- /dev/null +++ b/OpenRa.Mods.Cnc/OpenRa.Mods.Cnc.csproj @@ -0,0 +1,78 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {2881135D-4D62-493E-8F83-5EEE92CCC6BE} + Library + Properties + OpenRa.Mods.Cnc + OpenRa.Mods.Cnc + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + {0DFB103F-2962-400F-8C6D-E2C28CCBA633} + OpenRa.Game + + + {4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E} + OpenRa.Mods.RA + + + + + + mkdir "$(SolutionDir)mods/cnc/" +copy "$(TargetPath)" "$(SolutionDir)mods/cnc/" + + \ No newline at end of file diff --git a/OpenRa.Mods.Cnc/ProductionAirdrop.cs b/OpenRa.Mods.Cnc/ProductionAirdrop.cs new file mode 100644 index 0000000000..aa1014ab25 --- /dev/null +++ b/OpenRa.Mods.Cnc/ProductionAirdrop.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Linq; +using OpenRa.GameRules; +using OpenRa.Traits.Activities; +using OpenRa.Traits; +using OpenRa.Mods.RA; + +namespace OpenRa.Mods.Cnc +{ + 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(); + owner.World.AddFrameEndTask(w => + { + var a = w.CreateActor("C17", startPos, owner); + var cargo = a.traits.Get(); + + 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().TeleportTo(actor, self.Location + unloadOffset); + newUnit.traits.Get().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()) + t.UnitProduced(self, actor); + }); + })); + a.QueueActivity(new Fly(endPos)); + a.QueueActivity(new RemoveSelf()); + }); + + return true; + } + } +} diff --git a/OpenRa.Mods.Cnc/Properties/AssemblyInfo.cs b/OpenRa.Mods.Cnc/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5fc80de33c --- /dev/null +++ b/OpenRa.Mods.Cnc/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenRa.Mods.Cnc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenRa.Mods.Cnc")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3b31edcf-34e4-4a58-8130-88b15b046d10")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenRa.Mods.Cnc/TiberiumRefinery.cs b/OpenRa.Mods.Cnc/TiberiumRefinery.cs new file mode 100644 index 0000000000..74ce14e119 --- /dev/null +++ b/OpenRa.Mods.Cnc/TiberiumRefinery.cs @@ -0,0 +1,43 @@ +using OpenRa.Traits; +using OpenRa.Traits.Activities; + +namespace OpenRa.Mods.Cnc +{ + 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(); + var mobile = harvester.traits.Get(); + 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(); + harv.QueueActivity(new Move(self.Location + new int2(1,1), self)); + harv.QueueActivity(new Turn(96)); + harv.QueueActivity( new CallFunc( () => + self.traits.Get().PlayCustomAnimThen(self, "active", () => { + harv.traits.Get().Deliver(harv, self); + harv.QueueActivity(new Move(self.Location + DeliverOffset, self)); + harv.QueueActivity(new Harvest()); + }))); + } + } +} diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml new file mode 100644 index 0000000000..5949c781da --- /dev/null +++ b/mods/cnc/defaults.yaml @@ -0,0 +1,54 @@ +^Vehicle: + Category: Vehicle + Unit: + ROT: 5 + Mobile: + MovementType: Wheel + Selectable: + Voice: VehicleVoice + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +^Infantry: + Category: Infantry + Unit: + Armor: none + Sight: 4 + Mobile: + MovementType: Foot + Selectable: + RenderInfantry: + SquishByTank: + AutoTarget: + Passenger: + +^Ship: + Category: Ship + Unit: + Mobile: + MovementType: Float + Selectable: + +^Plane: + Category: Plane + Unit: + Selectable: + +^Building: + Category: Building + Selectable: + Priority: 3 + Building: + Dimensions: 1,1 + Footprint: x + RenderBuilding: + +^Tree: + Category: Building + RenderBuilding: + Palette: terrain + Building: + Footprint: __ x_ + Dimensions: 2,2 \ No newline at end of file diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index aaf2cf47bb..222a4700aa 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -31,7 +31,7 @@ LegacyRules: mods/cnc/weapons.ini: Weapons are still in the old format mods/cnc/voices.ini: Voices are still in the old format Rules: - mods/ra/defaults.yaml: Basic stuff + mods/cnc/defaults.yaml: Basic stuff mods/cnc/system.yaml: Player and world actors mods/cnc/structures.yaml: mods/cnc/infantry.yaml: diff --git a/mods/cnc/trees.yaml b/mods/cnc/trees.yaml index bb087645ec..3899166ed8 100644 --- a/mods/cnc/trees.yaml +++ b/mods/cnc/trees.yaml @@ -1,140 +1,87 @@ T01: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T02: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T03: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T05: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T06: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T07: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T08: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: x_ Dimensions: 2,1 - -Selectable: T10: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: __ xx - Dimensions: 2,2 - -Selectable: - T11: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: __ xx - Dimensions: 2,2 - -Selectable: - + T12: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T13: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T14: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: ___ xx_ Dimensions: 3,2 - -Selectable: T15: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: ___ xx_ Dimensions: 3,2 - -Selectable: T16: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree T17: - Inherits: ^Building - Building: - Footprint: __ x_ - Dimensions: 2,2 - -Selectable: + Inherits: ^Tree TC01: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: ___ xx_ Dimensions: 3,2 - -Selectable: TC02: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: _x_ xx_ Dimensions: 3,2 - -Selectable: TC03: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: xx_ xx_ Dimensions: 3,2 - -Selectable: TC04: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: ____ xxx_ x___ Dimensions: 4,3 - -Selectable: TC05: - Inherits: ^Building + Inherits: ^Tree Building: Footprint: __x_ xxx_ _xx_ Dimensions: 4,3 - -Selectable: