using StatelessTraitInfo<> for some things
This commit is contained in:
@@ -198,7 +198,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
var hasRadar = Game.world.Actors.Any(a => a.Owner == Game.LocalPlayer
|
||||
&& a.traits.Contains<ProvidesRadar>()
|
||||
&& a.traits.Get<ProvidesRadar>().IsActive());
|
||||
&& a.traits.Get<ProvidesRadar>().IsActive(a));
|
||||
|
||||
if (hasRadar != hadRadar)
|
||||
Sound.Play((hasRadar) ? "radaron2.aud" : "radardn1.aud");
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class PassengerInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Passenger(self); }
|
||||
}
|
||||
class PassengerInfo : StatelessTraitInfo<Passenger> {}
|
||||
|
||||
class Passenger : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Passenger(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right)
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using OpenRa.Game.GameRules;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ProvidesRadarInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new ProvidesRadar(self); }
|
||||
}
|
||||
class ProvidesRadarInfo : StatelessTraitInfo<ProvidesRadar> {}
|
||||
|
||||
class ProvidesRadar
|
||||
{
|
||||
Actor self;
|
||||
public ProvidesRadar(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public bool IsActive()
|
||||
public bool IsActive(Actor self)
|
||||
{
|
||||
// TODO: Check for nearby MRJ
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderBuildingChargeInfo : RenderBuildingInfo
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderBuildingOreInfo : RenderBuildingInfo
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Effects;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using IjwFramework.Collections;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
|
||||
@@ -10,14 +10,12 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
class RenderUnitSpinner : RenderUnit
|
||||
{
|
||||
public Animation spinnerAnim;
|
||||
|
||||
public RenderUnitSpinner( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
spinnerAnim = new Animation( self.Info.Name );
|
||||
var spinnerAnim = new Animation( self.Info.Name );
|
||||
spinnerAnim.PlayRepeating( "spinner" );
|
||||
anims.Add( "spinner", new AnimationWithOffset(
|
||||
spinnerAnim,
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
class RenderUnitTurreted : RenderUnit
|
||||
{
|
||||
public Animation muzzleFlash;
|
||||
|
||||
public RenderUnitTurreted(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
@@ -37,7 +35,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
if( self.Info.MuzzleFlash )
|
||||
{
|
||||
muzzleFlash = new Animation( self.Info.Name );
|
||||
var muzzleFlash = new Animation( self.Info.Name );
|
||||
muzzleFlash.PlayFetchIndex( "muzzle",
|
||||
() => ( Util.QuantizeFacing( self.traits.Get<Turreted>().turretFacing, 8 ) ) * 6
|
||||
+ (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class SeedsOreInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new SeedsOre(self); }
|
||||
}
|
||||
class SeedsOreInfo : StatelessTraitInfo<SeedsOre> {}
|
||||
|
||||
class SeedsOre : ITick
|
||||
{
|
||||
public SeedsOre( Actor self ) {}
|
||||
|
||||
const double OreSeedProbability = .05; // todo: push this out into rules
|
||||
|
||||
public void Tick(Actor self)
|
||||
|
||||
@@ -5,17 +5,12 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class SelectableInfo : ITraitInfo
|
||||
class SelectableInfo : StatelessTraitInfo<Selectable>
|
||||
{
|
||||
public readonly int Priority = 10;
|
||||
public readonly int[] Bounds = null;
|
||||
public readonly string Voice = "GenericVoice";
|
||||
|
||||
public object Create(Actor self) { return new Selectable(self); }
|
||||
}
|
||||
|
||||
class Selectable
|
||||
{
|
||||
public Selectable( Actor self ) { }
|
||||
}
|
||||
class Selectable {}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,14 @@ using System;
|
||||
using OpenRa.Game.GameRules;
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class StoresOreInfo : ITraitInfo
|
||||
class StoresOreInfo : StatelessTraitInfo<StoresOre>
|
||||
{
|
||||
public readonly int Pips = 0;
|
||||
public readonly int Capacity = 0;
|
||||
|
||||
public object Create(Actor self) { return new StoresOre(self); }
|
||||
}
|
||||
|
||||
class StoresOre : IPips, IAcceptThief
|
||||
{
|
||||
public StoresOre(Actor self) {}
|
||||
|
||||
public void OnSteal(Actor self, Actor thief)
|
||||
{
|
||||
// Steal half the ore the building holds
|
||||
|
||||
@@ -3,15 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ThiefInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Thief(self); }
|
||||
}
|
||||
class ThiefInfo : StatelessTraitInfo<Thief> { }
|
||||
|
||||
class Thief : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Thief(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
|
||||
@@ -6,15 +6,10 @@ using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class WithShadowInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new WithShadow(self); }
|
||||
}
|
||||
class WithShadowInfo : StatelessTraitInfo<WithShadow> {}
|
||||
|
||||
class WithShadow : IRenderModifier
|
||||
{
|
||||
public WithShadow(Actor self) {}
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
Reference in New Issue
Block a user