Migration to World.Defaults complete (for RA)
This commit is contained in:
@@ -157,7 +157,7 @@ namespace OpenRA
|
||||
if (Health <= 0)
|
||||
return DamageState.Dead;
|
||||
|
||||
if (Health < this.GetMaxHP() * Rules.General.ConditionYellow)
|
||||
if (Health < this.GetMaxHP() * World.Defaults.ConditionYellow)
|
||||
return DamageState.Half;
|
||||
|
||||
return DamageState.Normal;
|
||||
|
||||
@@ -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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -26,11 +26,15 @@ namespace OpenRA.Effects
|
||||
{
|
||||
class RepairIndicator : IEffect
|
||||
{
|
||||
int framesLeft = (int)(Rules.General.RepairRate * 25 * 60 / 2);
|
||||
int framesLeft;
|
||||
Actor a;
|
||||
Animation anim = new Animation("select");
|
||||
|
||||
public RepairIndicator(Actor a) { this.a = a; anim.PlayRepeating("repair"); }
|
||||
public RepairIndicator(Actor a)
|
||||
{
|
||||
this.a = a; anim.PlayRepeating("repair");
|
||||
framesLeft = (int)(a.World.Defaults.RepairRate * 25 * 60 / 2);
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace OpenRA
|
||||
public static InfoLoader<WarheadInfo> WarheadInfo;
|
||||
public static InfoLoader<ProjectileInfo> ProjectileInfo;
|
||||
public static InfoLoader<VoiceInfo> VoiceInfo;
|
||||
public static GeneralInfo General;
|
||||
public static TechTree TechTree;
|
||||
|
||||
public static Dictionary<string, ActorInfo> Info;
|
||||
@@ -45,9 +44,6 @@ namespace OpenRA
|
||||
legacyRules.Insert(0, map);
|
||||
AllRules = new IniFile(legacyRules.Select(a => FileSystem.Open(a)).ToArray());
|
||||
|
||||
General = new GeneralInfo();
|
||||
FieldLoader.Load(General, AllRules.GetSection("General"));
|
||||
|
||||
LoadCategories(
|
||||
"Weapon",
|
||||
"Warhead",
|
||||
|
||||
@@ -255,8 +255,8 @@ namespace OpenRA.Graphics
|
||||
lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c);
|
||||
|
||||
var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red
|
||||
: (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow
|
||||
var healthColor = (healthAmount < selectedUnit.World.Defaults.ConditionRed) ? Color.Red
|
||||
: (healthAmount < selectedUnit.World.Defaults.ConditionYellow) ? Color.Yellow
|
||||
: Color.LimeGreen;
|
||||
|
||||
var healthColor2 = Color.FromArgb(
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
<Compile Include="Traits\Activities\Wait.cs" />
|
||||
<Compile Include="Traits\CrateAction.cs" />
|
||||
<Compile Include="Effects\CrateEffect.cs" />
|
||||
<Compile Include="Traits\Defaults\GlobalDefaults.cs" />
|
||||
<Compile Include="Traits\World\GlobalDefaults.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
@@ -338,7 +338,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Folder Include="Traits\Defaults\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA
|
||||
void GiveAdvice(string advice)
|
||||
{
|
||||
// todo: store the condition or something.
|
||||
// repeat after Rules.General.SpeakDelay, as long as the condition holds.
|
||||
// repeat after World.Defaults.SpeakDelay, as long as the condition holds.
|
||||
Sound.PlayToPlayer(this, advice);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -39,8 +39,8 @@ namespace OpenRA.Traits.Activities
|
||||
var unitCost = self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
|
||||
var costPerHp = (Rules.General.URepairPercent * unitCost) / hp;
|
||||
var hpToRepair = Math.Min(Rules.General.URepairStep, hp - self.Health);
|
||||
var costPerHp = (self.World.Defaults.URepairPercent * unitCost) / hp;
|
||||
var hpToRepair = Math.Min(self.World.Defaults.URepairStep, hp - self.Health);
|
||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||
if (!self.Owner.TakeCash(cost))
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Traits.Activities
|
||||
hostBuilding.traits.Get<RenderBuilding>()
|
||||
.PlayCustomAnim(hostBuilding, "active");
|
||||
|
||||
remainingTicks = (int)(Rules.General.RepairRate * 60 * 25);
|
||||
remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25);
|
||||
}
|
||||
else
|
||||
--remainingTicks;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Traits.Activities
|
||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;
|
||||
var refund = Rules.General.RefundPercent * self.Health * cost / hp;
|
||||
var refund = self.World.Defaults.RefundPercent * self.Health * cost / hp;
|
||||
|
||||
self.Owner.GiveCash((int)refund);
|
||||
self.Health = 0;
|
||||
|
||||
@@ -125,8 +125,8 @@ namespace OpenRA.Traits
|
||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||
var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||
var costPerHp = (Rules.General.URepairPercent * buildingValue) / maxHP;
|
||||
var hpToRepair = Math.Min(Rules.General.URepairStep, maxHP - self.Health);
|
||||
var costPerHp = (self.World.Defaults.URepairPercent * buildingValue) / maxHP;
|
||||
var hpToRepair = Math.Min(self.World.Defaults.URepairStep, maxHP - self.Health);
|
||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||
if (!self.Owner.TakeCash(cost))
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace OpenRA.Traits
|
||||
isRepairing = false;
|
||||
return;
|
||||
}
|
||||
remainingTicks = (int)(Rules.General.RepairRate * 60 * 25);
|
||||
remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25);
|
||||
}
|
||||
else
|
||||
--remainingTicks;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Traits
|
||||
var unit = Rules.Info[order.TargetString];
|
||||
var ui = unit.Traits.Get<BuildableInfo>();
|
||||
var time = ui.Cost
|
||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||
* self.World.Defaults.BuildSpeed /* todo: country-specific build speed bonus */
|
||||
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||
/ 1000;
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace OpenRA.Traits
|
||||
if (player.GetPowerState() != PowerState.Normal)
|
||||
{
|
||||
if (--slowdown <= 0)
|
||||
slowdown = Rules.General.LowPowerSlowdown;
|
||||
slowdown = player.World.Defaults.LowPowerSlowdown;
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ namespace OpenRA.Traits
|
||||
if (effectiveHealth <= 0)
|
||||
return ExtendedDamageState.Dead;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionRed)
|
||||
if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionRed)
|
||||
return ExtendedDamageState.Quarter;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionYellow)
|
||||
if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionYellow)
|
||||
return ExtendedDamageState.Half;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * 0.75)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits.Defaults
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class GlobalDefaultsInfo : ITraitInfo
|
||||
public class GlobalDefaultsInfo : StatelessTraitInfo<GlobalDefaults>
|
||||
{
|
||||
/* Special Weapons */
|
||||
public readonly float GapRegenInterval =0;
|
||||
@@ -80,15 +80,8 @@ namespace OpenRA.Traits.Defaults
|
||||
public readonly int SuspendPriority = 0;
|
||||
public readonly float TeamDelay = 0;
|
||||
|
||||
public object Create(Actor self) { return new GlobalDefaults(self); }
|
||||
public readonly int LowPowerSlowdown = 3;
|
||||
}
|
||||
|
||||
public class GlobalDefaults
|
||||
{
|
||||
Actor self;
|
||||
public GlobalDefaults (Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
}
|
||||
public class GlobalDefaults {}
|
||||
}
|
||||
@@ -66,6 +66,7 @@ namespace OpenRA
|
||||
|
||||
public readonly Map Map;
|
||||
public readonly TileSet TileSet;
|
||||
public GlobalDefaultsInfo Defaults { get {return WorldActor.Info.Traits.Get<GlobalDefaultsInfo>();}}
|
||||
|
||||
// for tricky things like bridges.
|
||||
public readonly ICustomTerrain[,] customTerrain;
|
||||
@@ -114,7 +115,7 @@ namespace OpenRA
|
||||
Add( a );
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
public void Add(Actor a)
|
||||
{
|
||||
a.IsInWorld = true;
|
||||
|
||||
@@ -63,7 +63,7 @@ Player:
|
||||
GivenAuto: no
|
||||
OneShot: yes
|
||||
|
||||
Defaults:
|
||||
World:
|
||||
GlobalDefaults:
|
||||
GapRegenInterval: .1
|
||||
BadgerBombCount: 1
|
||||
@@ -125,8 +125,7 @@ Defaults:
|
||||
SuspendDelay: 2
|
||||
SuspendPriority: 20
|
||||
TeamDelay: .6
|
||||
|
||||
World:
|
||||
LowPowerSlowdown: 3
|
||||
ScreenShaker:
|
||||
WaterPaletteRotation:
|
||||
ChronoshiftPaletteEffect:
|
||||
|
||||
Reference in New Issue
Block a user