Actor.traits is implementation detail

This commit is contained in:
Bob
2010-08-14 15:19:30 +12:00
committed by alzeih
parent f6c6255f64
commit ae703d50b2
165 changed files with 586 additions and 561 deletions

View File

@@ -1,18 +1,18 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 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 LICENSE.
*/
#endregion
using System.Drawing;
using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
#region Copyright & License Information
/*
* Copyright 2007-2010 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 LICENSE.
*/
#endregion
using System.Drawing;
using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.Cnc
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc
{
float2 startDock = harv.CenterLocation;
float2 endDock = self.CenterLocation + new float2(-15,8);
var harvester = harv.traits.Get<Harvester>();
var harvester = harv.Trait<Harvester>();
harv.QueueActivity( new Turn(112) );
harv.QueueActivity( new CallFunc( () =>
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc
if (!preventDock)
{
dockedHarv = harv;
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
harv.QueueActivity( new Drag(startDock, endDock, 12) );
harv.QueueActivity( new CallFunc( () =>
@@ -51,16 +51,16 @@ namespace OpenRA.Mods.Cnc
harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) );
harv.QueueActivity( new Drag(endDock, startDock, 12) );
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
if (harvester.LastHarvestedCell != int2.Zero)
if (harvester.LastHarvestedCell != int2.Zero)
{
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
if (harv.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask( w =>
{
var line = harv.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTargetSilently(harv, Target.FromCell(harvester.LastHarvestedCell), Color.Green);
});
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
if (harv.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask( w =>
{
var line = harv.TraitOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTargetSilently(harv, Target.FromCell(harvester.LastHarvestedCell), Color.Green);
});
}
}
harv.QueueActivity( new Harvest() );
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc
return;
// invisible harvester makes ceiling cat cry
harv.traits.Get<Harvester>().Visible = true;
harv.Trait<Harvester>().Visible = true;
}
public void Selling (Actor self) { CancelDock(self, dockedHarv); }