Merge pull request #11179 from reaperrr/minor-perf-fixes
Minor trait caching tweaks
This commit is contained in:
@@ -24,16 +24,20 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public WeaponInfo WeaponInfo { get; private set; }
|
public WeaponInfo WeaponInfo { get; private set; }
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new PoisonedByTiberium(this); }
|
public override object Create(ActorInitializer init) { return new PoisonedByTiberium(init, this); }
|
||||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; }
|
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
class PoisonedByTiberium : UpgradableTrait<PoisonedByTiberiumInfo>, ITick, ISync
|
class PoisonedByTiberium : UpgradableTrait<PoisonedByTiberiumInfo>, ITick, ISync
|
||||||
{
|
{
|
||||||
|
readonly ResourceLayer rl;
|
||||||
[Sync] int poisonTicks;
|
[Sync] int poisonTicks;
|
||||||
|
|
||||||
public PoisonedByTiberium(PoisonedByTiberiumInfo info)
|
public PoisonedByTiberium(ActorInitializer init, PoisonedByTiberiumInfo info)
|
||||||
: base(info) { }
|
: base(info)
|
||||||
|
{
|
||||||
|
rl = init.Self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
@@ -44,7 +48,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
if (!self.IsInWorld)
|
if (!self.IsInWorld)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
|
||||||
var r = rl.GetResource(self.Location);
|
var r = rl.GetResource(self.Location);
|
||||||
if (r == null || !Info.Resources.Contains(r.Info.Name))
|
if (r == null || !Info.Resources.Contains(r.Info.Name))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Leave the current position in a random direction.")]
|
[Desc("Leave the current position in a random direction.")]
|
||||||
public void Scatter()
|
public void Scatter()
|
||||||
{
|
{
|
||||||
Self.Trait<Mobile>().Nudge(Self, Self, true);
|
mobile.Nudge(Self, Self, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ScriptActorPropertyActivity]
|
[ScriptActorPropertyActivity]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("This actor can be sent to a structure for repairs.")]
|
[Desc("This actor can be sent to a structure for repairs.")]
|
||||||
class RepairableInfo : ITraitInfo, Requires<HealthInfo>
|
class RepairableInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo>
|
||||||
{
|
{
|
||||||
public readonly HashSet<string> RepairBuildings = new HashSet<string> { "fix" };
|
public readonly HashSet<string> RepairBuildings = new HashSet<string> { "fix" };
|
||||||
|
|
||||||
@@ -33,12 +33,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
readonly RepairableInfo info;
|
readonly RepairableInfo info;
|
||||||
readonly Health health;
|
readonly Health health;
|
||||||
|
readonly IMove movement;
|
||||||
readonly AmmoPool[] ammoPools;
|
readonly AmmoPool[] ammoPools;
|
||||||
|
|
||||||
public Repairable(Actor self, RepairableInfo info)
|
public Repairable(Actor self, RepairableInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
health = self.Trait<Health>();
|
health = self.Trait<Health>();
|
||||||
|
movement = self.Trait<IMove>();
|
||||||
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
|
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +92,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!CanRepairAt(order.TargetActor) || (!CanRepair() && !CanRearm()))
|
if (!CanRepairAt(order.TargetActor) || (!CanRepair() && !CanRearm()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var movement = self.Trait<IMove>();
|
|
||||||
var target = Target.FromOrder(self.World, order);
|
var target = Target.FromOrder(self.World, order);
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.SetTargetLine(target, Color.Green);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user