Crates: Part 2
This commit is contained in:
46
OpenRa.Mods.RA/Crate Actions/SpeedUpgrade.cs
Normal file
46
OpenRa.Mods.RA/Crate Actions/SpeedUpgrade.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class SpeedUpgradeCrateActionInfo : ITraitInfo
|
||||
{
|
||||
public float Multiplier = 1.7f;
|
||||
public int SelectionShares = 10;
|
||||
public object Create(Actor self) { return new SpeedUpgradeCrateAction(self); }
|
||||
}
|
||||
class SpeedUpgradeCrateAction : ICrateAction
|
||||
{
|
||||
Actor self;
|
||||
public SpeedUpgradeCrateAction(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public int SelectionShares
|
||||
{
|
||||
get { return self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().SelectionShares; }
|
||||
}
|
||||
|
||||
public void Activate(Actor collector)
|
||||
{
|
||||
Sound.PlayToPlayer(collector.Owner, "unitspd1.aud");
|
||||
collector.World.AddFrameEndTask(w =>
|
||||
{
|
||||
float multiplier = self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Multiplier;
|
||||
collector.traits.Add(new SpeedUpgrade(multiplier));
|
||||
w.Add(new CrateEffectSpeedUpgrade(collector));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class SpeedUpgrade : ISpeedModifier
|
||||
{
|
||||
float multiplier;
|
||||
public SpeedUpgrade(float multiplier) { this.multiplier = multiplier; }
|
||||
public float GetSpeedModifier() { return multiplier; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user