ActorInitializer, in preparation for next change (bob)

This commit is contained in:
Chris Forbes
2010-06-19 14:28:30 +12:00
parent 572cdc9dbf
commit db465e1fdd
106 changed files with 174 additions and 227 deletions

View File

@@ -29,7 +29,8 @@ namespace OpenRA.Mods.RA
{
public readonly string UnitType = "badr.bomber";
public readonly string FlareType = null;
public override object Create(Actor self) { return new AirstrikePower(self, this); }
public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); }
}
class AirstrikePower : SupportPower, IResolveOrder

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class AttackHeliInfo : AttackBaseInfo
{
public override object Create(Actor self) { return new AttackHeli(self); }
public override object Create(ActorInitializer init) { return new AttackHeli(init.self); }
}
class AttackHeli : AttackFrontal

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
{
class AttackLeapInfo : AttackBaseInfo
{
public override object Create(Actor self) { return new AttackLeap(self); }
public override object Create(ActorInitializer init) { return new AttackLeap(init.self); }
}
class AttackLeap : AttackBase

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
class AttackOmniInfo : AttackBaseInfo
{
public override object Create(Actor self) { return new AttackOmni(self); }
public override object Create(ActorInitializer init) { return new AttackOmni(init.self); }
}
class AttackOmni : AttackBase, INotifyBuildComplete

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class AttackPlaneInfo : AttackBaseInfo
{
public override object Create(Actor self) { return new AttackPlane(self); }
public override object Create(ActorInitializer init) { return new AttackPlane(init.self); }
}
class AttackPlane : AttackFrontal

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
class AttackTeslaInfo : AttackOmniInfo
{
public readonly int MaxCharges = 3;
public override object Create(Actor self) { return new AttackTesla(self); }
public override object Create(ActorInitializer init) { return new AttackTesla(init.self); }
}
class AttackTesla : AttackOmni, ITick

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class AttackTurretedInfo : AttackBaseInfo
{
public override object Create(Actor self) { return new AttackTurreted( self ); }
public override object Create(ActorInitializer init) { return new AttackTurreted( init.self ); }
}
class AttackTurreted : AttackBase, INotifyBuildComplete

View File

@@ -34,7 +34,8 @@ namespace OpenRA.Mods.RA
public readonly bool UseAlternateNames = false;
public readonly int[] NorthOffset = null;
public readonly int[] SouthOffset = null;
public object Create(Actor self) { return new Bridge(self); }
public object Create(ActorInitializer init) { return new Bridge(init.self); }
}
class Bridge: IRender, INotifyDamage

View File

