Unit on Build is Generic. (half way there)

This commit is contained in:
alzeih
2010-03-18 18:31:11 +13:00
parent 93e4e8c1b8
commit 687b8547f5
4 changed files with 43 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -284,6 +284,7 @@
<Compile Include="Chrome\LabelWidget.cs" />
<Compile Include="Chrome\DefaultWidgetDelegates.cs" />
<Compile Include="Chrome\CheckboxWidget.cs" />
<Compile Include="Traits\HasUnitOnBuild.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -0,0 +1,35 @@
using System;
namespace OpenRA.Traits
{
class HasUnitOnBuildInfo : ITraitInfo
{
public readonly string Unit = null;
public readonly string InitialActivity = null;
public readonly int2 SpawnOffset = int2.Zero;
public readonly int Facing = 0;
public object Create( Actor self ) { return new HasUnitOnBuild(self); }
}
public class HasUnitOnBuild
{
public HasUnitOnBuild(Actor self)
{
var info = self.Info.Traits.Get<HasUnitOnBuildInfo>();
self.World.AddFrameEndTask(
w =>
{
var unit = w.CreateActor(info.Unit, self.Location
+ info.SpawnOffset, self.Owner);
var unitTrait = unit.traits.Get<Unit>();
unitTrait.Facing = info.Facing;
//unit.QueueActivity( new Harvest() );
});
}
}
}

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#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.
@@ -33,15 +33,6 @@ namespace OpenRA.Traits
public OreRefinery(Actor self)
{
this.self = self;
self.World.AddFrameEndTask(
w =>
{ /* create the free harvester! */
var harvester = w.CreateActor("harv", self.Location
+ new int2(1, 2), self.Owner);
var unit = harvester.traits.Get<Unit>();
unit.Facing = 64;
harvester.QueueActivity(new Harvest());
});
}
public int2 DeliverOffset { get { return new int2(1, 2); } }
public void OnDock(Actor harv, DeliverOre dockOrder)

View File

@@ -1475,6 +1475,11 @@ PROC:
IronCurtainable:
CustomSellValue:
Value: 600
HasUnitOnBuild:
Unit: HARV
InitialActivity: Harvest
SpawnOffset: 1,2
Facing: 64
SILO:
Inherits: ^Building