introduce 'Valued' trait, which is almost Buildable without being buildable.
This commit is contained in:
@@ -119,7 +119,7 @@ namespace OpenRA
|
||||
var actor = world.FindUnitsAtMouse(lastMousePos).FirstOrDefault();
|
||||
if (actor == null) return;
|
||||
|
||||
var text = actor.Info.Traits.Contains<BuildableInfo>() ? actor.Info.Traits.Get<BuildableInfo>().Description : actor.Info.Name;
|
||||
var text = actor.Info.Traits.Contains<ValuedInfo>() ? actor.Info.Traits.Get<ValuedInfo>().Description : actor.Info.Name;
|
||||
var text2 = (actor.Owner == world.LocalPlayer)
|
||||
? "" : (actor.Owner == world.NeutralPlayer ? "{0}" : "{0} ({1})").F(actor.Owner.PlayerName, world.LocalPlayer.Stances[actor.Owner]);
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace OpenRA.Traits.AI
|
||||
{
|
||||
var info = self.Info.Traits.Get<EmitInfantryOnSellInfo>();
|
||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
var hpFraction = Math.Max(info.MinHpFraction, hp / self.GetMaxHP());
|
||||
var dudesValue = (int)(hpFraction * info.ValueFraction * cost);
|
||||
var eligibleLocations = Footprint.Tiles(self).ToList();
|
||||
// todo: fix this for unbuildables in ActorTypes, like civilians.
|
||||
var actorTypes = info.ActorTypes.Select(a => new { Name = a, Cost = Rules.Info[a].Traits.Get<BuildableInfo>().Cost }).ToArray();
|
||||
var actorTypes = info.ActorTypes.Select(a => new { Name = a, Cost = Rules.Info[a].Traits.Get<ValuedInfo>().Cost }).ToArray();
|
||||
|
||||
while (eligibleLocations.Count > 0 && actorTypes.Any(a => a.Cost <= dudesValue))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Traits.Activities
|
||||
var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
||||
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
|
||||
|
||||
var unitCost = self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
|
||||
var costPerHp = (hostBuilding.Info.Traits.Get<RepairsUnitsInfo>().URepairPercent * unitCost) / hp;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Traits.Activities
|
||||
void DoSell(Actor self)
|
||||
{
|
||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
var refund = self.World.Defaults.RefundPercent * self.Health * cost / hp;
|
||||
|
||||
|
||||
@@ -20,19 +20,29 @@
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class BuildableInfo : TraitInfo<Buildable>
|
||||
class ValuedInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Cost = 0;
|
||||
public readonly string Description = "";
|
||||
public readonly string LongDesc = "";
|
||||
|
||||
public virtual object Create(Actor self) { return new Valued(); }
|
||||
}
|
||||
|
||||
class BuildableInfo : ValuedInfo
|
||||
{
|
||||
public readonly int TechLevel = -1;
|
||||
public readonly string[] Prerequisites = { };
|
||||
public readonly string[] BuiltAt = { };
|
||||
public readonly string[] Owner = { };
|
||||
public readonly int Cost = 0;
|
||||
public readonly string Description = "";
|
||||
public readonly string LongDesc = "";
|
||||
|
||||
public readonly string Icon = null;
|
||||
public readonly string[] AlternateName = { };
|
||||
public readonly int BuildPaletteOrder = 50;
|
||||
|
||||
public override object Create(Actor self) { return new Buildable(); }
|
||||
}
|
||||
|
||||
class Valued { } /* halfway to buildable */
|
||||
class Buildable { }
|
||||
}
|
||||
|
||||
@@ -209,6 +209,9 @@ C1:
|
||||
Selectable:
|
||||
Voice: CivilianMaleVoice
|
||||
Bounds: 12,17,0,-9
|
||||
Valued:
|
||||
Cost: 70
|
||||
Description: Technician
|
||||
Unit:
|
||||
HP: 20
|
||||
Sight: 2
|
||||
@@ -221,6 +224,9 @@ C2:
|
||||
Selectable:
|
||||
Voice: CivilianFemaleVoice
|
||||
Bounds: 12,17,0,-9
|
||||
Valued:
|
||||
Cost: 70
|
||||
Description: Technician
|
||||
Unit:
|
||||
HP: 20
|
||||
Sight: 2
|
||||
|
||||
Reference in New Issue
Block a user