Compare commits

...

30 Commits

Author SHA1 Message Date
Chris Forbes
20785a6585 clean up bullets somewhat 2010-07-09 21:44:38 +12:00
Chris Forbes
5e1c63ebb5 change BulletInfo.Arcing to BulletInfo.Angle to allow more control over trajectories 2010-07-09 21:05:00 +12:00
Chris Forbes
40ae25c895 remove silly exploit on undeploying MCV 2010-07-08 21:49:25 +12:00
Paul Chote
3093928d95 Move lint checking to the mods themselves; don't compile aftermath (the rules have bitrotted so lint always fails) 2010-07-08 20:28:05 +12:00
Paul Chote
df3581237e Remove hardcoded cursor bs; move TransformsOnDeploy to Mods.RA. 2010-07-08 20:23:19 +12:00
Paul Chote
ac3924e660 Restore sane buildspeed to cnc 2010-07-08 19:32:37 +12:00
Paul Chote
476d40b317 Move StoresOre into Mods.RA 2010-07-08 19:32:07 +12:00
Paul Chote
d9ba7ff90c Fix packaged osx SupportDir 2010-07-08 19:12:49 +12:00
Paul Chote
a383f8873c SupportDir supports absolute or relative paths; default to ~/OpenRA 2010-07-08 19:10:34 +12:00
Paul Chote
3508e71168 Automatically run ralint when building from makefile. Also fixes external-tool logging crash 2010-07-08 18:45:54 +12:00
Paul Chote
513769f131 Remove the need for a trailing separator 2010-07-08 18:11:29 +12:00
Paul Chote
fdc85b6e48 Don't spam logs and replays all over my home directory kthx.
Logs and replays are written to subdirectories of the "Support" folder. Default location is <game dir>/Support/; Can be overridden on game start.
2010-07-08 18:11:28 +12:00
Bob
fb6c44bce3 move render{building,buildingturreted,unit} into mods.ra; move all render traits into mods.ra.render 2010-07-08 17:24:12 +12:00
Bob
281d013c3b move Combat, AttackBase, and associates into mod 2010-07-08 16:38:58 +12:00
Bob
bd74b29ea3 move projectile effects into mod 2010-07-08 16:04:18 +12:00
Bob
7a738ed6af move CYard trait and UndeployMCV activity into mod 2010-07-08 15:34:21 +12:00
Bob
1eedae2c7b fix window origin in pseudofullscreen 2010-07-08 15:20:55 +12:00
Bob
6a840dff4c move ActorGroupProxy to mod; move SupportPower traits into directory 2010-07-08 14:01:44 +12:00
Paul Chote
9054f10b83 Sane crate defaults for cnc 2010-07-07 23:16:24 +12:00
Paul Chote
d04d943fe5 Remove some redundant logging 2010-07-07 23:13:27 +12:00
Paul Chote
02e4d7d270 Remove "Version: " from the version string display 2010-07-07 23:13:27 +12:00
Paul Chote
5fba682fe0 Fullscreen -> WindowMode; defaults to pseudofullscreen which does hax on windows, falls back to normal fullscreen for everyone else. 2010-07-07 23:13:27 +12:00
Paul Chote
731e7af45a Point the downloader at the right package 2010-07-07 23:13:27 +12:00
Paul Chote
b11719d34a Re-enable zip generation 2010-07-07 23:13:27 +12:00
Paul Chote
066c28b0e8 Point the download urls at the master server 2010-07-07 23:13:27 +12:00
Paul Chote
bc016fd76d More polish; pull terminal/finder windows to the front when stuff happens; include unzip progress in terminal 2010-07-07 23:13:26 +12:00
Paul Chote
4dd25d4936 Polish 2010-07-07 23:13:26 +12:00
Paul Chote
a5d90a542b Split the functions out into their own files 2010-07-07 23:13:26 +12:00
Paul Chote
9d70bb24a6 Package osx dependencies separately from the main download; Game is now run from inside app bundle; Support dir used to cache downloads only 2010-07-07 23:13:26 +12:00
Chris Forbes
12a350b89f fix crash on selecting husks (and other things with Unit but Selectable.Voice = null) 2010-07-07 21:27:34 +12:00
105 changed files with 737 additions and 508 deletions

View File

@@ -1,7 +1,7 @@
CSC = gmcs
CSFLAGS = -nologo -warn:4 -debug:+ -debug:full -optimize- -codepage:utf8 -unsafe
DEFINE = DEBUG;TRACE
PROGRAMS =fileformats gl game ra cnc aftermath seqed mapcvtr editor
PROGRAMS =fileformats gl game ra cnc aftermath seqed mapcvtr editor ralint
prefix = /usr/local
datarootdir = $(prefix)/share
datadir = $(datarootdir)
@@ -73,12 +73,18 @@ mapcvtr_KIND = winexe
mapcvtr_DEPS = $(fileformats_TARGET)
mapcvtr_LIBS = $(COMMON_LIBS) $(mapcvtr_DEPS)
ralint_SRCS = $(shell find RALint/ -iname '*.cs')
ralint_TARGET = ralint.exe
ralint_KIND = winexe
ralint_DEPS = $(fileformats_TARGET) $(game_TARGET)
ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS)
# -platform:x86
.SUFFIXES:
.PHONY: clean all default mods seqed mapcvtr install uninstall
.PHONY: clean all default mods install uninstall
all: $(fileformats_TARGET) $(gl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET) $(seqed_TARGET) $(mapcvtr_TARGET)
all: $(fileformats_TARGET) $(gl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET) $(seqed_TARGET) $(mapcvtr_TARGET) $(editor_TARGET) $(ralint_TARGET)
clean:
@-rm *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb
@@ -122,10 +128,18 @@ uninstall:
@-rm -r $(INSTALL_DIR)
@-rm $(DESTDIR)$(bindir)/openra
mods: $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET)
mod_ra: $(ra_TARGET) $(ralint_TARGET)
mono ralint.exe ra
mod_aftermath: $(aftermath_TARGET) $(ralint_TARGET)
mono ralint.exe ra aftermath
mod_cnc: $(cnc_TARGET) $(ralint_TARGET)
mono ralint.exe cnc
mods: mod_ra mod_cnc
seqed: $(seqed_TARGET)
mapcvtr: $(mapcvtr_TARGET)
editor: $(editor_TARGET)
ralint: $(ralint_TARGET)
define BUILD_ASSEMBLY

View File

@@ -102,4 +102,11 @@ namespace OpenRA.FileFormats.Graphics
public readonly T Start, End;
public Range( T start, T end ) { Start = start; End = end; }
}
public enum WindowMode
{
Windowed,
Fullscreen,
PseudoFullscreen,
}
}

View File