@@ -24,16 +24,13 @@ using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
{
class C4DemolitionInfo : ITraitInfo
class C4DemolitionInfo : TraitInfo<C4Demolition>
{
public readonly float C4Delay = 0;
public object Create(Actor self) { return new C4Demolition(self); }
}
class C4Demolition : IIssueOrder, IResolveOrder
{
public C4Demolition(Actor self) {}
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button != MouseButton.Right) return null;

View File

@@ -21,10 +21,7 @@
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class CanPowerDownInfo : ITraitInfo
{
public object Create(Actor self) { return new CanPowerDown(); }
}
public class CanPowerDownInfo : TraitInfo<CanPowerDown> { }
public class CanPowerDown : IDisable, IPowerModifier, IResolveOrder
{

View File

@@ -25,21 +25,17 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class CargoInfo : ITraitInfo
public class CargoInfo : TraitInfo<Cargo>
{
public readonly int Passengers = 0;
public readonly UnitMovementType[] PassengerTypes = { };
public readonly int UnloadFacing = 0;
public object Create(Actor self) { return new Cargo(self); }
}
public class Cargo : IPips, IIssueOrder, IResolveOrder
{
List<Actor> cargo = new List<Actor>();
public Cargo(Actor self) {}
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
// todo: check if there is an unoccupied `land` tile adjacent

View File

@@ -23,12 +23,10 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class CarpetBombInfo : ITraitInfo
class CarpetBombInfo : TraitInfo<CarpetBomb>
{
public readonly string Weapon = null;
public readonly int Range = 0;
public object Create(Actor self) { return new CarpetBomb(self); }
}
class CarpetBomb : ITick // todo: maybe integrate this better with the normal weapons system?
@@ -36,8 +34,6 @@ namespace OpenRA.Mods.RA
int2 Target;
int dropDelay;
public CarpetBomb(Actor self) { }
public void SetTarget(int2 targetCell) { Target = targetCell; }
public void Tick(Actor self)

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
class RepairButtonInfo : ITraitInfo
{
public readonly bool RequiresConstructionYard = true;
public object Create(Actor self) { return new RepairButton(this); }
public object Create(ActorInitializer init) { return new RepairButton(this); }
}
class RepairButton : IChromeButton

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
{
class ChronoshiftPowerInfo : SupportPowerInfo
{
public override object Create(Actor self) { return new ChronoshiftPower(self,this); }
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
}
class ChronoshiftPower : SupportPower, IResolveOrder
@@ -163,7 +163,7 @@ namespace OpenRA.Mods.RA
{
public readonly int Duration = 30;
public readonly bool KillCargo = true;
public object Create(Actor self) { return new Chronosphere(self); }
public object Create(ActorInitializer init) { return new Chronosphere(init.self); }
}
class Chronosphere

View File

@@ -23,10 +23,7 @@ using OpenRA.Mods.RA.Activities;
namespace OpenRA.Mods.RA
{
class ChronoshiftableInfo : ITraitInfo
{
public object Create(Actor self) { return new Chronoshiftable(self); }
}
class ChronoshiftableInfo : TraitInfo<Chronoshiftable> { }
public class Chronoshiftable : ITick
{
@@ -36,8 +33,6 @@ namespace OpenRA.Mods.RA
[Sync]
int chronoshiftReturnTicks = 0;
public Chronoshiftable(Actor self) { }
public void Tick(Actor self)
{
if (chronoshiftReturnTicks <= 0)

View File

@@ -23,18 +23,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class ConquestVictoryConditionsInfo : ITraitInfo
{
public object Create(Actor self) { return new ConquestVictoryConditions( self ); }
}
class ConquestVictoryConditionsInfo : TraitInfo<ConquestVictoryConditions> { }
class ConquestVictoryConditions : ITick, IVictoryConditions, IResolveOrder
{
public bool HasLost { get; private set; }
public bool HasWon { get; private set; }
public ConquestVictoryConditions(Actor self) { }
public void Tick(Actor self)
{
var hasAnything = self.World.Queries.OwnedBy[self.Owner]

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
class CrateInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
{
public readonly int Lifetime = 5; // Seconds
public object Create(Actor self) { return new Crate(self); }
public object Create(ActorInitializer init) { return new Crate(init.self); }
}
class Crate : ICrushable, IOccupySpace, ITick

View File

@@ -28,7 +28,8 @@ namespace OpenRA.Mods.RA
public int SelectionShares = 10;
public string Effect = null;
public string Notification = null;
public virtual object Create(Actor self) { return new CrateAction(self, this); }
public virtual object Create(ActorInitializer init) { return new CrateAction(init.self, this); }
}
public class CrateAction

View File

@@ -24,14 +24,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class CrateSpawnerInfo : ITraitInfo
class CrateSpawnerInfo : TraitInfo<CrateSpawner>
{
public readonly int Minimum = 1; // Minumum number of crates
public readonly int Maximum = 255; // Maximum number of crates
public readonly int SpawnInterval = 180; // Average time (seconds) between crate spawn
public readonly float WaterChance = .2f; // Chance of generating a water crate instead of a land crate
public object Create(Actor self) { return new CrateSpawner(); }
}
// assumption: there is always at least one free water cell, and one free land cell.

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
class ArmorUpgradeCrateActionInfo : CrateActionInfo
{
public float Multiplier = 2.0f;
public override object Create(Actor self) { return new ArmorUpgradeCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new ArmorUpgradeCrateAction(init.self, this); }
}
class ArmorUpgradeCrateAction : CrateAction

View File

@@ -10,7 +10,7 @@ namespace OpenRA.Mods.RA
class ExplodeCrateActionInfo : CrateActionInfo
{
public string Weapon = null;
public override object Create(Actor self) { return new ExplodeCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.self, this); }
}
class ExplodeCrateAction : CrateAction

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
class FirepowerUpgradeCrateActionInfo : CrateActionInfo
{
public float Multiplier = 2.0f;
public override object Create(Actor self) { return new FirepowerUpgradeCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new FirepowerUpgradeCrateAction(init.self, this); }
}
class FirepowerUpgradeCrateAction : CrateAction

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
class GiveCashCrateActionInfo : CrateActionInfo
{
public int Amount = 2000;
public override object Create(Actor self) { return new GiveCashCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new GiveCashCrateAction(init.self, this); }
}
class GiveCashCrateAction : CrateAction

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
class HideMapCrateActionInfo : CrateActionInfo
{
public override object Create(Actor self) { return new HideMapCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new HideMapCrateAction(init.self, this); }
}
class HideMapCrateAction : CrateAction

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
class SpeedUpgradeCrateActionInfo : CrateActionInfo
{
public float Multiplier = 1.7f;
public override object Create(Actor self) { return new SpeedUpgradeCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new SpeedUpgradeCrateAction(init.self, this); }
}
class SpeedUpgradeCrateAction : CrateAction

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Crates
class SupportPowerCrateActionInfo : CrateActionInfo
{
public string Power = null;
public override object Create(Actor self) { return new SupportPowerCrateAction(self, this); }
public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.self, this); }
}
class SupportPowerCrateAction : CrateAction

View File

@@ -26,11 +26,8 @@ using System.Collections.Generic;
using System;
namespace OpenRA.Mods.RA
{
class DefaultShellmapScriptInfo : ITraitInfo
{
public object Create(Actor self) { return new DefaultShellmapScript(); }
}
{
class DefaultShellmapScriptInfo : TraitInfo<DefaultShellmapScript> { }
class DefaultShellmapScript: ILoadWorldHook, ITick
{

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
public readonly float[] FirepowerModifier = { 1.1f, 1.15f, 1.2f, 1.5f };
public readonly float[] ArmorModifier = { 1.1f, 1.2f, 1.3f, 1.5f };
public readonly float[] SpeedModifier = { 1.1f, 1.15f, 1.2f, 1.5f };
public object Create(Actor self) { return new GainsExperience(self, this); }
public object Create(ActorInitializer init) { return new GainsExperience(init.self, this); }
}
public class GainsExperience : IFirepowerModifier, ISpeedModifier, IDamageModifier, IRenderModifier

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
{
public readonly int RevealDelay = 0;
public override object Create(Actor self) { return new GpsPower(self, this); }
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
}
class GpsPower : SupportPower

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
public readonly string[] Resources = { };
public readonly string DeathWeapon = null;
public object Create(Actor self) { return new Harvester(self, this); }
public object Create(ActorInitializer init) { return new Harvester(init.self, this); }
}
public class Harvester : IIssueOrder, IResolveOrder, INotifyDamage, IPips, IRenderModifier

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
public readonly int2 SpawnOffset = int2.Zero;
public readonly int Facing = 0;
public object Create( Actor self ) { return new FreeActor(self, this); }
public object Create( ActorInitializer init ) { return new FreeActor(init.self, this); }
}
public class FreeActor

View File

@@ -34,7 +34,8 @@ namespace OpenRA.Mods.RA
public readonly int CruiseAltitude = 20;
public readonly int IdealSeparation = 40;
public readonly bool LandWhenIdle = true;
public object Create(Actor self) { return new Helicopter(self); }
public object Create(ActorInitializer init) { return new Helicopter(init.self); }
}
class Helicopter : ITick, IIssueOrder, IResolveOrder, IMovement

View File

@@ -6,7 +6,10 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class HuskInfo : ITraitInfo { public object Create(Actor self) { return new Husk(self); } }
class HuskInfo : ITraitInfo
{
public object Create( ActorInitializer init ) { return new Husk( init.self ); }
}
class Husk : IOccupySpace
{

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
class IronCurtainPowerInfo : SupportPowerInfo
{
public readonly float Duration = 0f;
public override object Create(Actor self) { return new IronCurtainPower(self, this); }
public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); }
}
class IronCurtainPower : SupportPower, IResolveOrder

View File

@@ -24,7 +24,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class IronCurtainableInfo : TraitInfo<IronCurtainable> {}
class IronCurtainableInfo : TraitInfo<IronCurtainable> { }
class IronCurtainable : IDamageModifier, ITick
{

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
public readonly string Weapon = "ATMine";
public readonly bool AvoidFriendly = true;
public object Create(Actor self) { return new Mine(self); }
public object Create(ActorInitializer init) { return new Mine(init.self); }
}
class Mine : ICrushable, IOccupySpace

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
{
class NukePowerInfo : SupportPowerInfo
{
public override object Create(Actor self) { return new NukePower(self, this); }
public override object Create(ActorInitializer init) { return new NukePower(init.self, this); }
}
class NukePower : SupportPower, IResolveOrder
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
class NukeSiloInfo : ITraitInfo
{
public readonly string MissileWeapon = "";
public object Create(Actor self) { return new NukeSilo(self); }
public object Create(ActorInitializer init) { return new NukeSilo(init.self); }
}
class NukeSilo

View File

@@ -37,10 +37,8 @@ namespace OpenRA.Mods.RA
public readonly int ProcessTick = 25;
public readonly int ProcessAmount = 50;
public readonly string DeathWeapon = null;
public object Create (Actor self)
{
return new OreRefinery (self, this);
}
public object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }
}
class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IPips, ITraitPrerequisite<IAcceptOreDockAction>

View File

@@ -29,17 +29,18 @@ namespace OpenRA.Mods.RA
public readonly string Theater = null;
public readonly string Filename = null;
public readonly bool Transparent = true;
public object Create(Actor self) { return new PaletteFromFile(self, this); }
public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); }
}
class PaletteFromFile
{
public PaletteFromFile(Actor self, PaletteFromFileInfo info)
public PaletteFromFile(World world, PaletteFromFileInfo info)
{
if (info.Theater == null ||
info.Theater.ToLowerInvariant() == self.World.Map.Theater.ToLowerInvariant())
info.Theater.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant())
{
self.World.WorldRenderer.AddPalette(info.Name,
world.WorldRenderer.AddPalette(info.Name,
new Palette(FileSystem.Open(info.Filename), info.Transparent));
}
}

View File

@@ -32,18 +32,19 @@ namespace OpenRA.Mods.RA
public readonly int G = 0;
public readonly int B = 0;
public readonly int A = 255;
public object Create(Actor self) { return new PaletteFromRGBA(self, this); }
public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); }
}
class PaletteFromRGBA
{
public PaletteFromRGBA(Actor self, PaletteFromRGBAInfo info)
public PaletteFromRGBA(World world, PaletteFromRGBAInfo info)
{
if (info.Theatre == null ||
info.Theatre.ToLowerInvariant() == self.World.Map.Theater.ToLowerInvariant())
info.Theatre.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant())
{
// TODO: This shouldn't rely on a base palette
var wr = self.World.WorldRenderer;
var wr = world.WorldRenderer;
var pal = wr.GetPalette("player0");
wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B))));
}

