More Lua API enhancements
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -33,4 +34,34 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Maximum health of the actor.")]
|
||||
public int MaxHealth { get { return health.MaxHP; } }
|
||||
}
|
||||
|
||||
[ScriptPropertyGroup("General")]
|
||||
public class RepairableBuildingProperties : ScriptActorProperties, Requires<RepairableBuildingInfo>
|
||||
{
|
||||
readonly RepairableBuilding rb;
|
||||
|
||||
public RepairableBuildingProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
rb = self.Trait<RepairableBuilding>();
|
||||
}
|
||||
|
||||
[Desc("Start repairs on this building. `repairer` can be an allied player.")]
|
||||
public void StartBuildingRepairs(Player repairer = null)
|
||||
{
|
||||
repairer = repairer ?? self.Owner;
|
||||
|
||||
if (!rb.Repairers.Contains(repairer))
|
||||
rb.RepairBuilding(self, repairer);
|
||||
}
|
||||
|
||||
[Desc("Stop repairs on this building. `repairer` can be an allied player.")]
|
||||
public void StopBuildingRepairs(Player repairer = null)
|
||||
{
|
||||
repairer = repairer ?? self.Owner;
|
||||
|
||||
if (rb.RepairActive && rb.Repairers.Contains(repairer))
|
||||
rb.RepairBuilding(self, repairer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user