@@ -37,14 +37,20 @@ namespace OpenRA
public static class Log
{
public static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
static Dictionary<string, ChannelInfo> channels = new Dictionary<string,ChannelInfo>();
static Log()
public static string LogPath
{
AddChannel("debug", "openra.log.txt", false, false);
get { return LogPathPrefix; }
set
{
LogPathPrefix = value;
if (!Directory.Exists(LogPathPrefix))
Directory.CreateDirectory(LogPathPrefix);
}
}
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
{
if (channels.ContainsKey(channelName)) return;
@@ -57,7 +63,7 @@ namespace OpenRA
{
writer = File.CreateText(LogPathPrefix + filename);
}
catch(IOException e){ filename = new Random().Next().ToString() + filename; }
catch(IOException){ filename = new Random().Next().ToString() + filename; }
}
writer.AutoFlush = true;

View File

@@ -48,11 +48,6 @@ namespace OpenRA
}
}
static bool HasVoice(Actor a)
{
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
}
void ApplyOrders(World world, float2 xy, MouseInput mi)
{
if (orderGenerator == null) return;
@@ -61,7 +56,7 @@ namespace OpenRA
Game.orderManager.IssueOrders( orders );
var voicedActor = orders.Select(o => o.Subject)
.FirstOrDefault(a => a.Owner == world.LocalPlayer && HasVoice(a));
.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
var isMove = orders.Any(o => o.OrderString == "Move");
var isAttack = orders.Any( o => o.OrderString == "Attack" );

View File

@@ -24,7 +24,7 @@ using OpenRA.Traits;
namespace OpenRA.Effects
{
class FlashTarget : IEffect
public class FlashTarget : IEffect
{
Actor target;
int remainingTicks = 4;

View File

@@ -24,7 +24,7 @@ using OpenRA.Traits;
namespace OpenRA.Effects
{
class Smoke : IEffect
public class Smoke : IEffect
{
readonly int2 pos;
readonly Animation anim;

View File

@@ -21,9 +21,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA
{
@@ -45,28 +44,6 @@ namespace OpenRA
return xs.Aggregate(1f, (a, x) => a * x);
}
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static WeaponInfo GetSecondaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.SecondaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static int GetMaxHP(this Actor self)
{
var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>();

View File

@@ -115,10 +115,6 @@ namespace OpenRA
// TODO: Do this nicer
static Dictionary<string, MapStub> FindMaps(string[] mods)
{
Console.WriteLine("Finding maps");
foreach (var mod in mods)
Console.WriteLine(mod);
var paths = new[] { "maps/" }.Concat(mods.Select(m => "mods/" + m + "/maps/"))
.Where(p => Directory.Exists(p))
.SelectMany(p => Directory.GetDirectories(p)).ToList();
@@ -567,7 +563,14 @@ namespace OpenRA
{
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
LoadUserSettings(settings);
LoadUserSettings(settings);
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
Log.AddChannel("perf", "perf.log", false, false);
Log.AddChannel("debug", "debug.log", false, false);
Log.AddChannel("sync", "syncreport.log", true, true);
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
// Load the default mod to access required files
@@ -575,9 +578,8 @@ namespace OpenRA
Renderer.SheetSize = Settings.SheetSize;
bool windowed = !Game.Settings.Fullscreen;
var resolution = GetResolution(settings);
renderer = new Renderer(resolution, windowed);
renderer = new Renderer(resolution, Game.Settings.WindowMode);
resolution = renderer.Resolution;
controller = new Controller();
@@ -601,7 +603,6 @@ namespace OpenRA
ResetTimer();
Log.AddChannel("sync", "openra.syncreport.txt", true, true);
}
static void LoadUserSettings(Settings settings)
@@ -641,13 +642,26 @@ namespace OpenRA
Chrome.rootWidget.CloseWindow();
Chrome.rootWidget.OpenWindow("MAINMENU_BG");
}
}
public static string SupportDir
{
get {
var dir = Settings.SupportDir;
// Expand paths relative to the personal directory
if (dir.ElementAt(0) == '~')
dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dir.Substring(1);
return dir + Path.DirectorySeparatorChar;
}
}
internal static int GetGameId()
{
try
{
string s = File.ReadAllText(Log.LogPathPrefix + "openra.gameid");
string s = File.ReadAllText(SupportDir + "currentgameid");
return int.Parse(s);
}
catch (Exception)
@@ -658,7 +672,7 @@ namespace OpenRA
internal static void SetGameId(int id)
{
var file = File.CreateText(Log.LogPathPrefix + "openra.gameid");
var file = File.CreateText(SupportDir + "currentgameid");
file.Write(id);
file.Flush();
file.Close();

View File

@@ -38,12 +38,6 @@ namespace OpenRA
public static void LoadRules(Manifest m, Map map)
{
Log.Write("debug", "Using rules files: ");
foreach (var y in m.Rules)
Log.Write("debug", " -- {0}", y);
Log.Write("debug", "Using Map: {0}",map.Uid);
Info = LoadYamlRules(m.Rules, map.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y));
Weapons = LoadYamlRules(m.Weapons, map.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
Voices = LoadYamlRules(m.Voices, map.Voices, (k, _) => new VoiceInfo(k.Value));

View File

@@ -18,10 +18,15 @@
*/
#endregion
using OpenRA.FileFormats.Graphics;
using System;
using System.IO;
namespace OpenRA.GameRules
{
public class UserSettings
{
public readonly string SupportDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ Path.DirectorySeparatorChar + "OpenRA" + Path.DirectorySeparatorChar;
// Debug settings
public bool UnitDebug = false;
public bool PathDebug = true;
@@ -32,7 +37,7 @@ namespace OpenRA.GameRules
// Window settings
public readonly int Width = 0;
public readonly int Height = 0;
public readonly bool Fullscreen = false;
public readonly WindowMode WindowMode = WindowMode.PseudoFullscreen;
public bool MusicPlayer = true;
// Internal game settings

View File

@@ -22,7 +22,7 @@ using System.Xml;
namespace OpenRA.Graphics
{
class CursorSequence
public class CursorSequence
{
readonly int start, length;

View File

@@ -51,9 +51,9 @@ namespace OpenRA.Graphics
public Size Resolution { get { return device.WindowSize; } }
public Renderer(Size resolution, bool windowed)
public Renderer(Size resolution, OpenRA.FileFormats.Graphics.WindowMode windowMode)
{
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Gl.dll" ) ), resolution.Width, resolution.Height, windowed, false );
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Gl.dll" ) ), resolution.Width, resolution.Height, windowMode, false );
SpriteShader = device.CreateShader(FileSystem.Open("shaders/world-shp.fx"));
LineShader = device.CreateShader(FileSystem.Open("shaders/line.fx"));
@@ -69,12 +69,12 @@ namespace OpenRA.Graphics
TitleFont = new SpriteFont(this, "titles.ttf", 48);
}
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync )
{
foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) )
{
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( bool ), typeof( bool ) } )
.Invoke( new object[] { width, height, windowed, vsync } );
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( WindowMode ), typeof( bool ) } )
.Invoke( new object[] { width, height, window, vsync } );
}
throw new NotImplementedException();
}

View File

@@ -27,7 +27,7 @@ using OpenRA.FileFormats;
namespace OpenRA.Graphics
{
static class SequenceProvider
public static class SequenceProvider
{
static Dictionary<string, Dictionary<string, Sequence>> units;
static Dictionary<string, CursorSequence> cursors;

View File

@@ -62,10 +62,9 @@ namespace OpenRA.Network
public OrderManager( IConnection conn, string replayFilename )
: this( conn )
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ Path.DirectorySeparatorChar + ".openra";
string path = Game.SupportDir + "Replays" + Path.DirectorySeparatorChar;
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
replaySaveFile = File.Create( path + Path.DirectorySeparatorChar + replayFilename );
replaySaveFile = File.Create( path + replayFilename );
}
public void IssueOrders( Order[] orders )

View File

@@ -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>
@@ -77,21 +77,16 @@
<ItemGroup>
<Compile Include="Chat.cs" />
<Compile Include="Chrome.cs" />
<Compile Include="Effects\GravityBomb.cs" />
<Compile Include="GameRules\WeaponInfo.cs" />
<Compile Include="Group.cs" />
<Compile Include="Orders\GenericSelectTarget.cs" />
<Compile Include="Traits\Activities\UndeployMcv.cs" />
<Compile Include="Traits\BaseBuilding.cs" />
<Compile Include="Traits\DetectCloaked.cs" />
<Compile Include="Traits\LintAttributes.cs" />
<Compile Include="Traits\Modifiers\FrozenUnderFog.cs" />
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
<Compile Include="Traits\Player\PlayerResources.cs" />
<Compile Include="Traits\Player\TechTreeCache.cs" />
<Compile Include="Traits\Modifiers\HiddenUnderFog.cs" />
<Compile Include="Traits\Render\RenderBuilding.cs" />
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
<Compile Include="Traits\Render\RenderUnitTurreted.cs" />
<Compile Include="Traits\World\Shroud.cs" />
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />
@@ -104,14 +99,11 @@
<Compile Include="Widgets\MapPreviewWidget.cs" />
<Compile Include="Widgets\PostGameWidget.cs" />
<Compile Include="Widgets\WidgetUtils.cs" />
<Compile Include="Combat.cs" />
<Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\LaserZap.cs" />
<Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Effects\RepairIndicator.cs" />
<Compile Include="Effects\Smoke.cs" />
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Exts.cs" />
<Compile Include="GameRules\ActorInfo.cs" />
<Compile Include="GameRules\TechTree.cs" />
@@ -123,7 +115,6 @@
<Compile Include="Graphics\Minimap.cs" />
<Compile Include="Graphics\SpriteFont.cs" />
<Compile Include="Network\Connection.cs" />
<Compile Include="Effects\Missile.cs" />
<Compile Include="Network\OrderIO.cs" />
<Compile Include="Network\OrderManager.cs" />
<Compile Include="PathSearch.cs" />
@@ -141,10 +132,7 @@
<Compile Include="Traits\World\SpatialBins.cs" />
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
<Compile Include="Traits\World\Country.cs" />
<Compile Include="Traits\Activities\Attack.cs" />
<Compile Include="Traits\Activities\TransformIntoActor.cs" />
<Compile Include="Actor.cs" />
<Compile Include="Effects\Bullet.cs" />
<Compile Include="Controller.cs" />
<Compile Include="Cursor.cs" />
<Compile Include="Effects\Explosion.cs" />
@@ -181,11 +169,9 @@
<Compile Include="Graphics\TerrainRenderer.cs" />
<Compile Include="Traits\Activities\Move.cs" />
<Compile Include="Traits\Activities\Turn.cs" />
<Compile Include="Traits\AttackBase.cs" />
<Compile Include="Traits\Buildable.cs" />
<Compile Include="Traits\Building.cs" />
<Compile Include="Traits\World\BuildingInfluence.cs" />
<Compile Include="Traits\ConstructionYard.cs" />
<Compile Include="Traits\LimitedAmmo.cs" />
<Compile Include="Traits\Player\PlaceBuilding.cs" />
<Compile Include="Traits\World\PlayerColorPalette.cs" />
@@ -195,13 +181,10 @@
<Compile Include="Traits\ProvidesRadar.cs" />
<Compile Include="Traits\Selectable.cs" />
<Compile Include="Traits\Player\ProductionQueue.cs" />
<Compile Include="Traits\TransformsOnDeploy.cs" />
<Compile Include="Traits\Mobile.cs" />
<Compile Include="Traits\Production.cs" />
<Compile Include="Traits\RallyPoint.cs" />
<Compile Include="Traits\Render\RenderSimple.cs" />
<Compile Include="Traits\Render\RenderUnit.cs" />
<Compile Include="Traits\StoresOre.cs" />
<Compile Include="Traits\Cloak.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Turreted.cs" />
@@ -242,7 +225,6 @@
<Compile Include="Traits\SharesCell.cs" />
<Compile Include="Traits\World\AircraftInfluence.cs" />
<Compile Include="Traits\World\HazardLayer.cs" />
<Compile Include="Traits\Hazardous.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
@@ -278,4 +260,9 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Folder Include="Traits\" />
<Folder Include="Traits\" />
<Folder Include="Traits\Activities\" />
</ItemGroup>
</Project>

View File

@@ -52,9 +52,9 @@ namespace OpenRA.Orders
world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
if (a.Owner == world.LocalPlayer)
{
if (a.traits.Contains<RenderRangeCircle>())
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
a.CenterLocation, (int)a.GetPrimaryWeapon().Range);
//if (a.traits.Contains<RenderRangeCircle>())
// world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
// a.CenterLocation, (int)a.GetPrimaryWeapon().Range);
if (a.traits.Contains<DetectCloaked>())
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),
@@ -74,7 +74,8 @@ namespace OpenRA.Orders
{
var p = Game.controller.MousePosition;
var c = Order(world, p.ToInt2(), mi)
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
.Select(o => o.Subject.traits.WithInterface<IProvideCursor>()
.Select(pc => pc.CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)).FirstOrDefault(a => a != null))
.FirstOrDefault(a => a != null);
return c ??
@@ -83,42 +84,5 @@ namespace OpenRA.Orders
? "select" : "default");
}
}
string CursorForOrderString(string s, Actor a, int2 location)
{
switch (s)
{
case "Attack": return "attack";
case "Heal": return "heal";
case "C4": return "c4";
case "Move":
if (a.traits.GetOrDefault<IMove>().CanEnterCell(location))
return "move";
else
return "move-blocked";
case "DeployTransform":
var depInfo = a.Info.Traits.Get<TransformsOnDeployInfo>();
var transInfo = Rules.Info[depInfo.TransformsInto];
if (transInfo.Traits.Contains<BuildingInfo>())
{
var bi = transInfo.Traits.Get<BuildingInfo>();
if (!a.World.CanPlaceBuilding(depInfo.TransformsInto, bi, a.Location + new int2(depInfo.Offset[0], depInfo.Offset[1]), a))
return "deploy-blocked";
}
return "deploy";
case "Deploy": return "deploy";
case "Enter": return "enter";
case "EnterTransport": return "enter";
case "Deliver": return "enter";
case "Infiltrate": return "enter";
case "Capture": return "capture";
case "Harvest": return "attackmove";
case "Steal" : return "enter";
case "BeginMinefield": return "ability";
default:
return null;
}
}
}
}

