Add mod project this time; Fix trees

This commit is contained in:
Paul Chote
2010-02-05 19:58:31 +13:00
parent 1ea8e212c4
commit e3e4f4a853
8 changed files with 300 additions and 77 deletions

View File

@@ -7,7 +7,7 @@ namespace OpenRa.Traits
public abstract class RenderSimpleInfo : ITraitInfo public abstract class RenderSimpleInfo : ITraitInfo
{ {
public readonly string Image = null; public readonly string Image = null;
public readonly string Palette = null;
public abstract object Create(Actor self); public abstract object Create(Actor self);
} }
@@ -28,9 +28,10 @@ namespace OpenRa.Traits
public virtual IEnumerable<Renderable> Render( Actor self ) public virtual IEnumerable<Renderable> Render( Actor self )
{ {
var palette = self.Info.Traits.Get<RenderSimpleInfo>().Palette;
foreach( var a in anims.Values ) foreach( var a in anims.Values )
if( a.DisableFunc == null || !a.DisableFunc() ) 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) public virtual void Tick(Actor self)

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2881135D-4D62-493E-8F83-5EEE92CCC6BE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenRa.Mods.Cnc</RootNamespace>
<AssemblyName>OpenRa.Mods.Cnc</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProductionAirdrop.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TiberiumRefinery.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRa.FileFormats\OpenRa.FileFormats.csproj">
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
<Name>OpenRa.FileFormats</Name>
</ProjectReference>
<ProjectReference Include="..\OpenRa.Game\OpenRa.Game.csproj">
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
<Name>OpenRa.Game</Name>
</ProjectReference>
<ProjectReference Include="..\OpenRa.Mods.RA\OpenRa.Mods.RA.csproj">
<Project>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</Project>
<Name>OpenRa.Mods.RA</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)mods/cnc/"
copy "$(TargetPath)" "$(SolutionDir)mods/cnc/"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -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<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

@@ -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")]

View File

@@ -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<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());
})));
}
}
}

54
mods/cnc/defaults.yaml Normal file
View File

@@ -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

View File

@@ -31,7 +31,7 @@ LegacyRules:
mods/cnc/weapons.ini: Weapons are still in the old format mods/cnc/weapons.ini: Weapons are still in the old format
mods/cnc/voices.ini: Voices are still in the old format mods/cnc/voices.ini: Voices are still in the old format
Rules: Rules:
mods/ra/defaults.yaml: Basic stuff mods/cnc/defaults.yaml: Basic stuff
mods/cnc/system.yaml: Player and world actors mods/cnc/system.yaml: Player and world actors
mods/cnc/structures.yaml: mods/cnc/structures.yaml:
mods/cnc/infantry.yaml: mods/cnc/infantry.yaml:

View File

@@ -1,140 +1,87 @@
T01: T01:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T02: T02:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T03: T03:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T05: T05:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T06: T06:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T07: T07:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T08: T08:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: x_ Footprint: x_
Dimensions: 2,1 Dimensions: 2,1
-Selectable:
T10: T10:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: __ xx Footprint: __ xx
Dimensions: 2,2
-Selectable:
T11: T11:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: __ xx Footprint: __ xx
Dimensions: 2,2
-Selectable:
T12: T12:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T13: T13:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T14: T14:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: ___ xx_ Footprint: ___ xx_
Dimensions: 3,2 Dimensions: 3,2
-Selectable:
T15: T15:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: ___ xx_ Footprint: ___ xx_
Dimensions: 3,2 Dimensions: 3,2
-Selectable:
T16: T16:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
T17: T17:
Inherits: ^Building Inherits: ^Tree
Building:
Footprint: __ x_
Dimensions: 2,2
-Selectable:
TC01: TC01:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: ___ xx_ Footprint: ___ xx_
Dimensions: 3,2 Dimensions: 3,2
-Selectable:
TC02: TC02:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: _x_ xx_ Footprint: _x_ xx_
Dimensions: 3,2 Dimensions: 3,2
-Selectable:
TC03: TC03:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: xx_ xx_ Footprint: xx_ xx_
Dimensions: 3,2 Dimensions: 3,2
-Selectable:
TC04: TC04:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: ____ xxx_ x___ Footprint: ____ xxx_ x___
Dimensions: 4,3 Dimensions: 4,3
-Selectable:
TC05: TC05:
Inherits: ^Building Inherits: ^Tree
Building: Building:
Footprint: __x_ xxx_ _xx_ Footprint: __x_ xxx_ _xx_
Dimensions: 4,3 Dimensions: 4,3
-Selectable: