Add a 'refundableValue' parameter to 'Produce'

This commit is contained in:
abcdefg30
2020-09-08 19:49:54 +02:00
committed by reaperrr
parent cc2e369475
commit 0dac4520ad
10 changed files with 18 additions and 18 deletions

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc.Traits
factionInit ?? new FactionInit(BuildableInfo.GetInitialFaction(produced.Info, p.Faction))
};
if (p.Produce(self, produced.Info, Info.ProductionType, inits))
if (p.Produce(self, produced.Info, Info.ProductionType, inits, 0))
return;
}
}

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Scripting
new FactionInit(factionVariant ?? BuildableInfo.GetInitialFaction(actorInfo, p.Faction))
};
if (p.Produce(Self, actorInfo, type, inits))
if (p.Produce(Self, actorInfo, type, inits, 0))
return true;
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public ProductionAirdrop(ActorInitializer init, ProductionAirdropInfo info)
: base(init, info) { }
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits)
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits, int refundableValue)
{
if (IsTraitDisabled || IsTraitPaused)
return false;

View File

@@ -175,9 +175,10 @@ namespace OpenRA.Mods.Common.Traits
new FactionInit(BuildableInfo.GetInitialFaction(unit, p.Trait.Faction))
};
if (p.Trait.Produce(p.Actor, unit, type, inits))
var item = Queue.First(i => i.Done && i.Item == unit.Name);
if (p.Trait.Produce(p.Actor, unit, type, inits, item.TotalCost))
{
EndProduction(Queue.FirstOrDefault(i => i.Done && i.Item == unit.Name));
EndProduction(item);
return true;
}
}

View File

@@ -124,9 +124,10 @@ namespace OpenRA.Mods.Common.Traits
new FactionInit(BuildableInfo.GetInitialFaction(unit, p.Trait.Faction))
};
if (p.Trait.Produce(p.Actor, unit, type, inits))
var item = Queue.First(i => i.Done && i.Item == unit.Name);
if (p.Trait.Produce(p.Actor, unit, type, inits, item.TotalCost))
{
EndProduction(Queue.FirstOrDefault(i => i.Done && i.Item == unit.Name));
EndProduction(item);
return true;
}
}

View File

@@ -570,10 +570,10 @@ namespace OpenRA.Mods.Common.Traits
var bi = unit.TraitInfo<BuildableInfo>();
var type = developerMode.AllTech ? Info.Type : (bi.BuildAtProductionType ?? Info.Type);
if (!mostLikelyProducerTrait.IsTraitPaused && mostLikelyProducerTrait.Produce(self, unit, type, inits))
var item = Queue.First(i => i.Done && i.Item == unit.Name);
if (!mostLikelyProducerTrait.IsTraitPaused && mostLikelyProducerTrait.Produce(self, unit, type, inits, item.TotalCost))
{
EndProduction(Queue.FirstOrDefault(i => i.Done && i.Item == unit.Name));
EndProduction(item);
return true;
}

View File

@@ -109,18 +109,16 @@ namespace OpenRA.Mods.Common.Traits
return SelectExit(self, producee, productionType, e => CanUseExit(self, producee, e.Info));
}
public virtual bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits)
public virtual bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits, int refundableValue)
{
if (IsTraitDisabled || IsTraitPaused || Reservable.IsReserved(self))
return false;
// Pick a spawn/exit point pair
var exit = SelectExit(self, producee, productionType);
if (exit != null || self.OccupiesSpace == null || !producee.HasTraitInfo<IOccupySpaceInfo>())
{
DoProduction(self, producee, exit == null ? null : exit.Info, productionType, inits);
DoProduction(self, producee, exit?.Info, productionType, inits);
return true;
}

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
rp = self.TraitOrDefault<RallyPoint>();
}
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits)
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits, int refundableValue)
{
if (IsTraitDisabled || IsTraitPaused)
return false;

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault<RallyPoint>());
}
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits)
public override bool Produce(Actor self, ActorInfo producee, string productionType, TypeDictionary inits, int refundableValue)
{
if (IsTraitDisabled || IsTraitPaused)
return false;
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
cargo.Delivered(self);
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit == null ? null : exit.Info, productionType, inits));
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit?.Info, productionType, inits));
Game.Sound.Play(SoundType.World, info.ChuteSound, self.CenterPosition);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
}));

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
new FactionInit(BuildableInfo.GetInitialFaction(ai, faction))
};
activated |= p.Trait.Produce(p.Actor, ai, info.Type, inits);
activated |= p.Trait.Produce(p.Actor, ai, info.Type, inits, 0);
}
if (activated)