Further RA project cleanup

This commit is contained in:
penev92
2014-12-21 18:17:57 +02:00
parent 7c19f710b8
commit 681042caec
30 changed files with 53 additions and 35 deletions

View File

@@ -0,0 +1,45 @@
#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.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities
{
public class Turn : Activity
{
readonly IEnumerable<IDisableMove> moveDisablers;
readonly int desiredFacing;
public Turn(Actor self, int desiredFacing)
{
moveDisablers = self.TraitsImplementing<IDisableMove>();
this.desiredFacing = desiredFacing;
}
public override Activity Tick( Actor self )
{
if (IsCanceled)
return NextActivity;
if (moveDisablers.Any(d => d.MoveDisabled(self)))
return this;
var facing = self.Trait<IFacing>();
if( desiredFacing == facing.Facing )
return NextActivity;
facing.Facing = Util.TickFacing(facing.Facing, desiredFacing, facing.ROT);
return this;
}
}
}

View File

@@ -0,0 +1,69 @@
#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 OpenRA.Activities;
namespace OpenRA.Mods.Common.Activities
{
public class Wait : Activity
{
int remainingTicks;
bool interruptable = true;
public Wait(int period) { remainingTicks = period; }
public Wait(int period, bool interruptable)
{
remainingTicks = period;
this.interruptable = interruptable;
}
public override Activity Tick(Actor self)
{
return (remainingTicks-- == 0) ? NextActivity : this;
}
public override void Cancel( Actor self )
{
if( !interruptable )
return;
remainingTicks = 0;
base.Cancel(self);
}
}
public class WaitFor : Activity
{
Func<bool> f;
bool interruptable = true;
public WaitFor(Func<bool> f) { this.f = f; }
public WaitFor(Func<bool> f, bool interruptable)
{
this.f = f;
this.interruptable = interruptable;
}
public override Activity Tick(Actor self)
{
return (f == null || f()) ? NextActivity : this;
}
public override void Cancel( Actor self )
{
if (!interruptable)
return;
f = null;
base.Cancel(self);
}
}
}

View File

@@ -51,6 +51,8 @@
<Compile Include="Activities\Move\Drag.cs" />
<Compile Include="Activities\RemoveSelf.cs" />
<Compile Include="Activities\SimpleTeleport.cs" />
<Compile Include="Activities\Turn.cs" />
<Compile Include="Activities\Wait.cs" />
<Compile Include="Effects\Beacon.cs" />
<Compile Include="Effects\Bullet.cs" />
<Compile Include="Effects\Contrail.cs" />
@@ -112,12 +114,14 @@
<Compile Include="Traits\AppearsOnRadar.cs" />
<Compile Include="Traits\BlocksBullets.cs" />
<Compile Include="Traits\Buildable.cs" />
<Compile Include="Traits\Buildings\BaseBuilding.cs" />
<Compile Include="Traits\Buildings\BaseProvider.cs" />
<Compile Include="Traits\Buildings\DeadBuildingState.cs" />
<Compile Include="Traits\Buildings\LineBuild.cs" />
<Compile Include="Traits\Buildings\LineBuildNode.cs" />
<Compile Include="Traits\Buildings\RallyPoint.cs" />
<Compile Include="Traits\Burns.cs" />
<Compile Include="Traits\Huntable.cs" />
<Compile Include="Traits\CustomBuildTimeValue.cs" />
<Compile Include="Traits\CustomSellValue.cs" />
<Compile Include="Traits\Demolishable.cs" />

View File

@@ -0,0 +1,18 @@
#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 OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Tag trait for construction yard and MCVs. Used by the cycle bases hotkey to identify actors.")]
public class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
public class BaseBuilding { }
}

View File

@@ -0,0 +1,18 @@
#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 OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("This actor can be targeted by the Hunt activity.")]
public class HuntableInfo : TraitInfo<Huntable> { }
public class Huntable { }
}

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic;
using OpenRA.Activities;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -52,4 +51,6 @@ namespace OpenRA.Mods.Common.Traits
void PrerequisitesItemHidden(string key);
void PrerequisitesItemVisible(string key);
}
public interface INotifyTransform { void BeforeTransform(Actor self); void OnTransform(Actor self); void AfterTransform(Actor toActor); }
}