View File

@@ -27,10 +27,9 @@ using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
{
public class ParaDropInfo : ITraitInfo
public class ParaDropInfo : TraitInfo<ParaDrop>
{
public readonly int LZRange = 4;
public object Create(Actor self) { return new ParaDrop(); }
}
public class ParaDrop : ITick

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
public string UnitType = "badr";
public string FlareType = "flare";
public override object Create(Actor self) { return new ParatroopersPower(self,this); }
public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); }
}
class ParatroopersPower : SupportPower, IResolveOrder

View File

@@ -27,21 +27,17 @@ using OpenRA.Mods.RA.Activities;
namespace OpenRA.Mods.RA
{
public class PlaneInfo : ITraitInfo
public class PlaneInfo : TraitInfo<Plane>
{
public readonly int CruiseAltitude = 20;
public readonly string[] RearmBuildings = { "afld" };
public readonly string[] RepairBuildings = { "fix" };
public object Create(Actor self) { return new Plane(self); }
}
public class Plane : IIssueOrder, IResolveOrder, IMovement
{
public IDisposable reservation;
public Plane(Actor self) {}
static bool PlaneCanEnter(Actor self, Actor a)
{
var plane = self.Info.Traits.Get<PlaneInfo>();

View File

@@ -26,13 +26,11 @@ namespace OpenRA.Mods.RA
{
class ProductionSurroundInfo : ProductionInfo
{
public override object Create(Actor self) { return new ProductionSurround(self); }
public override object Create(ActorInitializer init) { return new ProductionSurround(); }
}
class ProductionSurround : Production
{
public ProductionSurround(Actor self) : base(self) { }
static int2? FindAdjacentTile(Actor self, bool waterBound)
{
var tiles = Footprint.Tiles(self);

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
class RenderBuildingChargeInfo : RenderBuildingInfo
{
public readonly string ChargeAudio = "tslachg2.aud";
public override object Create(Actor self) { return new RenderBuildingCharge(self); }
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init.self); }
}
/* used for tesla */

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
class RenderBuildingOreInfo : RenderBuildingInfo
{
public override object Create(Actor self) { return new RenderBuildingOre(self); }
public override object Create(ActorInitializer init) { return new RenderBuildingOre(init.self); }
}
class RenderBuildingOre : RenderBuilding, INotifyBuildComplete

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
class RenderBuildingWallInfo : RenderBuildingInfo
{
public readonly int DamageStates = 2;
public override object Create(Actor self) { return new RenderBuildingWall(self); }
public override object Create(ActorInitializer init) { return new RenderBuildingWall(init.self); }
}
class RenderBuildingWall : RenderBuilding

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class RenderWarFactoryInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
{
public object Create(Actor self) { return new RenderWarFactory(self); }
public object Create(ActorInitializer init) { return new RenderWarFactory(init.self); }
}
class RenderWarFactory : INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction, INotifySold

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
class RenderFlareInfo : RenderSimpleInfo
{
public override object Create(Actor self) { return new RenderFlare(self); }
public override object Create(ActorInitializer init) { return new RenderFlare(init.self); }
}
class RenderFlare : RenderSimple

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
public class RenderInfantryInfo : RenderSimpleInfo
{
public override object Create(Actor self) { return new RenderInfantry(self); }
public override object Create(ActorInitializer init) { return new RenderInfantry(init.self); }
}
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class RenderSpyInfo : RenderInfantryInfo
{
public override object Create(Actor self) { return new RenderSpy(self); }
public override object Create(ActorInitializer init) { return new RenderSpy(init.self); }
}
class RenderSpy : RenderInfantry, IRenderModifier

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
{
class RenderUnitReloadInfo : RenderUnitInfo
{
public override object Create(Actor self) { return new RenderUnitReload(self); }
public override object Create(ActorInitializer init) { return new RenderUnitReload(init.self); }
}
class RenderUnitReload : RenderUnit

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
public readonly int[] PrimaryOffset = { 0, 0 };
public readonly int[] SecondaryOffset = null;
public override object Create(Actor self) { return new RenderUnitRotor(self); }
public override object Create(ActorInitializer init) { return new RenderUnitRotor(init.self); }
}
class RenderUnitRotor : RenderUnit

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
class RenderUnitSpinnerInfo : RenderUnitInfo
{
public readonly int[] Offset = { 0, 0 };
public override object Create(Actor self) { return new RenderUnitSpinner(self); }
public override object Create(ActorInitializer init) { return new RenderUnitSpinner(init.self); }
}
class RenderUnitSpinner : RenderUnit

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
class ReplaceWithActorInfo : ITraitInfo
{
public readonly string Actor = null;
public object Create(Actor self) { return new ReplaceWithActor(self, this); }
public object Create(ActorInitializer init) { return new ReplaceWithActor(init.self, this); }
}
class ReplaceWithActor

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
class RequiresPowerInfo : ITraitInfo
{
public object Create(Actor self) { return new RequiresPower(self); }
public object Create(ActorInitializer init) { return new RequiresPower(init.self); }
}
class RequiresPower : IDisable

View File

@@ -23,14 +23,10 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class ReservableInfo : ITraitInfo
{
public object Create(Actor self) { return new Reservable(self); }
}
class ReservableInfo : TraitInfo<Reservable> { }
public class Reservable : ITick
{
public Reservable(Actor self) { }
Actor reservedFor;
public void Tick(Actor self)

View File

@@ -25,14 +25,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class SeedsResourceInfo : ITraitInfo
class SeedsResourceInfo : TraitInfo<SeedsResource>
{
public readonly int Interval = 75;
public readonly string ResourceType = "Ore";
public readonly int MaxRange = 100;
public readonly int MaxRange = 100;
public readonly int AnimationInterval = 750;
public object Create(Actor self) { return new SeedsResource(); }
}
class SeedsResource : ITick

View File

@@ -22,13 +22,11 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class SelfHealingInfo : ITraitInfo
class SelfHealingInfo : TraitInfo<SelfHealing>
{
public readonly int Step = 5;
public readonly int Ticks = 5;
public readonly float HealIfBelow = .5f;
public object Create(Actor self) { return new SelfHealing(); }
}
class SelfHealing : ITick

View File

@@ -27,15 +27,15 @@ namespace OpenRA.Mods.RA
{
public readonly string Name = "shroud";
public readonly bool IsFog = false;
public object Create(Actor self) { return new ShroudPalette(self, this); }
public object Create(ActorInitializer init) { return new ShroudPalette(init.world, this); }
}
class ShroudPalette
{
public ShroudPalette(Actor self, ShroudPaletteInfo info)
public ShroudPalette(World world, ShroudPaletteInfo info)
{
// TODO: This shouldn't rely on a base palette
var wr = self.World.WorldRenderer;
var wr = world.WorldRenderer;
var pal = wr.GetPalette("terrain");
wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog)));
}

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
{
public class SonarPulsePowerInfo : SupportPowerInfo
{
public override object Create(Actor self) { return new SonarPulsePower(self, this); }
public override object Create(ActorInitializer init) { return new SonarPulsePower(init.self, this); }
}
public class SonarPulsePower : SupportPower, IResolveOrder

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
class SpyPlanePowerInfo : SupportPowerInfo
{
public readonly float RevealTime = .1f; // minutes
public override object Create(Actor self) { return new SpyPlanePower(self,this); }
public override object Create(ActorInitializer init) { return new SpyPlanePower(init.self,this); }
}
class SpyPlanePower : SupportPower, IResolveOrder

View File

@@ -23,10 +23,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class TakeCoverInfo : ITraitInfo
{
public object Create(Actor self) { return new TakeCover(self); }
}
class TakeCoverInfo : TraitInfo<TakeCover> { }
// infantry prone behavior
class TakeCover : ITick, INotifyDamage, IDamageModifier, ISpeedModifier
@@ -40,8 +37,6 @@ namespace OpenRA.Mods.RA
public bool IsProne { get { return remainingProneTime > 0; } }
public TakeCover(Actor self) {}
public void Damaged(Actor self, AttackInfo e)
{
if (e.Damage > 0) /* fix to allow healing via `damage` */

View File

@@ -32,7 +32,8 @@ namespace OpenRA.Mods.RA
public readonly string AnimKey = null;
public readonly bool UseTurretFacing = true;
public readonly float ROT = 15;
public object Create(Actor self) { return new ThrowsParticle(self, this); }
public object Create(ActorInitializer init) { return new ThrowsParticle(this); }
}
class ThrowsParticle : ITick
@@ -48,7 +49,7 @@ namespace OpenRA.Mods.RA
const float gravity = 1.3f;
public ThrowsParticle(Actor self, ThrowsParticleInfo info) { this.info = info; }
public ThrowsParticle(ThrowsParticleInfo info) { this.info = info; }
public float? InitialFacing = null;
public void Tick(Actor self)

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
{
public readonly UnitMovementType[] CrushableBy = { };
public object Create(Actor self) { return new Wall(self); }
public object Create(ActorInitializer init) { return new Wall(init.self); }
}
public class Wall : ICrushable, IOccupySpace, IBlocksBullets

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
{
class WithMuzzleFlashInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
{
public object Create(Actor self) { return new WithMuzzleFlash(self); }
public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); }
}
class WithMuzzleFlash : INotifyAttack