View File

@@ -41,7 +41,7 @@ namespace OpenRA
else
actors = (isCombine ? oldSelection.Union(newSelection) : newSelection).ToList();
var voicedUnit = actors.FirstOrDefault(a => a.traits.Contains<Unit>() && a.Owner == world.LocalPlayer);
var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
Sound.PlayVoice("Select", voicedUnit);
foreach (var ns in world.WorldActor.traits.WithInterface<INotifySelection>())

View File

@@ -33,7 +33,6 @@ namespace OpenRA
{
// brutal hack
Application.CurrentCulture = CultureInfo.InvariantCulture;
Log.AddChannel("perf", "openra.perf.txt", false, false);
if (Debugger.IsAttached || args.Contains("--just-die"))
{

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRA.Traits
{
/* tag trait for "bases": mcv/fact */
class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
class BaseBuilding { }
}

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
}
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove, IProvideCursor
{
public readonly Actor self;
public readonly MobileInfo Info;
@@ -121,6 +121,14 @@ namespace OpenRA.Traits
}
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
if (s != "Move")
return null;
return (CanEnterCell(location)) ? "move" : "move-blocked";
}
public int2 TopLeft { get { return toCell; } }

View File

@@ -20,6 +20,7 @@
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -63,16 +64,7 @@ namespace OpenRA.Traits
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
}
/* todo: reimpl this properly */
var facts = w.Queries.OwnedBy[self.Owner]
.WithTrait<ConstructionYard>().Select(x => x.Actor);
var primaryFact = facts.Where(y => y.traits.Get<Production>().IsPrimary);
var fact = (primaryFact.Count() > 0) ? primaryFact.FirstOrDefault() : facts.FirstOrDefault();
if (fact != null)
fact.traits.Get<RenderBuilding>().PlayCustomAnim(fact, "build");
PlayBuildAnim( self, unit );
queue.FinishProduction(unit.Category);
@@ -84,6 +76,19 @@ namespace OpenRA.Traits
}
}
// finds a construction yard (or equivalent) and runs its "build" animation.
static void PlayBuildAnim( Actor self, ActorInfo unit )
{
var producers = self.World.Queries.OwnedBy[ self.Owner ].WithTrait<Production>()
.Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( unit.Category ) )
.ToList();
var producer = producers.Where( x => x.Trait.IsPrimary ).Concat( producers )
.FirstOrDefault();
if( producer.Actor != null )
producer.Actor.traits.WithInterface<RenderSimple>().First().PlayCustomAnim( producer.Actor, "build" );
}
static int GetNumBuildables(Player p)
{
if (p != p.World.LocalPlayer) return 0; // this only matters for local players.

View File

@@ -48,8 +48,8 @@ namespace OpenRA.Traits
int nextSiloAdviceTime = 0;
void TickOre(Actor self)
{
OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<StoresOre>()
.Sum(a => a.Actor.Info.Traits.Get<StoresOreInfo>().Capacity);
OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<IStoreOre>()
.Sum(a => a.Actor.traits.WithInterface<IStoreOre>().Sum(b => b.Capacity));
if (Ore > OreCapacity)
Ore = OreCapacity;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Traits
public readonly string[] Produces = { };
}
public class Production : IIssueOrder, IResolveOrder, ITags
public class Production : IIssueOrder, IResolveOrder, ITags, IProvideCursor
{
public virtual int2? CreationLocation( Actor self, ActorInfo producee )
{
@@ -108,7 +108,12 @@ namespace OpenRA.Traits
return new Order("Deploy", self);
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Deploy") ? "deploy" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Deploy")

View File

@@ -72,6 +72,18 @@ namespace OpenRA.Traits
a.Animation.Tick();
}
protected virtual string GetPrefix(Actor self)
{
return self.GetDamageState() == DamageState.Half ? "damaged-" : "";
}
public void PlayCustomAnim(Actor self, string name)
{
if (anim.HasSequence(name))
anim.PlayThen(GetPrefix(self) + name,
() => anim.PlayRepeating(GetPrefix(self) + "idle"));
}
public class AnimationWithOffset
{
public Animation Animation;

View File

@@ -46,6 +46,7 @@ namespace OpenRA.Traits
public interface IRender { IEnumerable<Renderable> Render(Actor self); }
public interface IIssueOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); }
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
public interface IProvideCursor { string CursorForOrderString(string s, Actor a, int2 location); }
public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); }
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
@@ -56,6 +57,7 @@ namespace OpenRA.Traits
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); }
public interface IAvoidHazard { string Type { get; } }
public interface IStoreOre { int Capacity { get; }}
public interface ITerrainTypeModifier { string GetTerrainType(int2 cell); }
public interface ITerrainCost { float GetTerrainCost(int2 cell, Actor forActor); }

