Make Cargo and Carryall conditional.

This commit is contained in:
Matthias Mailänder
2023-07-25 21:43:23 +02:00
committed by Gustas
parent a14cc8cc4d
commit 98896f9a75
7 changed files with 47 additions and 27 deletions

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnFirstRun(Actor self)
{
// The cargo might have become invalid while we were moving towards it.
if (cargo.IsDead || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
return;
if (carryall.ReserveCarryable(self, cargo))
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceling)
return true;
if (cargo.IsDead || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self) || cargo != carryall.Carryable)
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self) || cargo != carryall.Carryable)
{
Cancel(self, true);
return false;
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnFirstRun(Actor self)
{
// The cargo might have become invalid while we were moving towards it.
if (cargo == null || cargo.IsDead || carryable.IsTraitDisabled || carryall.Carryable != cargo || !cargo.AppearsFriendlyTo(self))
if (cargo == null || cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || carryall.Carryable != cargo || !cargo.AppearsFriendlyTo(self))
return;
self.World.AddFrameEndTask(w =>

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
// Make sure we can still enter the transport
// (but not before, because this may stop the actor in the middle of nowhere)
if (enterCargo == null || !passenger.Reserve(self, enterCargo))
if (enterCargo == null || enterCargo.IsTraitDisabled || !passenger.Reserve(self, enterCargo))
{
Cancel(self, true);
return false;
@@ -49,6 +49,12 @@ namespace OpenRA.Mods.Common.Activities
return true;
}
protected override void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor)
{
if (enterCargo != null && enterCargo.IsTraitDisabled)
Cancel(self, true);
}
protected override void OnEnterComplete(Actor self, Actor targetActor)
{
self.World.AddFrameEndTask(w =>