Merge pull request #5865 from obrakmann/fix5861
Fix RepairBuilding not working for AI and Lua scripts
This commit is contained in:
@@ -851,9 +851,11 @@ namespace OpenRA.Mods.RA.AI
|
|||||||
if (!e.Attacker.HasTrait<ITargetable>())
|
if (!e.Attacker.HasTrait<ITargetable>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Info.ShouldRepairBuildings && self.HasTrait<RepairableBuilding>())
|
var rb = self.TraitOrDefault<RepairableBuilding>();
|
||||||
|
|
||||||
|
if (Info.ShouldRepairBuildings && rb != null)
|
||||||
{
|
{
|
||||||
if (e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light)
|
if (e.DamageState > DamageState.Light && e.PreviousDamageState <= DamageState.Light && !rb.RepairActive)
|
||||||
{
|
{
|
||||||
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
|
BotDebug("Bot noticed damage {0} {1}->{2}, repairing.",
|
||||||
self, e.PreviousDamageState, e.DamageState);
|
self, e.PreviousDamageState, e.DamageState);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
|
|
||||||
Health Health;
|
Health Health;
|
||||||
RepairableBuildingInfo Info;
|
RepairableBuildingInfo Info;
|
||||||
public bool RepairActive = true;
|
public bool RepairActive = false;
|
||||||
|
|
||||||
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
||||||
{
|
{
|
||||||
@@ -102,6 +102,7 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
if (Health.DamageState == DamageState.Undamaged)
|
if (Health.DamageState == DamageState.Undamaged)
|
||||||
{
|
{
|
||||||
Repairers.Clear();
|
Repairers.Clear();
|
||||||
|
RepairActive = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ end
|
|||||||
|
|
||||||
Actor.RepairBuilding = function(actor)
|
Actor.RepairBuilding = function(actor)
|
||||||
local rb = Actor.TraitOrDefault(actor, "RepairableBuilding")
|
local rb = Actor.TraitOrDefault(actor, "RepairableBuilding")
|
||||||
if rb ~= nil and rb.Repairer == nil then
|
if rb ~= nil and not rb.RepairActive then
|
||||||
rb:RepairBuilding(actor, Actor.Owner(actor))
|
rb:RepairBuilding(actor, Actor.Owner(actor))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user