View File

@@ -21,7 +21,6 @@
using System;
using System.Drawing;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
namespace OpenRA.Traits
@@ -82,7 +81,7 @@ namespace OpenRA.Traits
return a / step;
}
static float2 RotateVectorByFacing(float2 v, int facing, float ecc)
public static float2 RotateVectorByFacing(float2 v, int facing, float ecc)
{
var angle = (facing / 256f) * (2 * (float)Math.PI);
var sinAngle = (float)Math.Sin(angle);
@@ -93,17 +92,6 @@ namespace OpenRA.Traits
ecc * (cosAngle * v.Y - sinAngle * v.X));
}
static float2 GetRecoil(Actor self, float recoil)
{
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
if (rut == null) return float2.Zero;
var facing = self.traits.Get<Turreted>().turretFacing;
return RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().Recoil), facing, .7f);
}
public static float2 CenterOfCell(int2 loc)
{
return new float2(12, 12) + Game.CellSize * (float2)loc;
@@ -114,19 +102,6 @@ namespace OpenRA.Traits
return 0.5f * (CenterOfCell(from) + CenterOfCell(to));
}
public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil)
{
if( unit == null ) return offset.AbsOffset(); /* things that don't have a rotating base don't need the turrets repositioned */
var ru = self.traits.GetOrDefault<RenderUnit>();
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
var bodyFacing = unit.Facing;
var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
return (RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil))
+ offset.AbsOffset();
}
public static int2 AsInt2(this int[] xs) { return new int2(xs[0], xs[1]); }
public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); }
public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); }
@@ -144,12 +119,6 @@ namespace OpenRA.Traits
(next, a) => { a.NextActivity = next; return a; });
}
public static float GetMaximumRange(Actor self)
{
return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
.Where(w => w != null).Max(w => w.Range);
}
public static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); }
public static int2 CellContaining(float2 pos) { return (1f / Game.CellSize * pos).ToInt2(); }

View File

@@ -26,7 +26,7 @@ using OpenRA.FileFormats;
namespace OpenRA.Traits
{
class SmudgeLayerInfo : ITraitInfo
public class SmudgeLayerInfo : ITraitInfo
{
public readonly string Type = "Scorch";
public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"};
@@ -34,7 +34,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
}
class SmudgeLayer: IRenderOverlay, ILoadWorldHook
public class SmudgeLayer: IRenderOverlay, ILoadWorldHook
{
public SmudgeLayerInfo Info;
SpriteRenderer spriteRenderer;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Widgets.Delegates
if (FileSystem.Exists("VERSION"))
{
var s = FileSystem.Open("VERSION");
version.Text = "Version: "+s.ReadAllText();
version.Text = s.ReadAllText();
s.Close();
}
}

View File

@@ -222,5 +222,10 @@ namespace OpenRA
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
}
public static bool HasVoice(this Actor a)
{
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
}
}
}

View File

