Merge remote branches 'alzeih/master', 'pchote/walls' and 'origin/dev'
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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -144,9 +144,19 @@ namespace OpenRa
|
||||
|
||||
public DamageState GetDamageState()
|
||||
{
|
||||
if (Health <= 0) return DamageState.Dead;
|
||||
var halfStrength = this.GetMaxHP() * Rules.General.ConditionYellow;
|
||||
return Health < halfStrength ? DamageState.Half : DamageState.Normal;
|
||||
if (Health <= 0)
|
||||
return DamageState.Dead;
|
||||
|
||||
if (Health < this.GetMaxHP() * Rules.General.ConditionRed)
|
||||
return DamageState.Quarter;
|
||||
|
||||
if (Health < this.GetMaxHP() * Rules.General.ConditionYellow)
|
||||
return DamageState.Half;
|
||||
|
||||
if (Health < this.GetMaxHP() * 0.75)
|
||||
return DamageState.ThreeQuarter;
|
||||
|
||||
return DamageState.Normal;
|
||||
}
|
||||
|
||||
public void InflictDamage(Actor attacker, int damage, WarheadInfo warhead)
|
||||
|
||||
@@ -685,50 +685,22 @@ namespace OpenRa
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
|
||||
const int chromeButtonGap = 2;
|
||||
|
||||
void DrawButtons( World world )
|
||||
{
|
||||
int2 buttonOrigin = new int2(Game.viewport.Width - 320, 2);
|
||||
// Repair
|
||||
Rectangle repairRect = new Rectangle(buttonOrigin.X, buttonOrigin.Y, repairButton.Image.bounds.Width, repairButton.Image.bounds.Height);
|
||||
var repairDrawPos = new float2(repairRect.Location);
|
||||
|
||||
var hasFact = world.Queries.OwnedBy[world.LocalPlayer].WithTrait<ConstructionYard>().Any();
|
||||
|
||||
if (Game.Settings.RepairRequiresConyard && !hasFact)
|
||||
repairButton.ReplaceAnim("disabled");
|
||||
else
|
||||
{
|
||||
repairButton.ReplaceAnim(Game.controller.orderGenerator is RepairOrderGenerator ? "pressed" : "normal");
|
||||
AddButton(repairRect, isLmb => Game.controller.ToggleInputMode<RepairOrderGenerator>());
|
||||
}
|
||||
shpRenderer.DrawSprite(repairButton.Image, repairDrawPos, "chrome");
|
||||
var origin = new int2(Game.viewport.Width - 200, 2);
|
||||
|
||||
// Sell
|
||||
Rectangle sellRect = new Rectangle(buttonOrigin.X+40, buttonOrigin.Y,
|
||||
sellButton.Image.bounds.Width, sellButton.Image.bounds.Height);
|
||||
|
||||
var sellDrawPos = new float2(sellRect.Location);
|
||||
|
||||
sellButton.ReplaceAnim(Game.controller.orderGenerator is SellOrderGenerator ? "pressed" : "normal");
|
||||
|
||||
AddButton(sellRect, isLmb => Game.controller.ToggleInputMode<SellOrderGenerator>());
|
||||
shpRenderer.DrawSprite(sellButton.Image, sellDrawPos, "chrome");
|
||||
shpRenderer.Flush();
|
||||
|
||||
if (Game.Settings.PowerDownBuildings)
|
||||
foreach (var cb in world.WorldActor.traits.WithInterface<IChromeButton>())
|
||||
{
|
||||
// Power Down
|
||||
Rectangle pwrdownRect = new Rectangle(buttonOrigin.X+80, buttonOrigin.Y,
|
||||
pwrdownButton.Image.bounds.Width, pwrdownButton.Image.bounds.Height);
|
||||
|
||||
var pwrdownDrawPos = new float2(pwrdownRect.Location);
|
||||
|
||||
pwrdownButton.ReplaceAnim(Game.controller.orderGenerator is PowerDownOrderGenerator ? "pressed" : "normal");
|
||||
|
||||
AddButton(pwrdownRect, isLmb => Game.controller.ToggleInputMode<PowerDownOrderGenerator>());
|
||||
shpRenderer.DrawSprite(pwrdownButton.Image, pwrdownDrawPos, "chrome");
|
||||
var button = cb;
|
||||
var anim = new Animation(cb.Image);
|
||||
anim.Play(cb.Enabled ? cb.Pressed ? "pressed" : "normal" : "disabled");
|
||||
origin.X -= (int)anim.Image.size.X + chromeButtonGap;
|
||||
shpRenderer.DrawSprite(anim.Image, origin, "chrome");
|
||||
AddButton(new RectangleF(origin.X, origin.Y, anim.Image.size.X, anim.Image.size.Y),
|
||||
_ => { if (button.Enabled) button.OnClick(); });
|
||||
}
|
||||
shpRenderer.Flush();
|
||||
|
||||
//Options
|
||||
Rectangle optionsRect = new Rectangle(0,0, optionsButton.Image.bounds.Width,
|
||||
|
||||
@@ -81,13 +81,7 @@ namespace OpenRa.Effects
|
||||
|
||||
var dist = Target.CenterLocation - Pos;
|
||||
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || Target.IsDead)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
if (t > Projectile.Arm * 40) /* don't blow up in our launcher's face! */
|
||||
Combat.DoImpact(Pos.ToInt2(), Pos.ToInt2(), Weapon, Projectile, Warhead, FiredBy);
|
||||
return;
|
||||
}
|
||||
Explode(world);
|
||||
|
||||
var speed = Scale * Weapon.Speed * ((targetAltitude > 0 && Weapon.TurboBoost) ? 1.5f : 1f);
|
||||
|
||||
@@ -99,7 +93,17 @@ namespace OpenRa.Effects
|
||||
world.AddFrameEndTask(w => w.Add(
|
||||
new Smoke(w, (Pos - 1.5f * move - new int2( 0, Altitude )).ToInt2(), Projectile.Trail)));
|
||||
|
||||
// todo: running out of fuel
|
||||
if (Projectile.RangeLimit != 0 && t > Projectile.RangeLimit * 40)
|
||||
Explode(world);
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
if (t > Projectile.Arm * 40) /* don't blow up in our launcher's face! */
|
||||
Combat.DoImpact(Pos.ToInt2(), Pos.ToInt2(), Weapon, Projectile, Warhead, FiredBy);
|
||||
return;
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
|
||||
@@ -25,25 +25,21 @@ namespace OpenRa.GameRules
|
||||
public readonly bool AA = false;
|
||||
public readonly bool AG = true;
|
||||
public readonly bool ASW = false;
|
||||
public readonly string Trail = null;
|
||||
public readonly bool Arcing = false;
|
||||
public readonly int Arm = 0;
|
||||
public readonly bool Degenerates = false;
|
||||
public readonly bool Dropping = false;
|
||||
public readonly int Frames = 1;
|
||||
public readonly bool Gigundo = false;
|
||||
public readonly bool High = false;
|
||||
public readonly string Image = null;
|
||||
public readonly bool Inaccurate = false;
|
||||
public readonly bool Inviso = false;
|
||||
public readonly bool Parachuted = false;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly int ROT = 0;
|
||||
public readonly bool Ranged = false;
|
||||
public readonly bool Rotates = false;
|
||||
public readonly bool Shadow = true;
|
||||
public readonly bool Translucent = false;
|
||||
public readonly bool UnderWater = false;
|
||||
public readonly int RangeLimit = 0;
|
||||
|
||||
// OpenRA-specific:
|
||||
public readonly string Trail = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRa.Graphics
|
||||
{
|
||||
class HardwarePalette : Sheet
|
||||
{
|
||||
const int maxEntries = 16;
|
||||
public const int MaxPalettes = 64;
|
||||
int allocated = 0;
|
||||
|
||||
// We need to store the Palettes themselves for the remap palettes to work
|
||||
@@ -36,7 +36,7 @@ namespace OpenRa.Graphics
|
||||
static Dictionary<string, Palette> palettes;
|
||||
static Dictionary<string, int> indices;
|
||||
public HardwarePalette(Renderer renderer, Map map)
|
||||
: base(renderer,new Size(256, maxEntries))
|
||||
: base(renderer,new Size(256, MaxPalettes))
|
||||
{
|
||||
palettes = new Dictionary<string, Palette>();
|
||||
indices = new Dictionary<string, int>();
|
||||
|
||||
@@ -52,23 +52,11 @@ namespace OpenRa.Graphics
|
||||
return result;
|
||||
}
|
||||
|
||||
public static readonly int2[] directions =
|
||||
new int2[] {
|
||||
new int2( -1, -1 ),
|
||||
new int2( -1, 0 ),
|
||||
new int2( -1, 1 ),
|
||||
new int2( 0, -1 ),
|
||||
new int2( 0, 1 ),
|
||||
new int2( 1, -1 ),
|
||||
new int2( 1, 0 ),
|
||||
new int2( 1, 1 ),
|
||||
};
|
||||
|
||||
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||
|
||||
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni, float2 size)
|
||||
{
|
||||
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
|
||||
var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]);
|
||||
|
||||
vertices[nv] = new Vertex(o,
|
||||
r.FastMapTextureCoords(0), attrib);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -108,6 +108,7 @@
|
||||
<Compile Include="Support\PerfHistory.cs" />
|
||||
<Compile Include="Sync.cs" />
|
||||
<Compile Include="Traits\Attack\AttackOmni.cs" />
|
||||
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\Player\SpawnDefaultUnits.cs" />
|
||||
<Compile Include="Traits\World\BridgeLoadHook.cs" />
|
||||
@@ -263,6 +264,8 @@
|
||||
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
||||
<Compile Include="World.cs" />
|
||||
<Compile Include="WorldUtils.cs" />
|
||||
<Compile Include="Traits\Wall.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRa.FileFormats\OpenRa.FileFormats.csproj">
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRa
|
||||
if (thisCost == float.PositiveInfinity)
|
||||
return p.Location;
|
||||
|
||||
foreach( int2 d in Graphics.Util.directions )
|
||||
foreach( int2 d in directions )
|
||||
{
|
||||
int2 newHere = p.Location + d;
|
||||
|
||||
@@ -113,6 +113,18 @@ namespace OpenRa
|
||||
return p.Location;
|
||||
}
|
||||
|
||||
static readonly int2[] directions =
|
||||
{
|
||||
new int2( -1, -1 ),
|
||||
new int2( -1, 0 ),
|
||||
new int2( -1, 1 ),
|
||||
new int2( 0, -1 ),
|
||||
new int2( 0, 1 ),
|
||||
new int2( 1, -1 ),
|
||||
new int2( 1, 0 ),
|
||||
new int2( 1, 1 ),
|
||||
};
|
||||
|
||||
public void AddInitialCell( World world, int2 location )
|
||||
{
|
||||
if (!world.Map.IsInMap(location.X, location.Y))
|
||||
|
||||
@@ -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.
|
||||
@@ -48,7 +48,7 @@ namespace OpenRa.Traits.Activities
|
||||
{
|
||||
if( !started )
|
||||
{
|
||||
framesRemaining = self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length;
|
||||
framesRemaining = (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation) ? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
foreach( var ns in self.traits.WithInterface<INotifySold>() )
|
||||
ns.Selling( self );
|
||||
|
||||
|
||||
47
OpenRa.Game/Traits/Chrome/PowerDownButton.cs
Normal file
47
OpenRa.Game/Traits/Chrome/PowerDownButton.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRa.Orders;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class PowerDownButtonInfo : StatelessTraitInfo<PowerDownButton> { }
|
||||
|
||||
class PowerDownButton : IChromeButton
|
||||
{
|
||||
public string Image { get { return "repair"; } } // todo: art
|
||||
public bool Enabled { get { return true; } }
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is PowerDownOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<PowerDownOrderGenerator>(); }
|
||||
}
|
||||
|
||||
class SellButtonInfo : StatelessTraitInfo<SellButton> { }
|
||||
|
||||
class SellButton : IChromeButton
|
||||
{
|
||||
public string Image { get { return "sell"; } }
|
||||
public bool Enabled { get { return true; } }
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is SellOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<SellOrderGenerator>(); }
|
||||
}
|
||||
|
||||
class RepairButtonInfo : StatelessTraitInfo<RepairButton> { }
|
||||
|
||||
class RepairButton : IChromeButton
|
||||
{
|
||||
public string Image { get { return "repair"; } } // todo: art
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Game.Settings.RepairRequiresConyard)
|
||||
return true;
|
||||
|
||||
return Game.world.Queries.OwnedBy[Game.world.LocalPlayer]
|
||||
.WithTrait<ConstructionYard>().Any();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is RepairOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<RepairOrderGenerator>(); }
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -25,6 +25,7 @@ namespace OpenRa.Traits
|
||||
{
|
||||
public class RenderBuildingInfo : RenderSimpleInfo
|
||||
{
|
||||
public readonly bool HasMakeAnimation = true;
|
||||
public override object Create(Actor self) { return new RenderBuilding(self);}
|
||||
}
|
||||
|
||||
@@ -39,8 +40,8 @@ namespace OpenRa.Traits
|
||||
|
||||
public RenderBuilding(Actor self, Func<int> baseFacing)
|
||||
: base(self, baseFacing)
|
||||
{
|
||||
if( Game.skipMakeAnims )
|
||||
{
|
||||
if( Game.skipMakeAnims || !self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation )
|
||||
Complete( self );
|
||||
else
|
||||
anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
|
||||
@@ -124,7 +125,9 @@ namespace OpenRa.Traits
|
||||
|
||||
public void Selling( Actor self )
|
||||
{
|
||||
anim.PlayBackwardsThen( "make", null );
|
||||
if( !Game.skipMakeAnims && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation )
|
||||
anim.PlayBackwardsThen( "make", null );
|
||||
|
||||
Sound.PlayToPlayer(self.Owner, "cashturn.aud");
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -27,7 +27,7 @@ using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
public enum DamageState { Normal, Half, Dead };
|
||||
public enum DamageState { Normal, ThreeQuarter, Half, Quarter, Dead };
|
||||
|
||||
// depends on the order of pips in WorldRenderer.cs!
|
||||
public enum PipType { Transparent, Green, Yellow, Red, Gray };
|
||||
@@ -132,4 +132,12 @@ namespace OpenRa.Traits
|
||||
IActivity Tick(Actor self);
|
||||
void Cancel(Actor self);
|
||||
}
|
||||
|
||||
public interface IChromeButton
|
||||
{
|
||||
string Image { get; }
|
||||
bool Enabled { get; }
|
||||
bool Pressed { get; }
|
||||
void OnClick();
|
||||
}
|
||||
}
|
||||
|
||||
32
OpenRa.Game/Traits/Wall.cs
Normal file
32
OpenRa.Game/Traits/Wall.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#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.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Effects;
|
||||
using OpenRa.GameRules;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
public class WallInfo : StatelessTraitInfo<Wall> {}
|
||||
public class Wall {}
|
||||
}
|
||||
Reference in New Issue
Block a user