Merge pull request #5797 from Mailaender/ts-harvester
Fixed the Tiberian Sun harvester
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -89,10 +89,12 @@ namespace OpenRA.Graphics
|
||||
static readonly float[] groundNormal = new float[] {0,0,1,1};
|
||||
public void BeforeRender(WorldRenderer wr)
|
||||
{
|
||||
var draw = voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
|
||||
|
||||
renderProxy = Game.Renderer.WorldVoxelRenderer.RenderAsync(
|
||||
wr, voxels, camera, scale, groundNormal, lightSource,
|
||||
wr, draw, camera, scale, groundNormal, lightSource,
|
||||
lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
palette, normalsPalette, shadowPalette);
|
||||
}
|
||||
|
||||
public void Render(WorldRenderer wr)
|
||||
|
||||
77
OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs
Normal file
77
OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS
|
||||
{
|
||||
public class VoxelHarvesterDockSequence : Activity
|
||||
{
|
||||
enum State { Turn, Dock, Loop, Undock }
|
||||
|
||||
readonly Actor proc;
|
||||
readonly Harvester harv;
|
||||
readonly WithVoxelUnloadBody body;
|
||||
State state;
|
||||
|
||||
public VoxelHarvesterDockSequence(Actor self, Actor proc)
|
||||
{
|
||||
this.proc = proc;
|
||||
state = State.Turn;
|
||||
harv = self.Trait<Harvester>();
|
||||
body = self.Trait<WithVoxelUnloadBody>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case State.Turn:
|
||||
state = State.Dock;
|
||||
return Util.SequenceActivities(new Turn(160), this);
|
||||
case State.Dock:
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Docked(proc, self);
|
||||
state = State.Loop;
|
||||
body.Docked = true;
|
||||
return this;
|
||||
case State.Loop:
|
||||
if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc))
|
||||
state = State.Undock;
|
||||
return this;
|
||||
case State.Undock:
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Undocked(proc, self);
|
||||
body.Docked = false;
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Invalid harvester dock state");
|
||||
}
|
||||
|
||||
public override void Cancel(Actor self)
|
||||
{
|
||||
state = State.Undock;
|
||||
}
|
||||
|
||||
public override IEnumerable<Target> GetTargets(Actor self)
|
||||
{
|
||||
yield return Target.FromActor(proc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,17 @@
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<Compile Include="Widgets\Logic\TSInstallFromCDLogic.cs" />
|
||||
<Compile Include="ShroudPalette.cs" />
|
||||
<Compile Include="Activities\VoxelHarvesterDockSequence.cs" />
|
||||
<Compile Include="TiberianSunRefinery.cs" />
|
||||
<Compile Include="WithVoxelUnloadBody.cs" />
|
||||
</ItemGroup>
|
||||
<!-- 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.
|
||||
|
||||
30
OpenRA.Mods.TS/TiberianSunRefinery.cs
Normal file
30
OpenRA.Mods.TS/TiberianSunRefinery.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS
|
||||
{
|
||||
public class TiberianSunRefineryInfo : OreRefineryInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new TiberianSunRefinery(init.self, this); }
|
||||
}
|
||||
|
||||
public class TiberianSunRefinery : OreRefinery
|
||||
{
|
||||
public TiberianSunRefinery(Actor self, TiberianSunRefineryInfo info) : base(self, info) { }
|
||||
|
||||
public override Activity DockSequence(Actor harv, Actor self)
|
||||
{
|
||||
return new VoxelHarvesterDockSequence(harv, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
OpenRA.Mods.TS/WithVoxelUnloadBody.cs
Executable file
61
OpenRA.Mods.TS/WithVoxelUnloadBody.cs
Executable file
@@ -0,0 +1,61 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
public class WithVoxelUnloadBodyInfo : ITraitInfo, Requires<RenderVoxelsInfo>
|
||||
{
|
||||
[Desc("Voxel sequence name to use when docked to a refinery.")]
|
||||
public readonly string UnloadSequence = "unload";
|
||||
|
||||
[Desc("Voxel sequence name to use when undocked from a refinery.")]
|
||||
public readonly string IdleSequence = "idle";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithVoxelUnloadBody(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithVoxelUnloadBody : IAutoSelectionSize
|
||||
{
|
||||
public bool Docked;
|
||||
|
||||
readonly int2 size;
|
||||
|
||||
public WithVoxelUnloadBody(Actor self, WithVoxelUnloadBodyInfo info)
|
||||
{
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
var rv = self.Trait<RenderVoxels>();
|
||||
|
||||
var idleVoxel = VoxelProvider.GetVoxel(rv.Image, info.IdleSequence);
|
||||
rv.Add(new VoxelAnimation(idleVoxel, () => WVec.Zero,
|
||||
() => new[]{ body.QuantizeOrientation(self, self.Orientation) },
|
||||
() => Docked,
|
||||
() => 0));
|
||||
|
||||
// Selection size
|
||||
var rvi = self.Info.Traits.Get<RenderVoxelsInfo>();
|
||||
var s = (int)(rvi.Scale * idleVoxel.Size.Aggregate(Math.Max));
|
||||
size = new int2(s, s);
|
||||
|
||||
var unloadVoxel = VoxelProvider.GetVoxel(rv.Image, info.UnloadSequence);
|
||||
rv.Add(new VoxelAnimation(unloadVoxel, () => WVec.Zero,
|
||||
() => new[]{ body.QuantizeOrientation(self, self.Orientation) },
|
||||
() => !Docked,
|
||||
() => 0));
|
||||
}
|
||||
|
||||
public int2 SelectionSize(Actor self) { return size; }
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,8 @@ PROC:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
# Bib:
|
||||
TiberiumRefinery:
|
||||
TiberianSunRefinery:
|
||||
DockOffset: 4,3
|
||||
StoresResources:
|
||||
PipColor: Green
|
||||
PipCount: 15
|
||||
@@ -142,6 +143,7 @@ PROC:
|
||||
Value: 600
|
||||
FreeActor:
|
||||
Actor: HARV
|
||||
InitialActivity: FindResources
|
||||
SpawnOffset: 3,4
|
||||
Facing: 64
|
||||
WithIdleOverlay@REDLIGHTS:
|
||||
|
||||
@@ -101,7 +101,7 @@ HARV:
|
||||
-GainsExperience:
|
||||
RenderSprites:
|
||||
RenderVoxels:
|
||||
WithVoxelBody:
|
||||
WithVoxelUnloadBody:
|
||||
Explodes:
|
||||
Weapon: TiberiumExplosion
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@ mcv:
|
||||
|
||||
harv:
|
||||
idle:
|
||||
|
||||
horv:
|
||||
idle:
|
||||
unload: horv
|
||||
|
||||
apc: # TODO apcw in water
|
||||
idle:
|
||||
|
||||
Reference in New Issue
Block a user