Added multiplier modifier traits, removing GainsStatUpgrades, InvulnerabilityUpgrade, & Invulnerable.
This commit is contained in:
31
OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs
Normal file
31
OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Damage taken by this actor is multiplied based on upgrade level.",
|
||||
"Decrease to increase actor's apparent strength.",
|
||||
"Use 0 to make actor invulnerable.")]
|
||||
public class DamageMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new DamageMultiplier(this, init.Self.Info.Name); }
|
||||
}
|
||||
|
||||
public class DamageMultiplier : UpgradeMultiplierTrait, IDamageModifier
|
||||
{
|
||||
public DamageMultiplier(DamageMultiplierInfo info, string actorType)
|
||||
: base(info, "DamageMultiplier", actorType) { }
|
||||
|
||||
public int GetDamageModifier(Actor attacker, IWarhead warhead) { return GetModifier(); }
|
||||
}
|
||||
}
|
||||
28
OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs
Normal file
28
OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("The firepower of this actor is multiplied based on upgrade level if specified.")]
|
||||
public class FirepowerMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new FirepowerMultiplier(this, init.Self.Info.Name); }
|
||||
}
|
||||
|
||||
public class FirepowerMultiplier : UpgradeMultiplierTrait, IFirepowerModifier
|
||||
{
|
||||
public FirepowerMultiplier(FirepowerMultiplierInfo info, string actorType)
|
||||
: base(info, "FirepowerMultiplier", actorType) { }
|
||||
|
||||
public int GetFirepowerModifier() { return GetModifier(); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("The inaccuracy of this actor is multipled based on upgrade level if specified.")]
|
||||
public class InaccuracyMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new InaccuracyMultiplier(this, init.Self.Info.Name); }
|
||||
}
|
||||
|
||||
public class InaccuracyMultiplier : UpgradeMultiplierTrait, IInaccuracyModifier
|
||||
{
|
||||
public InaccuracyMultiplier(InaccuracyMultiplierInfo info, string actorType)
|
||||
: base(info, "InaccuracyMultiplier", actorType) { }
|
||||
|
||||
public int GetInaccuracyModifier() { return GetModifier(); }
|
||||
}
|
||||
}
|
||||
36
OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs
Normal file
36
OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
[Desc("The power usage/output of this actor is multiplied based on upgrade level if specified.")]
|
||||
public class PowerMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new PowerMultiplier(init.Self, this); }
|
||||
}
|
||||
|
||||
public class PowerMultiplier : UpgradeMultiplierTrait, IPowerModifier, INotifyOwnerChanged
|
||||
{
|
||||
PowerManager power;
|
||||
|
||||
public PowerMultiplier(Actor self, PowerMultiplierInfo info)
|
||||
: base(info, "PowerMultiplier", self.Info.Name) { power = self.Owner.PlayerActor.Trait<PowerManager>(); }
|
||||
|
||||
public int GetPowerModifier() { return GetModifier(); }
|
||||
protected override void Update(Actor self) { power.UpdateActor(self); }
|
||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
{
|
||||
power = newOwner.PlayerActor.Trait<PowerManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("The reloading time of this actor is multiplied based on upgrade level if specified.")]
|
||||
public class ReloadDelayMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new ReloadDelayMultiplier(this, init.Self.Info.Name); }
|
||||
}
|
||||
|
||||
public class ReloadDelayMultiplier : UpgradeMultiplierTrait, IReloadModifier
|
||||
{
|
||||
public ReloadDelayMultiplier(ReloadDelayMultiplierInfo info, string actorType)
|
||||
: base(info, "ReloadDelayMultiplier", actorType) { }
|
||||
|
||||
public int GetReloadModifier() { return GetModifier(); }
|
||||
}
|
||||
}
|
||||
28
OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs
Normal file
28
OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("The speed of this actor is multiplied based on upgrade level if specified.")]
|
||||
public class SpeedMultiplierInfo : UpgradeMultiplierTraitInfo, ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new SpeedMultiplier(this, init.Self.Info.Name); }
|
||||
}
|
||||
|
||||
public class SpeedMultiplier : UpgradeMultiplierTrait, ISpeedModifier
|
||||
{
|
||||
public SpeedMultiplier(SpeedMultiplierInfo info, string actorType)
|
||||
: base(info, "SpeedMultiplier", actorType) { }
|
||||
|
||||
public int GetSpeedModifier() { return GetModifier(); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public abstract class UpgradeMultiplierTraitInfo
|
||||
{
|
||||
[UpgradeUsedReference]
|
||||
[Desc("Accepted upgrade types.")]
|
||||
public readonly string[] UpgradeTypes = { };
|
||||
|
||||
[Desc("The lowest upgrade level using the scale.")]
|
||||
public readonly int BaseLevel = 1;
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Percentages to apply with the first being applied at the base level.",
|
||||
"Repeat last entry to accept time extensions.",
|
||||
"If no upgrade types are specified, then the first/only modifier is always applied.")]
|
||||
public readonly int[] Modifier = { };
|
||||
}
|
||||
|
||||
public abstract class UpgradeMultiplierTrait : IUpgradable, IDisabledTrait, ISync
|
||||
{
|
||||
readonly UpgradeMultiplierTraitInfo info;
|
||||
[Sync] int level = 0;
|
||||
[Sync] public bool IsTraitDisabled { get; private set; }
|
||||
public int AdjustedLevel { get { return level - info.BaseLevel; } }
|
||||
public IEnumerable<string> UpgradeTypes { get { return info.UpgradeTypes; } }
|
||||
|
||||
protected UpgradeMultiplierTrait(UpgradeMultiplierTraitInfo info, string modifierType, string actorType)
|
||||
{
|
||||
if (info.Modifier.Length == 0)
|
||||
throw new Exception("No modifiers in " + modifierType + " for " + actorType);
|
||||
this.info = info;
|
||||
IsTraitDisabled = info.UpgradeTypes.Length > 0 && info.BaseLevel > 0;
|
||||
}
|
||||
|
||||
public bool AcceptsUpgradeLevel(Actor self, string type, int level)
|
||||
{
|
||||
return level < info.Modifier.Length + info.BaseLevel;
|
||||
}
|
||||
|
||||
// Override to recieve notice of level change.
|
||||
protected virtual void Update(Actor self) { }
|
||||
|
||||
public void UpgradeLevelChanged(Actor self, string type, int oldLevel, int newLevel)
|
||||
{
|
||||
if (!UpgradeTypes.Contains(type))
|
||||
return;
|
||||
level = newLevel.Clamp(0, Math.Max(info.Modifier.Length + info.BaseLevel - 1, 0));
|
||||
IsTraitDisabled = level < info.BaseLevel;
|
||||
Update(self);
|
||||
}
|
||||
|
||||
public int GetModifier()
|
||||
{
|
||||
return IsTraitDisabled ? 100 : info.Modifier[level - info.BaseLevel];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user