diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index b1df44eb54..1308ba32ef 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -36,9 +36,9 @@ namespace OpenRA public readonly ActorInfo Info; public readonly World World; - public readonly uint ActorID; - - [Sync] + public readonly uint ActorID; + + [Sync] public int2 Location; [Sync] public Player Owner; @@ -49,13 +49,15 @@ namespace OpenRA public Group Group; public Actor(World world, string name, int2 location, Player owner) - { + { World = world; ActorID = world.NextAID(); Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; + var init = new ActorInitializer( this ); + if (name != null) { if (!Rules.Info.ContainsKey(name.ToLowerInvariant())) @@ -65,9 +67,9 @@ namespace OpenRA Health = this.GetMaxHP(); foreach (var trait in Info.TraitsInConstructOrder()) - traits.Add(trait.Create(this)); - } - + traits.Add(trait.Create(init)); + } + Size = Lazy.New(() => { var si = Info.Traits.GetOrDefault(); @@ -254,5 +256,16 @@ namespace OpenRA var o = obj as Actor; return ( o != null && o.ActorID == ActorID ); } + } + + public class ActorInitializer + { + public readonly Actor self; + public World world { get { return self.World; } } + + public ActorInitializer( Actor actor ) + { + this.self = actor; + } } } diff --git a/OpenRA.Game/Traits/AttackBase.cs b/OpenRA.Game/Traits/AttackBase.cs index d3a20173d3..7d2a5ada2e 100644 --- a/OpenRA.Game/Traits/AttackBase.cs +++ b/OpenRA.Game/Traits/AttackBase.cs @@ -39,7 +39,7 @@ namespace OpenRA.Traits public readonly bool MuzzleFlash = false; public readonly int FireDelay = 0; - public virtual object Create(Actor self) { return new AttackBase(self); } + public virtual object Create(ActorInitializer init) { return new AttackBase(init.self); } } public class AttackBase : IIssueOrder, IResolveOrder, ITick diff --git a/OpenRA.Game/Traits/Buildable.cs b/OpenRA.Game/Traits/Buildable.cs index 9e37eab7f4..5234b35a26 100755 --- a/OpenRA.Game/Traits/Buildable.cs +++ b/OpenRA.Game/Traits/Buildable.cs @@ -27,7 +27,7 @@ namespace OpenRA.Traits public readonly string LongDesc = ""; public readonly string[] Owner = { }; - public virtual object Create(Actor self) { return new Valued(); } + public virtual object Create(ActorInitializer init) { return new Valued(); } } class BuildableInfo : ValuedInfo @@ -40,7 +40,7 @@ namespace OpenRA.Traits public readonly int BuildPaletteOrder = 9999; public readonly string Hotkey = null; - public override object Create(Actor self) { return new Buildable(); } + public override object Create(ActorInitializer init) { return new Buildable(); } } class Valued { } /* halfway to buildable */ diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index 4238584e73..31ac388e9c 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -54,7 +54,7 @@ namespace OpenRA.Traits public readonly string DamagedSound = "kaboom1.aud"; public readonly string DestroyedSound = "kaboom22.aud"; - public object Create(Actor self) { return new Building(self); } + public object Create(ActorInitializer init) { return new Building(init.self); } } public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier diff --git a/OpenRA.Game/Traits/Cloak.cs b/OpenRA.Game/Traits/Cloak.cs index 6a580e58ac..0ddd20501c 100644 --- a/OpenRA.Game/Traits/Cloak.cs +++ b/OpenRA.Game/Traits/Cloak.cs @@ -30,7 +30,8 @@ namespace OpenRA.Traits public readonly float CloakDelay = 1.2f; // Seconds public readonly string CloakSound = "subshow1.aud"; public readonly string UncloakSound = "subshow1.aud"; - public object Create(Actor self) { return new Cloak(self); } + + public object Create(ActorInitializer init) { return new Cloak(init.self); } } public class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage diff --git a/OpenRA.Game/Traits/LimitedAmmo.cs b/OpenRA.Game/Traits/LimitedAmmo.cs index cff63a57ea..62e14675cf 100644 --- a/OpenRA.Game/Traits/LimitedAmmo.cs +++ b/OpenRA.Game/Traits/LimitedAmmo.cs @@ -27,7 +27,7 @@ namespace OpenRA.Traits public readonly int Ammo = 0; public readonly int PipCount = 0; - public object Create(Actor self) { return new LimitedAmmo(self); } + public object Create(ActorInitializer init) { return new LimitedAmmo(init.self); } } public class LimitedAmmo : INotifyAttack, IPips diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index caddde09a3..c70b5187d2 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -24,13 +24,13 @@ using OpenRA.GameRules; namespace OpenRA.Traits { - public class MobileInfo : ITraitInfo + public class MobileInfo : ITraitInfo, ITraitPrerequisite { public readonly UnitMovementType MovementType = UnitMovementType.Wheel; public readonly int WaitAverage = 60; public readonly int WaitSpread = 20; - public object Create(Actor self) { return new Mobile(self); } + public object Create(ActorInitializer init) { return new Mobile(init.self); } } public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement diff --git a/OpenRA.Game/Traits/Modifiers/HiddenUnderFog.cs b/OpenRA.Game/Traits/Modifiers/HiddenUnderFog.cs index 908b0fad6b..c8fe9fbb49 100644 --- a/OpenRA.Game/Traits/Modifiers/HiddenUnderFog.cs +++ b/OpenRA.Game/Traits/Modifiers/HiddenUnderFog.cs @@ -24,7 +24,7 @@ namespace OpenRA.Traits { class HiddenUnderFogInfo : ITraitInfo { - public object Create(Actor self) { return new HiddenUnderFog(self); } + public object Create(ActorInitializer init) { return new HiddenUnderFog(init.self); } } class HiddenUnderFog : IRenderModifier diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index be3d505d1e..96db8b2c64 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -10,7 +10,8 @@ namespace OpenRA.Traits public readonly int InitialCash = 10000; public readonly int InitialOre = 0; public readonly int AdviceInterval = 250; - public object Create(Actor self) { return new PlayerResources(self); } + + public object Create(ActorInitializer init) { return new PlayerResources(init.self); } } public class PlayerResources : ITick @@ -19,8 +20,7 @@ namespace OpenRA.Traits int AdviceInterval; public PlayerResources(Actor self) { - var p = self.Owner; - Owner = p; + Owner = self.Owner; Cash = self.Info.Traits.Get().InitialCash; Ore = self.Info.Traits.Get().InitialOre; AdviceInterval = self.Info.Traits.Get().AdviceInterval; diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index 4d02c00fc9..07293d6d6d 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -29,7 +29,7 @@ namespace OpenRA.Traits { public readonly float BuildSpeed = 0.4f; public readonly int LowPowerSlowdown = 3; - public object Create(Actor self) { return new ProductionQueue(self); } + public object Create(ActorInitializer init) { return new ProductionQueue(init.self); } } class ProductionQueue : IResolveOrder, ITick diff --git a/OpenRA.Game/Traits/Production.cs b/OpenRA.Game/Traits/Production.cs index 9ee6a37ec3..37ee83a2f2 100755 --- a/OpenRA.Game/Traits/Production.cs +++ b/OpenRA.Game/Traits/Production.cs @@ -24,20 +24,16 @@ using OpenRA.GameRules; namespace OpenRA.Traits { - public class ProductionInfo : ITraitInfo + public class ProductionInfo : TraitInfo { public readonly int[] SpawnOffset = null; public readonly int[] ProductionOffset = null; public readonly int[] ExitOffset = null; public readonly string[] Produces = { }; - - public virtual object Create(Actor self) { return new Production(self); } } public class Production : IIssueOrder, IResolveOrder, ITags { - public Production( Actor self ) { } - public virtual int2? CreationLocation( Actor self, ActorInfo producee ) { var pos = (1 / 24f * self.CenterLocation).ToInt2(); diff --git a/OpenRA.Game/Traits/RallyPoint.cs b/OpenRA.Game/Traits/RallyPoint.cs index a932ff4122..62ed57b996 100644 --- a/OpenRA.Game/Traits/RallyPoint.cs +++ b/OpenRA.Game/Traits/RallyPoint.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits { public readonly int[] RallyPoint = { 1, 3 }; - public object Create(Actor self) { return new RallyPoint(self); } + public object Create(ActorInitializer init) { return new RallyPoint(init.self); } } public class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick diff --git a/OpenRA.Game/Traits/Render/RenderBuilding.cs b/OpenRA.Game/Traits/Render/RenderBuilding.cs index bad66739ce..ddec9016f6 100644 --- a/OpenRA.Game/Traits/Render/RenderBuilding.cs +++ b/OpenRA.Game/Traits/Render/RenderBuilding.cs @@ -26,7 +26,7 @@ namespace OpenRA.Traits public class RenderBuildingInfo : RenderSimpleInfo { public readonly bool HasMakeAnimation = true; - public override object Create(Actor self) { return new RenderBuilding(self);} + public override object Create(ActorInitializer init) { return new RenderBuilding(init.self);} } public class RenderBuilding : RenderSimple, INotifyDamage, INotifySold diff --git a/OpenRA.Game/Traits/Render/RenderBuildingTurreted.cs b/OpenRA.Game/Traits/Render/RenderBuildingTurreted.cs index f098ae8357..563a977ff3 100644 --- a/OpenRA.Game/Traits/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Game/Traits/Render/RenderBuildingTurreted.cs @@ -22,7 +22,7 @@ namespace OpenRA.Traits { class RenderBuildingTurretedInfo : RenderBuildingInfo { - public override object Create(Actor self) { return new RenderBuildingTurreted(self); } + public override object Create(ActorInitializer init) { return new RenderBuildingTurreted(init.self); } } class RenderBuildingTurreted : RenderBuilding, INotifyBuildComplete diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index f4d4793fa8..809afd64f6 100644 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits { public readonly string Image = null; public readonly string Palette = null; - public abstract object Create(Actor self); + public abstract object Create(ActorInitializer init); } public abstract class RenderSimple : IRender, ITick diff --git a/OpenRA.Game/Traits/Render/RenderUnit.cs b/OpenRA.Game/Traits/Render/RenderUnit.cs index f4c9c23b3a..27bf668003 100644 --- a/OpenRA.Game/Traits/Render/RenderUnit.cs +++ b/OpenRA.Game/Traits/Render/RenderUnit.cs @@ -25,7 +25,7 @@ namespace OpenRA.Traits { public class RenderUnitInfo : RenderSimpleInfo { - public override object Create(Actor self) { return new RenderUnit(self); } + public override object Create(ActorInitializer init) { return new RenderUnit(init.self); } } public class RenderUnit : RenderSimple, INotifyDamage diff --git a/OpenRA.Game/Traits/Render/RenderUnitTurreted.cs b/OpenRA.Game/Traits/Render/RenderUnitTurreted.cs index af7ec971af..a8bff2e084 100644 --- a/OpenRA.Game/Traits/Render/RenderUnitTurreted.cs +++ b/OpenRA.Game/Traits/Render/RenderUnitTurreted.cs @@ -24,7 +24,7 @@ namespace OpenRA.Traits { class RenderUnitTurretedInfo : RenderUnitInfo { - public override object Create(Actor self) { return new RenderUnitTurreted(self); } + public override object Create(ActorInitializer init) { return new RenderUnitTurreted(init.self); } } class RenderUnitTurreted : RenderUnit diff --git a/OpenRA.Game/Traits/StoresOre.cs b/OpenRA.Game/Traits/StoresOre.cs index c2b7c3cb49..7249962622 100644 --- a/OpenRA.Game/Traits/StoresOre.cs +++ b/OpenRA.Game/Traits/StoresOre.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits public readonly PipType PipColor = PipType.Yellow; public readonly int Capacity = 0; public readonly string DeathWeapon = null; - public object Create(Actor self) { return new StoresOre(self, this); } + public object Create(ActorInitializer init) { return new StoresOre(init.self, this); } } class StoresOre : IPips, INotifyCapture, INotifyDamage diff --git a/OpenRA.Game/Traits/SupportPower.cs b/OpenRA.Game/Traits/SupportPower.cs index 8b5aa8c3ea..de2808a1d6 100644 --- a/OpenRA.Game/Traits/SupportPower.cs +++ b/OpenRA.Game/Traits/SupportPower.cs @@ -41,7 +41,7 @@ namespace OpenRA.Traits public readonly string SelectTargetSound = null; public readonly string LaunchSound = null; - public abstract object Create(Actor self); + public abstract object Create(ActorInitializer init); public SupportPowerInfo() { OrderName = GetType().Name + "Order"; } } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 43450a2775..ea32ed9d32 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -108,9 +108,9 @@ namespace OpenRA.Traits public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, ZOffset); } } - public interface ITraitInfo { object Create(Actor self); } + public interface ITraitInfo { object Create(ActorInitializer init); } - public class TraitInfo : ITraitInfo where T : new() { public object Create(Actor self) { return new T(); } } + public class TraitInfo : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } } public interface ITraitPrerequisite { } diff --git a/OpenRA.Game/Traits/TransformsOnDeploy.cs b/OpenRA.Game/Traits/TransformsOnDeploy.cs index 5c1e62edaa..70ed138d92 100644 --- a/OpenRA.Game/Traits/TransformsOnDeploy.cs +++ b/OpenRA.Game/Traits/TransformsOnDeploy.cs @@ -22,7 +22,7 @@ using OpenRA.Traits.Activities; namespace OpenRA.Traits { - class TransformsOnDeployInfo : ITraitInfo + class TransformsOnDeployInfo : TraitInfo { public readonly string TransformsInto = null; public readonly int[] Offset = null; @@ -30,14 +30,10 @@ namespace OpenRA.Traits public readonly bool TransferHealthPercentage = true; // Set to false to transfer the absolute health public readonly string[] TransformSounds = null; public readonly string[] NoTransformSounds = null; - - public object Create(Actor self) { return new TransformsOnDeploy(self); } } class TransformsOnDeploy : IIssueOrder, IResolveOrder { - public TransformsOnDeploy(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button == MouseButton.Right && self == underCursor) diff --git a/OpenRA.Game/Traits/Turreted.cs b/OpenRA.Game/Traits/Turreted.cs index 18528a316b..a568cd382e 100644 --- a/OpenRA.Game/Traits/Turreted.cs +++ b/OpenRA.Game/Traits/Turreted.cs @@ -25,7 +25,7 @@ namespace OpenRA.Traits public readonly int ROT = 255; public readonly int InitialFacing = 128; - public object Create(Actor self) { return new Turreted(self); } + public object Create(ActorInitializer init) { return new Turreted(init.self); } } public class Turreted : ITick diff --git a/OpenRA.Game/Traits/Unit.cs b/OpenRA.Game/Traits/Unit.cs index 7da4a09529..01584f3fcf 100755 --- a/OpenRA.Game/Traits/Unit.cs +++ b/OpenRA.Game/Traits/Unit.cs @@ -26,7 +26,7 @@ namespace OpenRA.Traits public readonly int ROT = 255; public readonly int Speed = 1; - public object Create( Actor self ) { return new Unit( self ); } + public object Create( ActorInitializer init ) { return new Unit( init.self ); } } public class Unit : INotifyDamage diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index 1b5594c85e..b774e4743c 100644 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -30,7 +30,7 @@ namespace OpenRA.Traits { public readonly string[] BibTypes = {"bib3", "bib2", "bib1"}; public readonly int[] BibWidths = {2,3,4}; - public object Create(Actor self) { return new BibLayer(self, this); } + public object Create(ActorInitializer init) { return new BibLayer(init.self, this); } } class BibLayer: IRenderOverlay, ILoadWorldHook diff --git a/OpenRA.Game/Traits/World/BuildingInfluence.cs b/OpenRA.Game/Traits/World/BuildingInfluence.cs index 45262fc981..21e7c28c55 100644 --- a/OpenRA.Game/Traits/World/BuildingInfluence.cs +++ b/OpenRA.Game/Traits/World/BuildingInfluence.cs @@ -25,7 +25,7 @@ namespace OpenRA.Traits { public class BuildingInfluenceInfo : ITraitInfo { - public object Create( Actor self ) { return new BuildingInfluence( self ); } + public object Create( ActorInitializer init ) { return new BuildingInfluence( init.world ); } } public class BuildingInfluence @@ -34,17 +34,17 @@ namespace OpenRA.Traits Actor[,] influence; Map map; - public BuildingInfluence( Actor self ) + public BuildingInfluence( World world ) { - map = self.World.Map; + map = world.Map; blocked = new bool[map.MapSize.X, map.MapSize.Y]; influence = new Actor[map.MapSize.X, map.MapSize.Y]; - self.World.ActorAdded += + world.ActorAdded += a => { if (a.traits.Contains()) ChangeInfluence(a, a.traits.Get(), true); }; - self.World.ActorRemoved += + world.ActorRemoved += a => { if (a.traits.Contains()) ChangeInfluence(a, a.traits.Get(), false); }; } diff --git a/OpenRA.Game/Traits/World/Country.cs b/OpenRA.Game/Traits/World/Country.cs index 5a3aa95855..e917bee0b6 100644 --- a/OpenRA.Game/Traits/World/Country.cs +++ b/OpenRA.Game/Traits/World/Country.cs @@ -20,15 +20,13 @@ namespace OpenRA.Traits { - public class CountryInfo : ITraitInfo + public class CountryInfo : TraitInfo { public readonly string Name = null; public readonly string Race = null; /* todo: icon,... */ - - public object Create(Actor self) { return new CountryInfo(); } } - class Country { /* we're only interested in the Info */ } + public class Country { /* we're only interested in the Info */ } } diff --git a/OpenRA.Game/Traits/World/PlayerColorPalette.cs b/OpenRA.Game/Traits/World/PlayerColorPalette.cs index 0a14850066..57babb8b46 100644 --- a/OpenRA.Game/Traits/World/PlayerColorPalette.cs +++ b/OpenRA.Game/Traits/World/PlayerColorPalette.cs @@ -36,16 +36,16 @@ namespace OpenRA.Traits public readonly int[] DisplayColor = null; public readonly bool Playable = true; - public object Create(Actor self) { return new PlayerColorPalette(self, this); } + public object Create(ActorInitializer init) { return new PlayerColorPalette(init.world, this); } public Color Color { get { return Util.ArrayToColor(DisplayColor); } } } public class PlayerColorPalette { - public PlayerColorPalette(Actor self, PlayerColorPaletteInfo info) + public PlayerColorPalette(World world, PlayerColorPaletteInfo info) { - var wr = self.World.WorldRenderer; + var wr = world.WorldRenderer; var pal = wr.GetPalette(info.BasePalette); var newpal = new Palette(pal, new PlayerColorRemap( Util.ArrayToColor(info.Color1), diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 7049d627be..e6e92bcc28 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -26,10 +26,7 @@ using System.Drawing; namespace OpenRA.Traits { - public class ResourceLayerInfo : ITraitInfo - { - public object Create(Actor self) { return new ResourceLayer(self); } - } + public class ResourceLayerInfo : TraitInfo { } public class ResourceLayer: IRenderOverlay, ILoadWorldHook, ICustomTerrain { @@ -39,7 +36,7 @@ namespace OpenRA.Traits public ResourceType[] resourceTypes; CellContents[,] content; - public ResourceLayer(Actor self) + public ResourceLayer() { sr = Game.renderer.SpriteRenderer; } diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 95a072eb81..9922334491 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -38,7 +38,7 @@ namespace OpenRA.Traits public Sprite[][] Sprites; - public object Create(Actor self) { return new ResourceType(this); } + public object Create(ActorInitializer init) { return new ResourceType(this); } } public class ResourceType diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index f4db3d71fc..e16b862ba2 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -24,10 +24,7 @@ using System.Linq; namespace OpenRA.Traits { - class ScreenShakerInfo : ITraitInfo - { - public object Create( Actor self ) { return new ScreenShaker(); } - } + class ScreenShakerInfo : TraitInfo {} public class ScreenShaker : ITick { diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 88f0ead866..dd3e332372 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -29,7 +29,7 @@ namespace OpenRA.Traits { public class ShroudInfo : ITraitInfo { - public object Create(Actor self) { return new Shroud(self); } + public object Create(ActorInitializer init) { return new Shroud(init.world); } } public class Shroud @@ -41,14 +41,14 @@ namespace OpenRA.Traits public Rectangle? exploredBounds; public event Action Dirty = () => { }; - public Shroud(Actor self) + public Shroud(World world) { - map = self.World.Map; + map = world.Map; visibleCells = new int[map.MapSize.X, map.MapSize.Y]; exploredCells = new bool[map.MapSize.X, map.MapSize.Y]; - self.World.ActorAdded += AddActor; - self.World.ActorRemoved += RemoveActor; + world.ActorAdded += AddActor; + world.ActorRemoved += RemoveActor; } // cache of positions that were added, so no matter what crazy trait code does, it diff --git a/OpenRA.Game/Traits/World/SmudgeLayer.cs b/OpenRA.Game/Traits/World/SmudgeLayer.cs index d65ee19dfc..12bd70105d 100644 --- a/OpenRA.Game/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Game/Traits/World/SmudgeLayer.cs @@ -31,7 +31,7 @@ namespace OpenRA.Traits public readonly string Type = "Scorch"; public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"}; public readonly int[] Depths = {1,1,1,1,1,1}; - public object Create(Actor self) { return new SmudgeLayer(self, this); } + public object Create(ActorInitializer init) { return new SmudgeLayer(this); } } class SmudgeLayer: IRenderOverlay, ILoadWorldHook @@ -42,7 +42,7 @@ namespace OpenRA.Traits Sprite[][] smudgeSprites; World world; - public SmudgeLayer(Actor self, SmudgeLayerInfo info) + public SmudgeLayer(SmudgeLayerInfo info) { spriteRenderer = Game.renderer.SpriteRenderer; this.Info = info; diff --git a/OpenRA.Game/Traits/World/SpatialBins.cs b/OpenRA.Game/Traits/World/SpatialBins.cs index a9fcd3cba3..6c51ed07f7 100644 --- a/OpenRA.Game/Traits/World/SpatialBins.cs +++ b/OpenRA.Game/Traits/World/SpatialBins.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits class SpatialBinsInfo : ITraitInfo { public readonly int BinSize = 8; - public object Create(Actor self) { return new SpatialBins( self, this ); } + public object Create(ActorInitializer init) { return new SpatialBins( init.self, this ); } } class SpatialBins : ITick diff --git a/OpenRA.Game/Traits/World/UnitInfluence.cs b/OpenRA.Game/Traits/World/UnitInfluence.cs index d5f0323c7e..1e0c3c0f55 100644 --- a/OpenRA.Game/Traits/World/UnitInfluence.cs +++ b/OpenRA.Game/Traits/World/UnitInfluence.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits { public class UnitInfluenceInfo : ITraitInfo { - public object Create( Actor self ) { return new UnitInfluence( self ); } + public object Create( ActorInitializer init ) { return new UnitInfluence( init.world ); } } public class UnitInfluence : ITick @@ -36,15 +36,15 @@ namespace OpenRA.Traits List[,] influence; Map map; - public UnitInfluence( Actor self ) + public UnitInfluence( World world ) { - map = self.World.Map; - influence = new List[self.World.Map.MapSize.X, self.World.Map.MapSize.Y]; - for (int i = 0; i < self.World.Map.MapSize.X; i++) - for (int j = 0; j < self.World.Map.MapSize.Y; j++) + map = world.Map; + influence = new List[world.Map.MapSize.X, world.Map.MapSize.Y]; + for (int i = 0; i < world.Map.MapSize.X; i++) + for (int j = 0; j < world.Map.MapSize.Y; j++) influence[ i, j ] = new List(); - self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault() ); + world.ActorRemoved += a => Remove( a, a.traits.GetOrDefault() ); } public void Tick( Actor self ) diff --git a/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs b/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs index 7778cc0b4b..6bbfd85702 100644 --- a/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs +++ b/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs @@ -27,10 +27,9 @@ using OpenRA.Mods.RA; namespace OpenRA.Mods.Aftermath { - class ChronoshiftDeployInfo : ITraitInfo + class ChronoshiftDeployInfo : TraitInfo { public readonly int ChargeTime = 120; // Seconds - public object Create(Actor self) { return new ChronoshiftDeploy(self); } } class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ITick, IPips @@ -39,8 +38,6 @@ namespace OpenRA.Mods.Aftermath [Sync] int chargeTick = 0; // How long until we can chronoshift again? - public ChronoshiftDeploy(Actor self) { } - public void Tick(Actor self) { if (chargeTick > 0) diff --git a/OpenRA.Mods.Aftermath/DemoTruck.cs b/OpenRA.Mods.Aftermath/DemoTruck.cs index b830667680..e51fcedc12 100644 --- a/OpenRA.Mods.Aftermath/DemoTruck.cs +++ b/OpenRA.Mods.Aftermath/DemoTruck.cs @@ -23,15 +23,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.Aftermath { - class DemoTruckInfo : ITraitInfo - { - public object Create(Actor self) { return new DemoTruck(self); } - } + class DemoTruckInfo : TraitInfo { } class DemoTruck : Chronoshiftable, INotifyDamage { - public DemoTruck(Actor self) : base(self) { } - // Explode on chronoshift public override bool Activate(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) { diff --git a/OpenRA.Mods.Cnc/CriticalBuildingState.cs b/OpenRA.Mods.Cnc/CriticalBuildingState.cs index bb9783c7d1..1a3ef6505b 100644 --- a/OpenRA.Mods.Cnc/CriticalBuildingState.cs +++ b/OpenRA.Mods.Cnc/CriticalBuildingState.cs @@ -10,7 +10,7 @@ namespace OpenRA.Mods.Cnc class CriticalBuildingStateInfo : ITraitInfo { public readonly int LingerTime = 20; - public object Create(Actor self) { return new CriticalBuildingState(self, this); } + public object Create(ActorInitializer init) { return new CriticalBuildingState(init.self, this); } } class CriticalBuildingState : INotifyDamage diff --git a/OpenRA.Mods.Cnc/IonCannonPower.cs b/OpenRA.Mods.Cnc/IonCannonPower.cs index 0b4cdf2ed7..184b0824b2 100644 --- a/OpenRA.Mods.Cnc/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/IonCannonPower.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc { class IonCannonPowerInfo : SupportPowerInfo { - public override object Create(Actor self) { return new IonCannonPower(self, this); } + public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); } } class IonCannonPower : SupportPower, IResolveOrder diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index 3f37f630ef..79e843884f 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc public readonly string Weapon = "Tiberium"; public readonly string[] Resources = { "Tiberium" }; - public object Create(Actor self) { return new PoisonedByTiberium(this); } + public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } } class PoisonedByTiberium : ITick diff --git a/OpenRA.Mods.Cnc/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/ProductionAirdrop.cs index e6cedb8c23..9b3e1d9cf8 100644 --- a/OpenRA.Mods.Cnc/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/ProductionAirdrop.cs @@ -28,13 +28,11 @@ namespace OpenRA.Mods.Cnc { public class ProductionAirdropInfo : ProductionInfo { - public override object Create(Actor self) { return new ProductionAirdrop(self); } + public override object Create(ActorInitializer init) { return new ProductionAirdrop(); } } class ProductionAirdrop : Production { - public ProductionAirdrop(Actor self) : base(self) { } - public override bool Produce( Actor self, ActorInfo producee ) { var owner = self.Owner; diff --git a/OpenRA.Mods.RA/AirstrikePower.cs b/OpenRA.Mods.RA/AirstrikePower.cs index 38a7534292..173b2753ef 100644 --- a/OpenRA.Mods.RA/AirstrikePower.cs +++ b/OpenRA.Mods.RA/AirstrikePower.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackHeli.cs b/OpenRA.Mods.RA/AttackHeli.cs index f270dbc544..5c3d52681b 100644 --- a/OpenRA.Mods.RA/AttackHeli.cs +++ b/OpenRA.Mods.RA/AttackHeli.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackLeap.cs b/OpenRA.Mods.RA/AttackLeap.cs index d011d59342..241aa4ddc7 100644 --- a/OpenRA.Mods.RA/AttackLeap.cs +++ b/OpenRA.Mods.RA/AttackLeap.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackOmni.cs b/OpenRA.Mods.RA/AttackOmni.cs index d2885b742c..2b6ad1c039 100644 --- a/OpenRA.Mods.RA/AttackOmni.cs +++ b/OpenRA.Mods.RA/AttackOmni.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackPlane.cs b/OpenRA.Mods.RA/AttackPlane.cs index e592504414..f998707530 100644 --- a/OpenRA.Mods.RA/AttackPlane.cs +++ b/OpenRA.Mods.RA/AttackPlane.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackTesla.cs b/OpenRA.Mods.RA/AttackTesla.cs index b89148d51e..3772813b59 100644 --- a/OpenRA.Mods.RA/AttackTesla.cs +++ b/OpenRA.Mods.RA/AttackTesla.cs @@ -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 diff --git a/OpenRA.Mods.RA/AttackTurreted.cs b/OpenRA.Mods.RA/AttackTurreted.cs index 40000b4d38..0c32eee07d 100644 --- a/OpenRA.Mods.RA/AttackTurreted.cs +++ b/OpenRA.Mods.RA/AttackTurreted.cs @@ -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 diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index 2c18f9d83e..9f2f885076 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -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 diff --git a/OpenRA.Mods.RA/C4Demolition.cs b/OpenRA.Mods.RA/C4Demolition.cs index 0be8ab91ca..410593a66c 100644 --- a/OpenRA.Mods.RA/C4Demolition.cs +++ b/OpenRA.Mods.RA/C4Demolition.cs @@ -24,16 +24,13 @@ using OpenRA.Traits.Activities; namespace OpenRA.Mods.RA { - class C4DemolitionInfo : ITraitInfo + class C4DemolitionInfo : TraitInfo { 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; diff --git a/OpenRA.Mods.RA/CanPowerDown.cs b/OpenRA.Mods.RA/CanPowerDown.cs index 03fc004a0e..ee1126d8ef 100755 --- a/OpenRA.Mods.RA/CanPowerDown.cs +++ b/OpenRA.Mods.RA/CanPowerDown.cs @@ -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 { } public class CanPowerDown : IDisable, IPowerModifier, IResolveOrder { diff --git a/OpenRA.Mods.RA/Cargo.cs b/OpenRA.Mods.RA/Cargo.cs index 174f6aaa5d..0c0af8af32 100644 --- a/OpenRA.Mods.RA/Cargo.cs +++ b/OpenRA.Mods.RA/Cargo.cs @@ -25,21 +25,17 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class CargoInfo : ITraitInfo + public class CargoInfo : TraitInfo { 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 cargo = new List(); - 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 diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs index 7e3a42fc9b..399fa8caa8 100644 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ b/OpenRA.Mods.RA/CarpetBomb.cs @@ -23,12 +23,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class CarpetBombInfo : ITraitInfo + class CarpetBombInfo : TraitInfo { 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) diff --git a/OpenRA.Mods.RA/Chrome/PowerDownButton.cs b/OpenRA.Mods.RA/Chrome/PowerDownButton.cs index 14abf497ea..993e48fc44 100755 --- a/OpenRA.Mods.RA/Chrome/PowerDownButton.cs +++ b/OpenRA.Mods.RA/Chrome/PowerDownButton.cs @@ -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 diff --git a/OpenRA.Mods.RA/ChronoshiftPower.cs b/OpenRA.Mods.RA/ChronoshiftPower.cs index b8c62dad16..d2e5fac483 100644 --- a/OpenRA.Mods.RA/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/ChronoshiftPower.cs @@ -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 diff --git a/OpenRA.Mods.RA/Chronoshiftable.cs b/OpenRA.Mods.RA/Chronoshiftable.cs index d5bf028aa8..65eafbc1bd 100755 --- a/OpenRA.Mods.RA/Chronoshiftable.cs +++ b/OpenRA.Mods.RA/Chronoshiftable.cs @@ -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 { } 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) diff --git a/OpenRA.Mods.RA/ConquestVictoryConditions.cs b/OpenRA.Mods.RA/ConquestVictoryConditions.cs index ed86c7d536..eeb001a792 100644 --- a/OpenRA.Mods.RA/ConquestVictoryConditions.cs +++ b/OpenRA.Mods.RA/ConquestVictoryConditions.cs @@ -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 { } 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] diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index ab7de582e8..de39f8eb03 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA class CrateInfo : ITraitInfo, ITraitPrerequisite { 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 diff --git a/OpenRA.Mods.RA/CrateAction.cs b/OpenRA.Mods.RA/CrateAction.cs index b311743f64..7ab18063a3 100644 --- a/OpenRA.Mods.RA/CrateAction.cs +++ b/OpenRA.Mods.RA/CrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs index eddf9f94e3..546cc206f9 100644 --- a/OpenRA.Mods.RA/CrateSpawner.cs +++ b/OpenRA.Mods.RA/CrateSpawner.cs @@ -24,14 +24,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class CrateSpawnerInfo : ITraitInfo + class CrateSpawnerInfo : TraitInfo { 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. diff --git a/OpenRA.Mods.RA/Crates/ArmorUpgradeCrateAction.cs b/OpenRA.Mods.RA/Crates/ArmorUpgradeCrateAction.cs index b07b63647f..b8c4a77528 100644 --- a/OpenRA.Mods.RA/Crates/ArmorUpgradeCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/ArmorUpgradeCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs b/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs index 43b67dfbea..1b3250341f 100644 --- a/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/ExplodeCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/FirepowerUpgradeCrateAction.cs b/OpenRA.Mods.RA/Crates/FirepowerUpgradeCrateAction.cs index 208d054dc9..d5b3288eca 100644 --- a/OpenRA.Mods.RA/Crates/FirepowerUpgradeCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/FirepowerUpgradeCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs index b9408730c2..8e68f86476 100644 --- a/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs b/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs index cb484d993d..fe1856cdae 100644 --- a/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/SpeedUpgradeCrateAction.cs b/OpenRA.Mods.RA/Crates/SpeedUpgradeCrateAction.cs index 3eec26110c..c6237f8d8d 100644 --- a/OpenRA.Mods.RA/Crates/SpeedUpgradeCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/SpeedUpgradeCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs index cf64b2355b..969cc50cfd 100644 --- a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs @@ -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 diff --git a/OpenRA.Mods.RA/DefaultShellmapScript.cs b/OpenRA.Mods.RA/DefaultShellmapScript.cs index 53963d6246..e8903c2d9e 100644 --- a/OpenRA.Mods.RA/DefaultShellmapScript.cs +++ b/OpenRA.Mods.RA/DefaultShellmapScript.cs @@ -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 { } class DefaultShellmapScript: ILoadWorldHook, ITick { diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs index a48ff09715..1a9e89600f 100644 --- a/OpenRA.Mods.RA/GainsExperience.cs +++ b/OpenRA.Mods.RA/GainsExperience.cs @@ -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 diff --git a/OpenRA.Mods.RA/GpsPower.cs b/OpenRA.Mods.RA/GpsPower.cs index 59f656f44a..d56e6bf153 100644 --- a/OpenRA.Mods.RA/GpsPower.cs +++ b/OpenRA.Mods.RA/GpsPower.cs @@ -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 diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 348097eee1..be7ba0bbc5 100755 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -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 diff --git a/OpenRA.Mods.RA/HasUnitOnBuild.cs b/OpenRA.Mods.RA/HasUnitOnBuild.cs index 642d845813..c309d4dc5d 100644 --- a/OpenRA.Mods.RA/HasUnitOnBuild.cs +++ b/OpenRA.Mods.RA/HasUnitOnBuild.cs @@ -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 diff --git a/OpenRA.Mods.RA/Helicopter.cs b/OpenRA.Mods.RA/Helicopter.cs index 82fdcf1f54..d44b3c3092 100644 --- a/OpenRA.Mods.RA/Helicopter.cs +++ b/OpenRA.Mods.RA/Helicopter.cs @@ -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 diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index e662452186..d3ab58c686 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -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 { diff --git a/OpenRA.Mods.RA/IronCurtainPower.cs b/OpenRA.Mods.RA/IronCurtainPower.cs index 9bab23b682..b077699c19 100644 --- a/OpenRA.Mods.RA/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/IronCurtainPower.cs @@ -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 diff --git a/OpenRA.Mods.RA/IronCurtainable.cs b/OpenRA.Mods.RA/IronCurtainable.cs index 705b08b7ef..d609749942 100644 --- a/OpenRA.Mods.RA/IronCurtainable.cs +++ b/OpenRA.Mods.RA/IronCurtainable.cs @@ -24,7 +24,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class IronCurtainableInfo : TraitInfo {} + class IronCurtainableInfo : TraitInfo { } class IronCurtainable : IDamageModifier, ITick { diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index 5902730945..bd3b43b11c 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -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 diff --git a/OpenRA.Mods.RA/NukePower.cs b/OpenRA.Mods.RA/NukePower.cs index 90e11214c3..4867352982 100644 --- a/OpenRA.Mods.RA/NukePower.cs +++ b/OpenRA.Mods.RA/NukePower.cs @@ -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 diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 5ef1830f78..509d8e7ab7 100755 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -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 diff --git a/OpenRA.Mods.RA/PaletteFromFile.cs b/OpenRA.Mods.RA/PaletteFromFile.cs index 625e0a0a10..af329b05b8 100644 --- a/OpenRA.Mods.RA/PaletteFromFile.cs +++ b/OpenRA.Mods.RA/PaletteFromFile.cs @@ -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)); } } diff --git a/OpenRA.Mods.RA/PaletteFromRGBA.cs b/OpenRA.Mods.RA/PaletteFromRGBA.cs index fdb1b79142..219f088d6c 100644 --- a/OpenRA.Mods.RA/PaletteFromRGBA.cs +++ b/OpenRA.Mods.RA/PaletteFromRGBA.cs @@ -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)))); } diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index cb7e6c4280..438cf85aef 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -27,10 +27,9 @@ using OpenRA.Traits.Activities; namespace OpenRA.Mods.RA { - public class ParaDropInfo : ITraitInfo + public class ParaDropInfo : TraitInfo { public readonly int LZRange = 4; - public object Create(Actor self) { return new ParaDrop(); } } public class ParaDrop : ITick diff --git a/OpenRA.Mods.RA/ParatroopersPower.cs b/OpenRA.Mods.RA/ParatroopersPower.cs index 99dbc3e10b..39053d7cbd 100644 --- a/OpenRA.Mods.RA/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/ParatroopersPower.cs @@ -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 diff --git a/OpenRA.Mods.RA/Plane.cs b/OpenRA.Mods.RA/Plane.cs index 379bd9a470..2c5d3030df 100644 --- a/OpenRA.Mods.RA/Plane.cs +++ b/OpenRA.Mods.RA/Plane.cs @@ -27,21 +27,17 @@ using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.RA { - public class PlaneInfo : ITraitInfo + public class PlaneInfo : TraitInfo { 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(); diff --git a/OpenRA.Mods.RA/ProductionSurround.cs b/OpenRA.Mods.RA/ProductionSurround.cs index e85a081395..a162dc7002 100644 --- a/OpenRA.Mods.RA/ProductionSurround.cs +++ b/OpenRA.Mods.RA/ProductionSurround.cs @@ -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); diff --git a/OpenRA.Mods.RA/RenderBuildingCharge.cs b/OpenRA.Mods.RA/RenderBuildingCharge.cs index 2d7fb585e6..e747a07dd2 100644 --- a/OpenRA.Mods.RA/RenderBuildingCharge.cs +++ b/OpenRA.Mods.RA/RenderBuildingCharge.cs @@ -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 */ diff --git a/OpenRA.Mods.RA/RenderBuildingOre.cs b/OpenRA.Mods.RA/RenderBuildingOre.cs index 002c42163c..267f0c3190 100644 --- a/OpenRA.Mods.RA/RenderBuildingOre.cs +++ b/OpenRA.Mods.RA/RenderBuildingOre.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderBuildingWall.cs b/OpenRA.Mods.RA/RenderBuildingWall.cs index 04db0e5fd4..295bce182a 100644 --- a/OpenRA.Mods.RA/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/RenderBuildingWall.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderBuildingWarFactory.cs b/OpenRA.Mods.RA/RenderBuildingWarFactory.cs index 672c840e97..3934f0ea0c 100644 --- a/OpenRA.Mods.RA/RenderBuildingWarFactory.cs +++ b/OpenRA.Mods.RA/RenderBuildingWarFactory.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA { class RenderWarFactoryInfo : ITraitInfo, ITraitPrerequisite { - 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 diff --git a/OpenRA.Mods.RA/RenderFlare.cs b/OpenRA.Mods.RA/RenderFlare.cs index b8c0ea410d..816f71b0d4 100644 --- a/OpenRA.Mods.RA/RenderFlare.cs +++ b/OpenRA.Mods.RA/RenderFlare.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderInfantry.cs b/OpenRA.Mods.RA/RenderInfantry.cs index 87e3690638..8631c22385 100644 --- a/OpenRA.Mods.RA/RenderInfantry.cs +++ b/OpenRA.Mods.RA/RenderInfantry.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderSpy.cs b/OpenRA.Mods.RA/RenderSpy.cs index 2def8fc9b1..f15a28c239 100644 --- a/OpenRA.Mods.RA/RenderSpy.cs +++ b/OpenRA.Mods.RA/RenderSpy.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderUnitReload.cs b/OpenRA.Mods.RA/RenderUnitReload.cs index 3190183e43..5dc5042b79 100644 --- a/OpenRA.Mods.RA/RenderUnitReload.cs +++ b/OpenRA.Mods.RA/RenderUnitReload.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderUnitRotor.cs b/OpenRA.Mods.RA/RenderUnitRotor.cs index 3c81870ba7..64975d93e4 100644 --- a/OpenRA.Mods.RA/RenderUnitRotor.cs +++ b/OpenRA.Mods.RA/RenderUnitRotor.cs @@ -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 diff --git a/OpenRA.Mods.RA/RenderUnitSpinner.cs b/OpenRA.Mods.RA/RenderUnitSpinner.cs index 43f03fa51a..17a34fa08a 100644 --- a/OpenRA.Mods.RA/RenderUnitSpinner.cs +++ b/OpenRA.Mods.RA/RenderUnitSpinner.cs @@ -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 diff --git a/OpenRA.Mods.RA/ReplaceWithActor.cs b/OpenRA.Mods.RA/ReplaceWithActor.cs index 26e65dbe6c..e5c931d036 100644 --- a/OpenRA.Mods.RA/ReplaceWithActor.cs +++ b/OpenRA.Mods.RA/ReplaceWithActor.cs @@ -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 diff --git a/OpenRA.Mods.RA/RequiresPower.cs b/OpenRA.Mods.RA/RequiresPower.cs index 3014977e75..a9fb2f715b 100644 --- a/OpenRA.Mods.RA/RequiresPower.cs +++ b/OpenRA.Mods.RA/RequiresPower.cs @@ -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 diff --git a/OpenRA.Mods.RA/Reservable.cs b/OpenRA.Mods.RA/Reservable.cs index f2dc93273b..1fe2158096 100644 --- a/OpenRA.Mods.RA/Reservable.cs +++ b/OpenRA.Mods.RA/Reservable.cs @@ -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 { } public class Reservable : ITick { - public Reservable(Actor self) { } Actor reservedFor; public void Tick(Actor self) diff --git a/OpenRA.Mods.RA/SeedsResource.cs b/OpenRA.Mods.RA/SeedsResource.cs index 5c5c1493b1..bb891776da 100644 --- a/OpenRA.Mods.RA/SeedsResource.cs +++ b/OpenRA.Mods.RA/SeedsResource.cs @@ -25,14 +25,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class SeedsResourceInfo : ITraitInfo + class SeedsResourceInfo : TraitInfo { 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 diff --git a/OpenRA.Mods.RA/SelfHealing.cs b/OpenRA.Mods.RA/SelfHealing.cs index 1843e9ce93..083cdd4705 100644 --- a/OpenRA.Mods.RA/SelfHealing.cs +++ b/OpenRA.Mods.RA/SelfHealing.cs @@ -22,13 +22,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class SelfHealingInfo : ITraitInfo + class SelfHealingInfo : TraitInfo { 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 diff --git a/OpenRA.Mods.RA/ShroudPalette.cs b/OpenRA.Mods.RA/ShroudPalette.cs index 4fb32258db..f035a04588 100644 --- a/OpenRA.Mods.RA/ShroudPalette.cs +++ b/OpenRA.Mods.RA/ShroudPalette.cs @@ -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))); } diff --git a/OpenRA.Mods.RA/SonarPulsePower.cs b/OpenRA.Mods.RA/SonarPulsePower.cs index be0e3c7eae..2343bb97f8 100644 --- a/OpenRA.Mods.RA/SonarPulsePower.cs +++ b/OpenRA.Mods.RA/SonarPulsePower.cs @@ -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 diff --git a/OpenRA.Mods.RA/SpyPlanePower.cs b/OpenRA.Mods.RA/SpyPlanePower.cs index 1783594217..732edf68a7 100644 --- a/OpenRA.Mods.RA/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SpyPlanePower.cs @@ -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 diff --git a/OpenRA.Mods.RA/TakeCover.cs b/OpenRA.Mods.RA/TakeCover.cs index 659bd5be12..a61989e402 100644 --- a/OpenRA.Mods.RA/TakeCover.cs +++ b/OpenRA.Mods.RA/TakeCover.cs @@ -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 { } // 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` */ diff --git a/OpenRA.Mods.RA/ThrowsParticles.cs b/OpenRA.Mods.RA/ThrowsParticles.cs index 4c46148323..e8e1e6784d 100644 --- a/OpenRA.Mods.RA/ThrowsParticles.cs +++ b/OpenRA.Mods.RA/ThrowsParticles.cs @@ -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) diff --git a/OpenRA.Mods.RA/Wall.cs b/OpenRA.Mods.RA/Wall.cs index 2be644b5e3..d59c07cbef 100644 --- a/OpenRA.Mods.RA/Wall.cs +++ b/OpenRA.Mods.RA/Wall.cs @@ -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 diff --git a/OpenRA.Mods.RA/WithMuzzleFlash.cs b/OpenRA.Mods.RA/WithMuzzleFlash.cs index df81e9ed08..23ddb79fa7 100644 --- a/OpenRA.Mods.RA/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/WithMuzzleFlash.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA { class WithMuzzleFlashInfo : ITraitInfo, ITraitPrerequisite { - public object Create(Actor self) { return new WithMuzzleFlash(self); } + public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); } } class WithMuzzleFlash : INotifyAttack