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