Fix crash on repair non-buildables (fact,proc). Allow special powers to depend on them too.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -25,6 +25,7 @@ namespace OpenRA.Traits
|
|||||||
public readonly int Cost = 0;
|
public readonly int Cost = 0;
|
||||||
public readonly string Description = "";
|
public readonly string Description = "";
|
||||||
public readonly string LongDesc = "";
|
public readonly string LongDesc = "";
|
||||||
|
public readonly string[] Owner = { };
|
||||||
|
|
||||||
public virtual object Create(Actor self) { return new Valued(); }
|
public virtual object Create(Actor self) { return new Valued(); }
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,6 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public readonly string[] Prerequisites = { };
|
public readonly string[] Prerequisites = { };
|
||||||
public readonly string[] BuiltAt = { };
|
public readonly string[] BuiltAt = { };
|
||||||
public readonly string[] Owner = { };
|
|
||||||
|
|
||||||
public readonly string Icon = null;
|
public readonly string Icon = null;
|
||||||
public readonly string[] AlternateName = { };
|
public readonly string[] AlternateName = { };
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA.Traits
|
|||||||
if (remainingTicks == 0)
|
if (remainingTicks == 0)
|
||||||
{
|
{
|
||||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||||
var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
|
var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||||
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||||
var costPerHp = (self.World.Defaults.RepairPercent * buildingValue) / maxHP;
|
var costPerHp = (self.World.Defaults.RepairPercent * buildingValue) / maxHP;
|
||||||
var hpToRepair = Math.Min(self.World.Defaults.RepairStep, maxHP - self.Health);
|
var hpToRepair = Math.Min(self.World.Defaults.RepairStep, maxHP - self.Health);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Traits
|
|||||||
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
||||||
var effectivePrereq = Info.Prerequisites
|
var effectivePrereq = Info.Prerequisites
|
||||||
.Select(a => a.ToLowerInvariant())
|
.Select(a => a.ToLowerInvariant())
|
||||||
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(Owner.Country.Race));
|
.Where(a => Rules.Info[a].Traits.Get<ValuedInfo>().Owner.Contains(Owner.Country.Race));
|
||||||
|
|
||||||
if (Info.Prerequisites.Count() == 0)
|
if (Info.Prerequisites.Count() == 0)
|
||||||
return Owner.PlayerActor.traits.Get<PlayerResources>().GetPowerState() == PowerState.Normal;
|
return Owner.PlayerActor.traits.Get<PlayerResources>().GetPowerState() == PowerState.Normal;
|
||||||
|
|||||||
Reference in New Issue
Block a user