@@ -50,27 +50,32 @@ namespace OpenRA.GlRenderer
throw new InvalidOperationException("GL Error");
}
public GraphicsDevice(int width, int height, bool windowed, bool vsync)
public GraphicsDevice(int width, int height, WindowMode window, bool vsync)
{
Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);
int windowFlags = 0;
switch( window )
{
// pseudo-fullscreen, for sane debugging.
Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_NOFRAME | Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
}
else
{
// OSX doesn't like this, due to quirks of their WM.
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
}
case WindowMode.Fullscreen:
windowFlags |= Sdl.SDL_FULLSCREEN;
break;
case WindowMode.PseudoFullscreen:
// pseudo-fullscreen only reliably works on windows; fall back to fullscreen for everyone else
windowFlags |= ( Environment.OSVersion.Platform == PlatformID.Win32NT ) ? Sdl.SDL_NOFRAME : Sdl.SDL_FULLSCREEN;
Environment.SetEnvironmentVariable( "SDL_VIDEO_WINDOW_POS", "0,0" );
break;
default:
break;
}
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_OPENGL | windowFlags);
Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
Sdl.SDL_ShowCursor(0);
Sdl.SDL_EnableUNICODE(1);
@@ -89,8 +94,8 @@ namespace OpenRA.GlRenderer
vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
Console.WriteLine("VP Profile: " + vertexProfile);
Console.WriteLine("FP Profile: " + fragmentProfile);
//Console.WriteLine("VP Profile: " + vertexProfile);
//Console.WriteLine("FP Profile: " + fragmentProfile);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
CheckGlError();

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Aftermath
public readonly int ChargeTime = 120; // Seconds
}
class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ITick, IPips
class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ITick, IPips, IProvideCursor
{
// Recharge logic
[Sync]
@@ -78,6 +78,11 @@ namespace OpenRA.Mods.Aftermath
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Deploy") ? "deploy" : null;
}
// Display 5 pips indicating the current charge status
public IEnumerable<PipType> GetPips(Actor self)
{

View File

@@ -18,10 +18,10 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Mods.RA;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Effects

View File

@@ -20,6 +20,7 @@
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc

View File

@@ -16,14 +16,12 @@
* 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.Linq;
using System.Collections.Generic;
using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
#endregion
using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.Cnc

View File

@@ -18,7 +18,11 @@
*/
#endregion
namespace OpenRA.Traits.Activities
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA.Activities
{
/* non-turreted attack */
public class Attack : IActivity

View File

@@ -19,7 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;

View File

@@ -18,8 +18,10 @@
*/
#endregion
using OpenRA.Traits;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class Leap : IActivity

View File

@@ -19,6 +19,7 @@
#endregion
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities

View File

@@ -19,7 +19,7 @@
#endregion
using System;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities

View File

@@ -19,8 +19,9 @@
#endregion
using System;
using OpenRA.Traits;
namespace OpenRA.Traits.Activities
namespace OpenRA.Mods.RA.Activities
{
class TransformIntoActor : IActivity
{
@@ -44,24 +45,28 @@ namespace OpenRA.Traits.Activities
public IActivity Tick( Actor self )
{
if (isCanceled) return NextActivity;
self.World.AddFrameEndTask( _ =>
self.World.AddFrameEndTask(_ =>
{
var oldHP = self.GetMaxHP();
var newHP = Rules.Info[actor].Traits.Get<OwnedActorInfo>().HP;
var newHealth = (transferPercentage) ? (int)((float)self.Health/oldHP*newHP) : Math.Min(self.Health, newHP);
self.Health = 0;
self.World.Remove( self );
self.World.Remove(self);
foreach (var s in sounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
var a = self.World.CreateActor( actor, self.Location + offset, self.Owner );
a.Health = newHealth;
} );
var a = self.World.CreateActor(actor, self.Location + offset, self.Owner);
a.Health = GetHealthToTransfer(self, a, transferPercentage);
});
return this;
}
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
public static int GetHealthToTransfer(Actor from, Actor to, bool transferPercentage)
{
var oldHP = from.GetMaxHP();
var newHP = to.GetMaxHP();
return (transferPercentage)
? (int)((float)from.Health / oldHP * newHP)
: Math.Min(from.Health, newHP);
}
}
}

View File

@@ -18,9 +18,12 @@
*/
#endregion
namespace OpenRA.Traits.Activities
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class UndeployMcv : IActivity
public class UndeployMcv : IActivity
{
public IActivity NextActivity { get; set; }
bool started;
@@ -30,6 +33,7 @@ namespace OpenRA.Traits.Activities
w.Remove(self);
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
mcv.Health = TransformIntoActor.GetHealthToTransfer(self, mcv, true);
mcv.traits.Get<Unit>().Facing = 96;
}

View File

@@ -19,7 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;

View File

@@ -24,8 +24,9 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{
public class AttackBaseInfo : ITraitInfo
{
@@ -44,7 +45,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new AttackBase(init.self); }
}
public class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier
public class AttackBase : IIssueOrder, IResolveOrder, ITick, IExplodeModifier, IProvideCursor
{
[Sync] public Actor target;
@@ -178,7 +179,7 @@ namespace OpenRA.Traits
firedBy = self,
target = target,
src = self.CenterLocation.ToInt2() + Util.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(),
src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(),
srcAltitude = unit != null ? unit.Altitude : 0,
dest = target.CenterLocation.ToInt2(),
destAltitude = destUnit != null ? destUnit.Altitude : 0,
@@ -252,6 +253,16 @@ namespace OpenRA.Traits
target = null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
switch (s)
{
case "Attack": return "attack";
case "Heal": return "heal";
default: return null;
}
}
protected virtual void QueueAttack(Actor self, Order order)
{
/* todo: choose the appropriate weapon, when only one works against this target */

View File

@@ -19,6 +19,7 @@
#endregion
using System;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -19,8 +19,8 @@
#endregion
using System.Linq;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
{
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
bool NeedsNewTarget(Actor self)
{
var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self);
var range = Combat.GetMaximumRange(self);
if (attack.target == null)
return true; // he's dead.
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
var range = Util.GetMaximumRange(self);
var range = Combat.GetMaximumRange(self);
if (NeedsNewTarget(self))
AttackTarget(self, ChooseTarget(self, range));

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
if (--nextScanTime <= 0)
{
var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self);
var range = Combat.GetMaximumRange(self);
if (attack.target == null ||
(attack.target.Location - self.Location).LengthSquared > range * range)

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
public readonly float C4Delay = 0;
}
class C4Demolition : IIssueOrder, IResolveOrder
class C4Demolition : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -51,5 +51,10 @@ namespace OpenRA.Mods.RA
self.QueueActivity(new Move(self.Location, 0));
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "C4") ? "c4" : null;
}
}
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
public readonly int UnloadFacing = 0;
}
public class Cargo : IPips, IIssueOrder, IResolveOrder
public class Cargo : IPips, IIssueOrder, IResolveOrder, IProvideCursor
{
List<Actor> cargo = new List<Actor>();
@@ -59,6 +59,11 @@ namespace OpenRA.Mods.RA
self.QueueActivity(new UnloadCargo());
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Deploy") ? "deploy" : null;
}
public bool IsFull(Actor self)
{

View File

@@ -46,9 +46,8 @@ namespace OpenRA.Mods.RA
{
get
{
return !info.RequiresConstructionYard ||
Game.world.Queries.OwnedBy[Game.world.LocalPlayer]
.WithTrait<ConstructionYard>().Any();
// WTF: why are these buttons even traits?
return RepairOrderGenerator.PlayerIsAllowedToRepair( Game.world );
}
}

56
OpenRA.Game/Combat.cs → OpenRA.Mods.RA/Combat.cs Normal file → Executable file
View File

@@ -22,10 +22,10 @@ using System;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA
namespace OpenRA.Mods.RA
{
public static class Combat /* some utility bits that are shared between various things */
{
@@ -194,5 +194,57 @@ namespace OpenRA
return false;
}
public static float GetMaximumRange(Actor self)
{
return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
.Where(w => w != null).Max(w => w.Range);
}
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static WeaponInfo GetSecondaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.SecondaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
static float2 GetRecoil(Actor self, float recoil)
{
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
if (rut == null) return float2.Zero;
var facing = self.traits.Get<Turreted>().turretFacing;
return Util.RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().Recoil), facing, .7f);
}
public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil)
{
if( unit == null ) return offset.AbsOffset(); /* things that don't have a rotating base don't need the turrets repositioned */
var ru = self.traits.GetOrDefault<RenderUnit>();
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
var bodyFacing = unit.Facing;
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
return (Util.RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil))
+ offset.AbsOffset();
}
}
}

