Unit on Build is Generic. (half way there)
This commit is contained in:
@@ -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">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -284,6 +284,7 @@
|
|||||||
<Compile Include="Chrome\LabelWidget.cs" />
|
<Compile Include="Chrome\LabelWidget.cs" />
|
||||||
<Compile Include="Chrome\DefaultWidgetDelegates.cs" />
|
<Compile Include="Chrome\DefaultWidgetDelegates.cs" />
|
||||||
<Compile Include="Chrome\CheckboxWidget.cs" />
|
<Compile Include="Chrome\CheckboxWidget.cs" />
|
||||||
|
<Compile Include="Traits\HasUnitOnBuild.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
35
OpenRA.Game/Traits/HasUnitOnBuild.cs
Normal file
35
OpenRA.Game/Traits/HasUnitOnBuild.cs
Normal 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() );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -33,15 +33,6 @@ namespace OpenRA.Traits
|
|||||||
public OreRefinery(Actor self)
|
public OreRefinery(Actor self)
|
||||||
{
|
{
|
||||||
this.self = 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 int2 DeliverOffset { get { return new int2(1, 2); } }
|
||||||
public void OnDock(Actor harv, DeliverOre dockOrder)
|
public void OnDock(Actor harv, DeliverOre dockOrder)
|
||||||
|
|||||||
@@ -1475,6 +1475,11 @@ PROC:
|
|||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
Value: 600
|
Value: 600
|
||||||
|
HasUnitOnBuild:
|
||||||
|
Unit: HARV
|
||||||
|
InitialActivity: Harvest
|
||||||
|
SpawnOffset: 1,2
|
||||||
|
Facing: 64
|
||||||
|
|
||||||
SILO:
|
SILO:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
Reference in New Issue
Block a user