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