View File

@@ -18,13 +18,14 @@
*/
#endregion
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{
class ConstructionYardInfo : TraitInfo<ConstructionYard> { }
public class ConstructionYard : IIssueOrder, IResolveOrder
public class ConstructionYard : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -36,6 +37,11 @@ namespace OpenRA.Traits
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Deploy") ? "deploy" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Deploy")
@@ -45,9 +51,4 @@ namespace OpenRA.Traits
}
}
}
/* tag trait for "bases": mcv/fact */
class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
class BaseBuilding { }
}

View File

@@ -77,8 +77,6 @@ namespace OpenRA.Mods.RA
if (self.World.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(p) != null) continue;
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any()) continue;
System.Console.WriteLine("Spawning crate at {0}", p);
self.World.AddFrameEndTask(
w => crates.Add(w.CreateActor("crate", p, self.World.WorldActor.Owner)));
return;

View File

@@ -20,11 +20,12 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
namespace OpenRA.Mods.RA.Effects
{
public class BulletInfo : IProjectileInfo
{
@@ -33,11 +34,11 @@ namespace OpenRA.Effects
public readonly float Inaccuracy = 0; // pixels at maximum range
public readonly string Image = null;
public readonly bool High = false;
public readonly bool Arcing = false;
public readonly int RangeLimit = 0;
public readonly int Arm = 0;
public readonly bool Shadow = false;
public readonly bool Proximity = false;
public readonly float Angle = 0;
public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); }
}
@@ -65,13 +66,33 @@ namespace OpenRA.Effects
if (Info.Image != null)
{
anim = new Animation(Info.Image, () => Traits.Util.GetFacing(Args.dest - Args.src, 0));
anim = new Animation(Info.Image, GetEffectiveFacing);
anim.PlayRepeating("idle");
}
}
int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }
float GetAltitude()
{
var at = (float)t / TotalTime();
return (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at);
}
int GetEffectiveFacing()
{
var at = (float)t / TotalTime();
var attitude = Info.Angle * (1 - 2 * at);
var rawFacing = Traits.Util.GetFacing(Args.dest - Args.src, 0);
var u = (rawFacing % 128) / 128f;
var scale = 512 * u * (1 - u);
return (int)(rawFacing < 128
? rawFacing - scale * attitude
: rawFacing + scale * attitude);
}
public void Tick( World world )
{
t += 40;
@@ -86,8 +107,8 @@ namespace OpenRA.Effects
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
var highPos = (Info.High || Info.Arcing)
? (pos - new float2(0, (Args.dest - Args.src).Length * height * 4 * at * (1 - at)))
var highPos = (Info.High || Info.Angle > 0)
? (pos - new float2(0, GetAltitude()))
: pos;
world.AddFrameEndTask(w => w.Add(
@@ -120,12 +141,12 @@ namespace OpenRA.Effects
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
if (Info.High || Info.Arcing)
if (Info.High || Info.Angle > 0)
{
if (Info.Shadow)
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow");
var highPos = pos - new float2(0, (Args.dest - Args.src).Length * height * 4 * at * (1 - at));
var highPos = pos - new float2(0, GetAltitude());
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette);
}

View File

@@ -19,11 +19,12 @@
#endregion
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
namespace OpenRA.Mods.RA.Effects
{
public class GravityBombInfo : IProjectileInfo
{

View File

@@ -20,10 +20,11 @@
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Traits;
namespace OpenRA.Effects
namespace OpenRA.Mods.RA.Effects
{
class LaserZapInfo : IProjectileInfo
{
@@ -75,7 +76,7 @@ namespace OpenRA.Effects
float2 norm = new float2(-unit.Y, unit.X);
for (int i = -radius; i < radius; i++)
Game.world.WorldRenderer.lineRenderer.DrawLine(args.src + i * norm, args.dest + i * norm, rc, rc);
Game.world.WorldRenderer.DrawLine(args.src + i * norm, args.dest + i * norm, rc, rc);
yield break;
}

View File

@@ -21,11 +21,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
namespace OpenRA.Mods.RA.Effects
{
class MissileInfo : IProjectileInfo
{

View File

@@ -21,11 +21,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
namespace OpenRA.Mods.RA.Effects
{
class TeslaZapInfo : IProjectileInfo
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
public readonly int EngineerDamage = 300;
}
class EngineerCapture : IIssueOrder, IResolveOrder
class EngineerCapture : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
@@ -48,6 +48,12 @@ namespace OpenRA.Mods.RA
self, underCursor);
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Infiltrate") ? "enter" :
(s == "Capture") ? "capture" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Infiltrate" || order.OrderString == "Capture")

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new Harvester(init.self, this); }
}
public class Harvester : IIssueOrder, IResolveOrder, INotifyDamage, IPips, IRenderModifier, IExplodeModifier
public class Harvester : IIssueOrder, IResolveOrder, INotifyDamage, IPips, IRenderModifier, IExplodeModifier, IProvideCursor
{
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
@@ -113,7 +113,13 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Deliver") ? "enter" :
(s == "Harvest") ? "attackmove" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Harvest")

View File

@@ -16,12 +16,13 @@
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
using System.Linq;
using System.Collections.Generic;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{
class AntiAirInfo : ITraitInfo
{

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA
public override object Create( ActorInitializer init ) { return new Helicopter( init ); }
}
class Helicopter : Aircraft, ITick, IIssueOrder, IResolveOrder
class Helicopter : Aircraft, ITick, IIssueOrder, IResolveOrder, IProvideCursor
{
public IDisposable reservation;
@@ -61,6 +61,11 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Enter") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
public readonly string[] RearmBuildings = { "fix" };
}
class Minelayer : IIssueOrder, IResolveOrder
class Minelayer : IIssueOrder, IResolveOrder, IProvideCursor
{
/* [Sync] when sync can cope with arrays! */ public int2[] minefield = null;
[Sync] int2 minefieldStart;
@@ -49,6 +49,11 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "BeginMinefield") ? "ability" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "BeginMinefield")

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -46,6 +46,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\Attack.cs" />
<Compile Include="Activities\CallFunc.cs" />
<Compile Include="Activities\CaptureBuilding.cs" />
<Compile Include="Activities\DeliverOre.cs" />
@@ -67,10 +68,25 @@
<Compile Include="Activities\Repair.cs" />
<Compile Include="Activities\ReturnToBase.cs" />
<Compile Include="Activities\Teleport.cs" />
<Compile Include="Activities\UndeployMcv.cs" />
<Compile Include="Activities\UnloadCargo.cs" />
<Compile Include="Activities\Wait.cs" />
<Compile Include="AttackBase.cs" />
<Compile Include="Combat.cs" />
<Compile Include="ConstructionYard.cs" />
<Compile Include="Effects\Bullet.cs" />
<Compile Include="Effects\GravityBomb.cs" />
<Compile Include="Effects\LaserZap.cs" />
<Compile Include="Effects\Missile.cs" />
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Hazardous.cs" />
<Compile Include="Player\ActorGroupProxy.cs" />
<Compile Include="Aircraft.cs" />
<Compile Include="AirstrikePower.cs" />
<Compile Include="Render\RenderBuilding.cs" />
<Compile Include="Render\RenderBuildingTurreted.cs" />
<Compile Include="Render\RenderUnit.cs" />
<Compile Include="Render\RenderUnitTurreted.cs" />
<Compile Include="SupportPowers\AirstrikePower.cs" />
<Compile Include="AttackFrontal.cs" />
<Compile Include="AttackHeli.cs" />
<Compile Include="AttackLeap.cs" />
@@ -116,7 +132,7 @@
<Compile Include="LightPaletteRotator.cs" />
<Compile Include="OreRefinery.cs" />
<Compile Include="ChronoshiftPaletteEffect.cs" />
<Compile Include="ChronoshiftPower.cs" />
<Compile Include="SupportPowers\ChronoshiftPower.cs" />
<Compile Include="Crates\ArmorUpgradeCrateAction.cs" />
<Compile Include="Crates\ExplodeCrateAction.cs" />
<Compile Include="Crates\FirepowerUpgradeCrateAction.cs" />
@@ -126,33 +142,33 @@
<Compile Include="Effects\Parachute.cs" />
<Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="EngineerCapture.cs" />
<Compile Include="GpsPower.cs" />
<Compile Include="SupportPowers\GpsPower.cs" />
<Compile Include="InfiltrateForSonarPulse.cs" />
<Compile Include="IronCurtainable.cs" />
<Compile Include="IronCurtainPower.cs" />
<Compile Include="SupportPowers\IronCurtainPower.cs" />
<Compile Include="PaletteFromFile.cs" />
<Compile Include="PaletteFromRGBA.cs" />
<Compile Include="ParaDrop.cs" />
<Compile Include="ParatroopersPower.cs" />
<Compile Include="SupportPowers\ParatroopersPower.cs" />
<Compile Include="Passenger.cs" />
<Compile Include="Plane.cs" />
<Compile Include="ProductionSurround.cs" />
<Compile Include="RenderBuildingCharge.cs" />
<Compile Include="RenderBuildingOre.cs" />
<Compile Include="RenderBuildingWall.cs" />
<Compile Include="RenderBuildingWarFactory.cs" />
<Compile Include="RenderFlare.cs" />
<Compile Include="RenderInfantry.cs" />
<Compile Include="RenderUnitReload.cs" />
<Compile Include="RenderUnitRotor.cs" />
<Compile Include="RenderUnitSpinner.cs" />
<Compile Include="Render\RenderBuildingCharge.cs" />
<Compile Include="Render\RenderBuildingOre.cs" />
<Compile Include="Render\RenderBuildingWall.cs" />
<Compile Include="Render\RenderBuildingWarFactory.cs" />
<Compile Include="Render\RenderFlare.cs" />
<Compile Include="Render\RenderInfantry.cs" />
<Compile Include="Render\RenderUnitReload.cs" />
<Compile Include="Render\RenderUnitRotor.cs" />
<Compile Include="Render\RenderUnitSpinner.cs" />
<Compile Include="Repairable.cs" />
<Compile Include="RepairsUnits.cs" />
<Compile Include="RequiresPower.cs" />
<Compile Include="Mine.cs" />
<Compile Include="Minelayer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RenderSpy.cs" />
<Compile Include="Render\RenderSpy.cs" />
<Compile Include="RepairableNear.cs" />
<Compile Include="Crates\SpeedUpgradeCrateAction.cs" />
<Compile Include="Reservable.cs" />
@@ -161,12 +177,12 @@
<Compile Include="SeedsResource.cs" />
<Compile Include="SelfHealing.cs" />
<Compile Include="ShroudPalette.cs" />
<Compile Include="SonarPulsePower.cs" />
<Compile Include="SupportPowers\SonarPulsePower.cs" />
<Compile Include="SpawnDefaultUnits.cs" />
<Compile Include="SpawnMapActors.cs" />
<Compile Include="Spy.cs" />
<Compile Include="SpyPlanePower.cs" />
<Compile Include="NukePower.cs" />
<Compile Include="SupportPowers\SpyPlanePower.cs" />
<Compile Include="SupportPowers\NukePower.cs" />
<Compile Include="TakeCover.cs" />
<Compile Include="TeslaInstantKills.cs" />
<Compile Include="Crates\ResetRadarCrateAction.cs" />
@@ -185,6 +201,9 @@
<Compile Include="OreRefineryDockAction.cs" />
<Compile Include="Activities\Drag.cs" />
<Compile Include="ProducesHelicopters.cs" />
<Compile Include="StoresOre.cs" />
<Compile Include="TransformsOnDeploy.cs" />
<Compile Include="Activities\TransformIntoActor.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -52,14 +52,20 @@ namespace OpenRA.Mods.RA.Orders
public void Tick( World world )
{
var hasFact = world.Queries.OwnedBy[world.LocalPlayer]
.WithTrait<ConstructionYard>()
.Any();
if (!hasFact)
if( PlayerIsAllowedToRepair( world ) )
Game.controller.CancelInputMode();
}
public static bool PlayerIsAllowedToRepair( World world )
{
if( !world.WorldActor.Info.Traits.Get<RepairButtonInfo>().RequiresConstructionYard )
return true;
return Game.world.Queries.OwnedBy[ Game.world.LocalPlayer ]
.WithTrait<Production>().Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( "Building" ) )
.Any();
}
public void Render( World world ) {}
public string GetCursor(World world, int2 xy, MouseInput mi)

View File

@@ -18,8 +18,9 @@
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
public readonly PipType ColorOfCargoPip = PipType.Green;
}
class Passenger : IIssueOrder, IResolveOrder
class Passenger : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -51,6 +51,11 @@ namespace OpenRA.Mods.RA
return new Order("EnterTransport", self, underCursor);
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "EnterTransport") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
public override object Create( ActorInitializer init ) { return new Plane( init ); }
}
public class Plane : Aircraft, IIssueOrder, IResolveOrder
public class Plane : Aircraft, IIssueOrder, IResolveOrder, IProvideCursor
{
public IDisposable reservation;
@@ -50,7 +50,12 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Enter") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (reservation != null)

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{
class ActorGroupProxyInfo : TraitInfo<ActorGroupProxy> { }

View File

@@ -20,8 +20,9 @@
using System;
using OpenRA.Effects;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA.Render
{
public class RenderBuildingInfo : RenderSimpleInfo
{
@@ -52,18 +53,6 @@ namespace OpenRA.Traits
x.BuildingComplete( self );
}
protected string GetPrefix(Actor self)
{
return self.GetDamageState() == DamageState.Half ? "damaged-" : "";
}
public void PlayCustomAnim(Actor self, string name)
{
if (anim.HasSequence(name))
anim.PlayThen(GetPrefix(self) + name,
() => anim.PlayRepeating(GetPrefix(self) + "idle"));
}
public void PlayCustomAnimThen(Actor self, string name, Action a)
{
anim.PlayThen(GetPrefix(self) + name,

View File

@@ -18,9 +18,7 @@
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingChargeInfo : RenderBuildingInfo
{

View File

@@ -20,7 +20,7 @@
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingOreInfo : RenderBuildingInfo
{

View File

@@ -18,7 +18,9 @@
*/
#endregion
namespace OpenRA.Traits
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingTurretedInfo : RenderBuildingInfo
{

View File

@@ -19,10 +19,9 @@
#endregion
using System.Linq;
using System;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingWallInfo : RenderBuildingInfo
{

View File

@@ -22,7 +22,7 @@ using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderWarFactoryInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
{

View File

@@ -20,7 +20,7 @@
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderFlareInfo : RenderSimpleInfo
{

View File

@@ -22,7 +22,7 @@ using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
public class RenderInfantryInfo : RenderSimpleInfo
{

View File

@@ -22,7 +22,7 @@ using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderSpyInfo : RenderInfantryInfo
{

View File

@@ -20,8 +20,9 @@
using System;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA.Render
{
public class RenderUnitInfo : RenderSimpleInfo
{

View File

@@ -18,10 +18,10 @@
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitReloadInfo : RenderUnitInfo
{

View File

@@ -21,7 +21,7 @@
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitRotorInfo : RenderUnitInfo
{
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
rotorAnim.PlayRepeating("rotor");
anims.Add( "rotor_1", new AnimationWithOffset(
rotorAnim,
() => Traits.Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
() => Combat.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
null ) { ZOffset = 1 } );
if (info.SecondaryOffset == null) return;
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
secondRotorAnim.PlayRepeating( "rotor2" );
anims.Add( "rotor_2", new AnimationWithOffset(
secondRotorAnim,
() => Traits.Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
() => Combat.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
null) { ZOffset = 1 });
}

View File

@@ -21,7 +21,7 @@
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.RA.Render
{
class RenderUnitSpinnerInfo : RenderUnitInfo
{
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
spinnerAnim.PlayRepeating( "spinner" );
anims.Add( "spinner", new AnimationWithOffset(
spinnerAnim,
() => Traits.Util.GetTurretPosition( self, unit, info.Offset, 0 ),
() => Combat.GetTurretPosition( self, unit, info.Offset, 0 ),
null ) { ZOffset = 1 } );
}
}

View File

@@ -19,8 +19,9 @@
#endregion
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA.Render
{
class RenderUnitTurretedInfo : RenderUnitInfo
{
@@ -43,13 +44,13 @@ namespace OpenRA.Traits
if( attackInfo.PrimaryOffset != null )
anims.Add("turret_1", new AnimationWithOffset(
turretAnim,
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
() => Combat.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
null) { ZOffset = 1 });
if (attackInfo.SecondaryOffset != null)
anims.Add("turret_2", new AnimationWithOffset(
turretAnim,
() => Util.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil),
() => Combat.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil),
null) { ZOffset = 1 });
if( attackInfo.MuzzleFlash )
@@ -59,7 +60,7 @@ namespace OpenRA.Traits
() => (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */
anims.Add( "muzzle_flash", new AnimationWithOffset(
muzzleFlash,
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
() => Combat.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
() => attack.primaryRecoil <= 0 ) );
}
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
{
class RepairableInfo : TraitInfo<Repairable> { public readonly string[] RepairBuildings = { "fix" }; }
class Repairable : IIssueOrder, IResolveOrder
class Repairable : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -41,9 +41,13 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Enter") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Enter")
{
var rp = order.TargetActor.traits.GetOrDefault<RallyPoint>();

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
public readonly string[] Buildings = { "spen", "syrd" };
}
class RepairableNear : IIssueOrder, IResolveOrder
class RepairableNear : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -46,6 +46,11 @@ namespace OpenRA.Mods.RA
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Enter") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Enter")

View File

@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
{
class SpyInfo : TraitInfo<Spy> { }
class Spy : IIssueOrder, IResolveOrder
class Spy : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -38,6 +38,11 @@ namespace OpenRA.Mods.RA
return new Order("Infiltrate", self, underCursor);
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
return (s == "Infiltrate") ? "enter" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Infiltrate")

View File

@@ -19,8 +19,9 @@
#endregion
using System.Collections.Generic;
namespace OpenRA.Traits
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class StoresOreInfo : ITraitInfo
{
@@ -30,7 +31,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
}
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre
{
readonly PlayerResources Player;
readonly StoresOreInfo Info;
@@ -41,6 +42,8 @@ namespace OpenRA.Traits
Info = info;
}
public int Capacity { get { return Info.Capacity; } }
public void OnCapture(Actor self, Actor captor)
{
var ore = Stored(self);

View File

@@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA

View File

@@ -20,6 +20,7 @@
using System.Linq;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Render;
using OpenRA.Orders;
using OpenRA.Traits;

View File

@@ -19,6 +19,7 @@
#endregion
using OpenRA.Graphics;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -57,7 +58,7 @@ namespace OpenRA.Mods.RA
if (info != null)
{
alt = 0;
pos = Traits.Util.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
pos = Combat.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
var ru = self.traits.Get<RenderUnit>();
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();

View File

@@ -18,9 +18,11 @@
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{
class TransformsOnDeployInfo : TraitInfo<TransformsOnDeploy>
{
@@ -33,7 +35,7 @@ namespace OpenRA.Traits
public readonly string[] NoTransformSounds = null;
}
class TransformsOnDeploy : IIssueOrder, IResolveOrder
class TransformsOnDeploy : IIssueOrder, IResolveOrder, IProvideCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
@@ -77,5 +79,21 @@ namespace OpenRA.Traits
self.QueueActivity(new TransformIntoActor(info.TransformsInto, new int2(info.Offset[0], info.Offset[1]), info.TransferHealthPercentage, info.TransformSounds));
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
{
if (s != "DeployTransform")
return null;
var depInfo = a.Info.Traits.Get<TransformsOnDeployInfo>();
var transInfo = Rules.Info[depInfo.TransformsInto];
if (transInfo.Traits.Contains<BuildingInfo>())
{
var bi = transInfo.Traits.Get<BuildingInfo>();
if (!a.World.CanPlaceBuilding(depInfo.TransformsInto, bi, a.Location + new int2(depInfo.Offset[0], depInfo.Offset[1]), a))
return "deploy-blocked";
}
return "deploy";
}
}
}

View File

@@ -1,6 +1,6 @@
Player:
ProductionQueue:
BuildSpeed: .004
BuildSpeed: .4
LowPowerSlowdown: 3
PlaceBuilding:
TechTreeCache:
@@ -231,8 +231,8 @@ World:
Shroud:
CrateSpawner:
Minimum: 1
Maximum: 300
SpawnInterval: 12
Maximum: 3
SpawnInterval: 120
WaterChance: 0
CRATE:

View File

@@ -203,7 +203,7 @@ Grenade:
Bullet:
Speed: 5
High: yes
Arcing: yes
Angle: .1
Inaccuracy: 5
Image: BOMB
Warhead:
@@ -354,7 +354,7 @@ Ballistic:
Bullet:
Speed: 12
High: yes
Arcing: yes
Angle: .1
Inaccuracy: 5
Image: 120MM
Warhead:

View File

@@ -229,7 +229,7 @@ Grenade:
Bullet:
Speed: 5
High: true
Arcing: true
Angle: .1
Inaccuracy: 13
Image: BOMB
Warhead:
@@ -358,7 +358,7 @@ MammothTusk:
Bullet:
Speed: 12
High: true
Arcing: true
Angle: .1
Inaccuracy: 80
Image: 120MM
Warhead:
@@ -492,7 +492,7 @@ RedEye:
Bullet:
Speed: 12
High: true
Arcing: true
Angle: .1
Inaccuracy: 120
Image: 120MM
Warhead:
@@ -571,7 +571,7 @@ DepthCharge:
Bullet:
Speed: 5
Image: BOMB
Arcing: true
Angle: .1
High: true
Inaccuracy: 3
Warhead:
@@ -633,6 +633,7 @@ SCUD:
Trail: smokey
Inaccuracy: 5
Image: V2
Angle: .1
Warhead:
Spread: 8
Verses: 90%,75%,60%,25%,100%

Some files were not shown because too many files have changed in this diff Show More