Compare commits
142 Commits
playtest-2
...
playtest-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcf7328d77 | ||
|
|
02350e6ac8 | ||
|
|
ee0f90708f | ||
|
|
5d823d8e6e | ||
|
|
3870be5122 | ||
|
|
1bd7a9b590 | ||
|
|
e60acc682a | ||
|
|
aa239d172d | ||
|
|
5f48577ebc | ||
|
|
fd014e15a5 | ||
|
|
1839655eb5 | ||
|
|
e7c7a117a8 | ||
|
|
a6d0adbab3 | ||
|
|
52c69addc6 | ||
|
|
493dec031b | ||
|
|
1e570b5edb | ||
|
|
f2bcf1afae | ||
|
|
b45c74fa0b | ||
|
|
f946382e38 | ||
|
|
5a5fa37397 | ||
|
|
c531343481 | ||
|
|
b57ebcffea | ||
|
|
f89e9f6d06 | ||
|
|
b5327a2cb7 | ||
|
|
d379a1f78b | ||
|
|
90e1e0e796 | ||
|
|
f3a0c94eb5 | ||
|
|
540a2da82a | ||
|
|
8285c7d158 | ||
|
|
ac10ca3fad | ||
|
|
d824373853 | ||
|
|
94e8edb1cd | ||
|
|
b61db88402 | ||
|
|
9b11e79592 | ||
|
|
2ca9a936a3 | ||
|
|
584a7091db | ||
|
|
c1f76da011 | ||
|
|
ba850ec3f1 | ||
|
|
04dceb4417 | ||
|
|
996344ea6e | ||
|
|
a259a0aca0 | ||
|
|
a399e0b682 | ||
|
|
ce9f7666b4 | ||
|
|
4dcc65237d | ||
|
|
8ca03da277 | ||
|
|
3f32275169 | ||
|
|
230625897a | ||
|
|
1bd9dc7536 | ||
|
|
294240de7f | ||
|
|
0c8e8b5658 | ||
|
|
a070820695 | ||
|
|
c15d721884 | ||
|
|
c792ce5686 | ||
|
|
49b1870eaa | ||
|
|
a35d6207a9 | ||
|
|
9dc8422adf | ||
|
|
b286a71487 | ||
|
|
92ba40da1a | ||
|
|
270941cfde | ||
|
|
e7b7f69caf | ||
|
|
878039fc4a | ||
|
|
fcea5bd2f0 | ||
|
|
e8829f8e92 | ||
|
|
081d1cdafc | ||
|
|
f3a73fa53d | ||
|
|
81ccc6a0c8 | ||
|
|
08756b7b4c | ||
|
|
5c9d6362c1 | ||
|
|
d109dad4a2 | ||
|
|
f5b313b5e8 | ||
|
|
7ef2ed1434 | ||
|
|
2dfa4d9db7 | ||
|
|
78455a3dce | ||
|
|
35ca5f80b2 | ||
|
|
9837b4ce32 | ||
|
|
a6f5b12a55 | ||
|
|
bbbd65a6eb | ||
|
|
d9931af5ae | ||
|
|
b8b3ef61aa | ||
|
|
e850937022 | ||
|
|
5ca590a16a | ||
|
|
f77c12e9a0 | ||
|
|
431bbe2764 | ||
|
|
224489502e | ||
|
|
027d7e2c2b | ||
|
|
9dd1032683 | ||
|
|
baf37f7d04 | ||
|
|
bb289101fc | ||
|
|
6cbebeebd5 | ||
|
|
e5bb541824 | ||
|
|
4d7de9e790 | ||
|
|
87d7fd163b | ||
|
|
b662cebfb8 | ||
|
|
630aee7b98 | ||
|
|
560c41bf42 | ||
|
|
40f981a80d | ||
|
|
e9799ffdfa | ||
|
|
7609097f4f | ||
|
|
91a4ac5faf | ||
|
|
586d5ec11e | ||
|
|
3276a4f557 | ||
|
|
9215fa4d28 | ||
|
|
43eb4b03ea | ||
|
|
1d0848466f | ||
|
|
b0d2bf2e51 | ||
|
|
7fc5007ac8 | ||
|
|
f75a2d2fe6 | ||
|
|
be974f7970 | ||
|
|
d008fd9eed | ||
|
|
b1327378ed | ||
|
|
7910f3fe54 | ||
|
|
e5951b1502 | ||
|
|
4585addff2 | ||
|
|
d3332a7454 | ||
|
|
5deea6df93 | ||
|
|
561a2a86d0 | ||
|
|
99acb65502 | ||
|
|
248eba20fa | ||
|
|
342ef2a498 | ||
|
|
a33bb7bd8a | ||
|
|
50cc18d1f4 | ||
|
|
ed21b3be8d | ||
|
|
151f5acb2f | ||
|
|
f9a2c20eee | ||
|
|
e910ab87a1 | ||
|
|
a49efda001 | ||
|
|
55a58394e4 | ||
|
|
76bcd7cb26 | ||
|
|
5adfd908c4 | ||
|
|
82c895adee | ||
|
|
382636a3ba | ||
|
|
3cbd62c6ec | ||
|
|
7a426778d4 | ||
|
|
490d8d5a5f | ||
|
|
b9ca655756 | ||
|
|
47af8fc8f2 | ||
|
|
a6a1c1aabc | ||
|
|
5c7838bafa | ||
|
|
56ec24a84e | ||
|
|
3475712075 | ||
|
|
78aa7bb3a9 | ||
|
|
5c48465c65 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,6 +21,7 @@ log.txt
|
||||
|
||||
#binary stuff
|
||||
/*.dll
|
||||
*.pdb
|
||||
*.mdb
|
||||
/*.exe
|
||||
OpenRA
|
||||
|
||||
@@ -112,7 +112,6 @@ namespace MapConverter
|
||||
foreach (var pkg in manifest.Packages) FileSystem.Mount(pkg);
|
||||
|
||||
ConvertIniMap(args[1]);
|
||||
Map.DebugContents();
|
||||
Save(args[2]);
|
||||
}
|
||||
|
||||
@@ -275,7 +274,7 @@ namespace MapConverter
|
||||
Map.MapResources[i,j] = new TileReference<byte,byte>(res.First, res.Second);
|
||||
|
||||
if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o]))
|
||||
Map.Actors.Add("Actor"+ActorCount++, new ActorReference( overlayActorMapping[raOverlayNames[o]], new int2(i,j), "Neutral"));
|
||||
Map.Actors.Add("Actor"+ActorCount, new ActorReference("Actor"+ActorCount++, overlayActorMapping[raOverlayNames[o]], new int2(i,j), "Neutral"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +287,7 @@ namespace MapConverter
|
||||
foreach( KeyValuePair<string, string> kv in terrain )
|
||||
{
|
||||
var loc = int.Parse( kv.Key );
|
||||
Map.Actors.Add("Actor"+ActorCount++, new ActorReference(kv.Value.ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), "Neutral" ) );
|
||||
Map.Actors.Add("Actor"+ActorCount, new ActorReference("Actor"+ActorCount++,kv.Value.ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), "Neutral" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +328,7 @@ namespace MapConverter
|
||||
Map.MapResources[ cell.X, cell.Y ] = new TileReference<byte,byte>(res.First, res.Second);
|
||||
|
||||
if (overlayActorMapping.ContainsKey(kv.Value.ToLower()))
|
||||
Map.Actors.Add("Actor"+ActorCount++, new ActorReference( overlayActorMapping[kv.Value.ToLower()], new int2(cell.X,cell.Y), "Neutral"));
|
||||
Map.Actors.Add("Actor"+ActorCount, new ActorReference("Actor"+ActorCount++, overlayActorMapping[kv.Value.ToLower()], new int2(cell.X,cell.Y), "Neutral"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +342,7 @@ namespace MapConverter
|
||||
foreach( KeyValuePair<string, string> kv in terrain )
|
||||
{
|
||||
var loc = int.Parse( kv.Key );
|
||||
Map.Actors.Add("Actor"+ActorCount++, new ActorReference( kv.Value.Split(',')[0].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize),"Neutral"));
|
||||
Map.Actors.Add("Actor"+ActorCount, new ActorReference("Actor"+ActorCount++, kv.Value.Split(',')[0].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize),"Neutral"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +355,7 @@ namespace MapConverter
|
||||
var loc = int.Parse(parts[3]);
|
||||
if (parts[0] == "")
|
||||
parts[0] = "Neutral";
|
||||
Map.Actors.Add("Actor"+ActorCount++, new ActorReference( parts[1].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), parts[0]));
|
||||
Map.Actors.Add("Actor"+ActorCount, new ActorReference("Actor"+ActorCount++, parts[1].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), parts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -28,7 +28,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
@@ -44,5 +44,5 @@
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,4 +1,24 @@
|
||||
using System;
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -17,10 +37,11 @@ namespace OpenRA.Editor
|
||||
{
|
||||
InitializeComponent();
|
||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||
LocateGameRoot();
|
||||
|
||||
currentMod = mods.FirstOrDefault() ?? "ra";
|
||||
|
||||
Text = "OpenRA Editor (mod:{0})".F(currentMod);
|
||||
|
||||
var manifest = new Manifest(new[] { currentMod });
|
||||
Game.LoadModAssemblies(manifest);
|
||||
|
||||
@@ -29,6 +50,8 @@ namespace OpenRA.Editor
|
||||
foreach (var pkg in manifest.Packages) FileSystem.Mount(pkg);
|
||||
|
||||
Rules.LoadRules(manifest, new Map());
|
||||
|
||||
folderBrowser.SelectedPath = Environment.CurrentDirectory + "mods\\" + currentMod + "\\maps";
|
||||
}
|
||||
|
||||
string loadedMapName;
|
||||
@@ -80,10 +103,11 @@ namespace OpenRA.Editor
|
||||
Rules.LoadRules(manifest, map);
|
||||
|
||||
// we're also going to need a tileset...
|
||||
var tsinfo = fileMapping[Pair.New(currentMod, map.Theater)];
|
||||
tileset = new TileSet("tileset.til", "templates.ini", tsinfo.First);
|
||||
var theaterInfo = Rules.Info["world"].Traits.WithInterface<TheaterInfo>()
|
||||
.FirstOrDefault(t => t.Theater == map.Theater);
|
||||
|
||||
colors = tsinfo.Second;
|
||||
tileset = new TileSet(theaterInfo.Tileset, theaterInfo.Templates, theaterInfo.Suffix);
|
||||
colors = theaterInfo.MapColors;
|
||||
|
||||
var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true);
|
||||
|
||||
@@ -91,6 +115,9 @@ namespace OpenRA.Editor
|
||||
|
||||
// construct the palette of tiles
|
||||
|
||||
var palettes = new[] { tilePalette, actorPalette, resourcePalette };
|
||||
foreach (var p in palettes) { p.Visible = false; p.SuspendLayout(); }
|
||||
|
||||
foreach (var n in tileset.tiles.Keys)
|
||||
{
|
||||
try
|
||||
@@ -128,7 +155,7 @@ namespace OpenRA.Editor
|
||||
try
|
||||
{
|
||||
var info = Rules.Info[a];
|
||||
var template = RenderActor(info, tsinfo.First, palette);
|
||||
var template = RenderActor(info, theaterInfo.Suffix, palette);
|
||||
var ibox = new PictureBox
|
||||
{
|
||||
Image = template.Bitmap,
|
||||
@@ -159,7 +186,7 @@ namespace OpenRA.Editor
|
||||
{
|
||||
try
|
||||
{
|
||||
var template = RenderResourceType(a, tsinfo.First, palette);
|
||||
var template = RenderResourceType(a, theaterInfo.Suffix, palette);
|
||||
var ibox = new PictureBox
|
||||
{
|
||||
Image = template.Bitmap,
|
||||
@@ -183,29 +210,10 @@ namespace OpenRA.Editor
|
||||
}
|
||||
|
||||
surface1.BindResourceTemplates(resourceTemplates);
|
||||
}
|
||||
|
||||
void LocateGameRoot()
|
||||
{
|
||||
while (!Directory.Exists("mods"))
|
||||
{
|
||||
var current = Directory.GetCurrentDirectory();
|
||||
if (Directory.GetDirectoryRoot(current) == current)
|
||||
throw new InvalidOperationException("Unable to find game root.");
|
||||
Directory.SetCurrentDirectory("..");
|
||||
}
|
||||
foreach (var p in palettes) { p.Visible = true; p.ResumeLayout(); }
|
||||
}
|
||||
|
||||
static Dictionary<Pair<string, string>, Pair<string, string>> fileMapping = new Dictionary<Pair<string, string>, Pair<string, string>>()
|
||||
{
|
||||
{Pair.New("ra","TEMPERAT"),Pair.New("tem","temperat.col")},
|
||||
{Pair.New("ra","SNOW"),Pair.New("sno","snow.col")},
|
||||
{Pair.New("ra","INTERIOR"),Pair.New("int","temperat.col")},
|
||||
{Pair.New("cnc","DESERT"),Pair.New("des","desert.col")},
|
||||
{Pair.New("cnc","TEMPERAT"),Pair.New("tem","temperat.col")},
|
||||
{Pair.New("cnc","WINTER"),Pair.New("win","winter.col")},
|
||||
};
|
||||
|
||||
static Bitmap RenderTemplate(TileSet ts, ushort n, Palette p)
|
||||
{
|
||||
var template = ts.walk[n];
|
||||
@@ -389,26 +397,12 @@ namespace OpenRA.Editor
|
||||
{
|
||||
var map = new Map();
|
||||
|
||||
map.MapSize = new int2(1, 1);
|
||||
map.MapResources = new TileReference<byte, byte>[1, 1];
|
||||
map.MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
{ { new TileReference<ushort, byte> {
|
||||
type = currentMod == "cnc" ? (ushort)0xffu : (ushort)0xffffu,
|
||||
image = (byte)0xffu,
|
||||
index = (byte)0xffu } } };
|
||||
|
||||
map.Resize((int)nmd.width.Value, (int)nmd.height.Value);
|
||||
|
||||
map.PlayerCount = 8;
|
||||
|
||||
map.TopLeft = new int2((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value);
|
||||
map.BottomRight = new int2((int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
||||
|
||||
map.Tileset = nmd.theater.SelectedItem as string;
|
||||
|
||||
map.Title = "Name your map here";
|
||||
map.Description = "Describe your map here";
|
||||
map.Author = "Your name here";
|
||||
|
||||
NewMap(map);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Thirdparty;
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
@@ -91,6 +92,47 @@ namespace OpenRA.Editor
|
||||
}
|
||||
}
|
||||
|
||||
void FloodFillWithBrush(int2 pos)
|
||||
{
|
||||
var queue = new Queue<int2>();
|
||||
var replace = Map.MapTiles[pos.X, pos.Y];
|
||||
|
||||
queue.Enqueue(pos);
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var p = queue.Dequeue();
|
||||
if (!Map.MapTiles[p.X, p.Y].Equals(replace))
|
||||
continue;
|
||||
|
||||
var a = FindEdge(p, new int2(-1, 0), replace);
|
||||
var b = FindEdge(p, new int2(1, 0), replace);
|
||||
|
||||
for (var x = a.X; x <= b.X; x++)
|
||||
{
|
||||
Map.MapTiles[x, p.Y] = new TileReference<ushort, byte> { type = Brush.N, image = (byte)0, index = (byte)0 };
|
||||
if (Map.MapTiles[x, p.Y - 1].Equals(replace) && Map.IsInMap(x, p.Y - 1))
|
||||
queue.Enqueue(new int2(x, p.Y - 1));
|
||||
if (Map.MapTiles[x, p.Y + 1].Equals(replace) && Map.IsInMap(x, p.Y + 1))
|
||||
queue.Enqueue(new int2(x, p.Y + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/* todo: optimize */
|
||||
foreach (var ch in Chunks.Values) ch.Dispose();
|
||||
Chunks.Clear();
|
||||
}
|
||||
|
||||
int2 FindEdge(int2 p, int2 d, TileReference<ushort, byte> replace)
|
||||
{
|
||||
for (; ; )
|
||||
{
|
||||
var q = p+d;
|
||||
if (!Map.IsInMap(q)) return p;
|
||||
if (!Map.MapTiles[q.X, q.Y].Equals(replace)) return p;
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWithBrush()
|
||||
{
|
||||
// change the bits in the map
|
||||
@@ -98,6 +140,12 @@ namespace OpenRA.Editor
|
||||
var template = TileSet.walk[Brush.N];
|
||||
var pos = GetBrushLocation();
|
||||
|
||||
if (ModifierKeys == Keys.Shift)
|
||||
{
|
||||
FloodFillWithBrush(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var u = 0; u < template.Size.X; u++)
|
||||
for (var v = 0; v < template.Size.Y; v++)
|
||||
{
|
||||
@@ -186,7 +234,8 @@ namespace OpenRA.Editor
|
||||
return;
|
||||
|
||||
var owner = "Neutral";
|
||||
Map.Actors[NextActorName()] = new ActorReference(Actor.Info.Name.ToLowerInvariant(), GetBrushLocation(), owner);
|
||||
var id = NextActorName();
|
||||
Map.Actors[id] = new ActorReference(id,Actor.Info.Name.ToLowerInvariant(), GetBrushLocation(), owner);
|
||||
}
|
||||
|
||||
Random r = new Random();
|
||||
@@ -316,7 +365,7 @@ namespace OpenRA.Editor
|
||||
new Rectangle(Map.XOffset * 24 + Offset.X, Map.YOffset * 24 + Offset.Y, Map.Width * 24, Map.Height * 24));
|
||||
|
||||
foreach (var ar in Map.Actors)
|
||||
DrawActor(e.Graphics, ar.Value.Location, ActorTemplates[ar.Value.Name]);
|
||||
DrawActor(e.Graphics, ar.Value.Location, ActorTemplates[ar.Value.Type]);
|
||||
|
||||
foreach (var wp in Map.Waypoints)
|
||||
e.Graphics.DrawRectangle(Pens.LimeGreen, new Rectangle(
|
||||
@@ -345,7 +394,7 @@ namespace OpenRA.Editor
|
||||
{
|
||||
var x = Map.Actors.FirstOrDefault(a => a.Value.Location == GetBrushLocation());
|
||||
if (x.Key != null)
|
||||
DrawActorBorder(e.Graphics, x.Value.Location, ActorTemplates[x.Value.Name]);
|
||||
DrawActorBorder(e.Graphics, x.Value.Location, ActorTemplates[x.Value.Type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace OpenRA.FileFormats
|
||||
FieldLoader.LoadField(self,field,my[field].Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void LoadField( object self, string key, string value )
|
||||
{
|
||||
|
||||
@@ -20,22 +20,25 @@
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
public struct ActorReference
|
||||
public class ActorReference
|
||||
{
|
||||
public readonly string Id;
|
||||
public readonly string Type;
|
||||
public readonly int2 Location;
|
||||
public readonly string Name;
|
||||
public readonly string Owner;
|
||||
public ActorReference( string name, int2 location, string owner )
|
||||
|
||||
public ActorReference(MiniYaml my)
|
||||
{
|
||||
Name = name;
|
||||
FieldLoader.Load(this, my);
|
||||
}
|
||||
|
||||
// Legacy construtor for old format maps
|
||||
public ActorReference(string id, string type, int2 location, string owner )
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
Location = location;
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format("{0} {1} {2},{3}", Name, Owner, Location.X,Location.Y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,23 +35,25 @@ namespace OpenRA.FileFormats
|
||||
|
||||
// Yaml map data
|
||||
public bool Selectable = true;
|
||||
public int MapFormat = 1;
|
||||
public int MapFormat;
|
||||
public string Title;
|
||||
public string Description;
|
||||
public string Author;
|
||||
public int PlayerCount;
|
||||
public string Tileset;
|
||||
|
||||
|
||||
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
|
||||
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
||||
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
||||
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
||||
|
||||
|
||||
// Rules overrides
|
||||
public Dictionary<string, MiniYaml> Rules = new Dictionary<string, MiniYaml>();
|
||||
public Dictionary<string, MiniYaml> Weapons = new Dictionary<string, MiniYaml>();
|
||||
public Dictionary<string, MiniYaml> Voices = new Dictionary<string, MiniYaml>();
|
||||
public Dictionary<string, MiniYaml> Music = new Dictionary<string, MiniYaml>();
|
||||
public Dictionary<string, MiniYaml> Terrain = new Dictionary<string, MiniYaml>();
|
||||
public Dictionary<string, MiniYaml> Terrain = new Dictionary<string, MiniYaml>();
|
||||
|
||||
// Binary map data
|
||||
public byte TileFormat = 1;
|
||||
public int2 MapSize;
|
||||
@@ -77,7 +79,27 @@ namespace OpenRA.FileFormats
|
||||
"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight"
|
||||
};
|
||||
|
||||
public Map() { }
|
||||
public Map()
|
||||
{
|
||||
MapSize = new int2(1, 1);
|
||||
MapResources = new TileReference<byte, byte>[1, 1];
|
||||
MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
{ { new TileReference<ushort, byte> {
|
||||
type = (ushort)0xffffu,
|
||||
image = (byte)0xffu,
|
||||
index = (byte)0xffu } } };
|
||||
|
||||
PlayerCount = 0;
|
||||
TopLeft = new int2(0,0);
|
||||
BottomRight = new int2(0,0);
|
||||
|
||||
Tileset = "TEMPERAT";
|
||||
Players.Add("Neutral", new PlayerReference("Neutral", "neutral", "allies", true, true));
|
||||
|
||||
Title = "Name your map here";
|
||||
Description = "Describe your map here";
|
||||
Author = "Your name here";
|
||||
}
|
||||
|
||||
public Map(IFolder package)
|
||||
{
|
||||
@@ -92,16 +114,42 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
string[] loc = wp.Value.Value.Split(',');
|
||||
Waypoints.Add(wp.Key, new int2(int.Parse(loc[0]), int.Parse(loc[1])));
|
||||
}
|
||||
|
||||
// Actors
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
{
|
||||
string[] vals = kv.Value.Value.Split(' ');
|
||||
string[] loc = vals[2].Split(',');
|
||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[2]);
|
||||
Actors.Add(kv.Key, a);
|
||||
}
|
||||
}
|
||||
|
||||
// Players
|
||||
if (MapFormat == 1)
|
||||
{
|
||||
Players.Add("Neutral", new PlayerReference("Neutral", "neutral", "allies", true, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in yaml["Players"].Nodes)
|
||||
{
|
||||
var player = new PlayerReference(kv.Value);
|
||||
Players.Add(player.Name, player);
|
||||
}
|
||||
}
|
||||
|
||||
// Actors
|
||||
if (MapFormat == 1)
|
||||
{
|
||||
int actors = 0;
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
{
|
||||
string[] vals = kv.Value.Value.Split(' ');
|
||||
string[] loc = vals[2].Split(',');
|
||||
var a = new ActorReference("Actor"+actors++, vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), "Neutral");
|
||||
Actors.Add(a.Id, a);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
{
|
||||
var a = new ActorReference(kv.Value);
|
||||
Actors.Add(a.Id, a);
|
||||
}
|
||||
}
|
||||
|
||||
// Smudges
|
||||
foreach (var kv in yaml["Smudges"].Nodes)
|
||||
@@ -120,17 +168,28 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public void Save(string filepath)
|
||||
{
|
||||
MapFormat = 2;
|
||||
|
||||
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
||||
foreach (var field in SimpleFields)
|
||||
{
|
||||
FieldInfo f = this.GetType().GetField(field);
|
||||
if (f.GetValue(this) == null) continue;
|
||||
root.Add(field, new MiniYaml(FieldSaver.FormatValue(this, f), null));
|
||||
}
|
||||
|
||||
root.Add("Actors", MiniYaml.FromDictionary<string, ActorReference>(Actors));
|
||||
root.Add(field, new MiniYaml(FieldSaver.FormatValue(this, f), null));
|
||||
}
|
||||
|
||||
Dictionary<string, MiniYaml> playerYaml = new Dictionary<string, MiniYaml>();
|
||||
foreach(var p in Players)
|
||||
playerYaml.Add("PlayerReference@{0}".F(p.Key), FieldSaver.Save(p.Value));
|
||||
root.Add("Players",new MiniYaml(null, playerYaml));
|
||||
|
||||
Dictionary<string, MiniYaml> actorYaml = new Dictionary<string, MiniYaml>();
|
||||
foreach(var p in Actors)
|
||||
actorYaml.Add("ActorReference@{0}".F(p.Key), FieldSaver.Save(p.Value));
|
||||
root.Add("Actors",new MiniYaml(null, actorYaml));
|
||||
|
||||
root.Add("Waypoints", MiniYaml.FromDictionary<string, int2>(Waypoints));
|
||||
root.Add("Smudges", MiniYaml.FromList<SmudgeReference>(Smudges));
|
||||
root.Add("Smudges", MiniYaml.FromList<SmudgeReference>(Smudges));
|
||||
root.Add("Rules", new MiniYaml(null, Rules));
|
||||
SaveBinaryData(Path.Combine(filepath, "map.bin"));
|
||||
root.WriteToFile(Path.Combine(filepath, "map.yaml"));
|
||||
@@ -246,24 +305,6 @@ namespace OpenRA.FileFormats
|
||||
return (x >= TopLeft.X && y >= TopLeft.Y && x < BottomRight.X && y < BottomRight.Y);
|
||||
}
|
||||
|
||||
public void DebugContents()
|
||||
{
|
||||
foreach (var field in SimpleFields)
|
||||
Console.WriteLine("Loaded {0}: {1}", field, this.GetType().GetField(field).GetValue(this));
|
||||
|
||||
Console.WriteLine("Loaded Waypoints:");
|
||||
foreach (var wp in Waypoints)
|
||||
Console.WriteLine("\t{0} => {1}", wp.Key, wp.Value);
|
||||
|
||||
Console.WriteLine("Loaded Actors:");
|
||||
foreach (var wp in Actors)
|
||||
Console.WriteLine("\t{0} => {1} {2} {3}", wp.Key, wp.Value.Name, wp.Value.Owner, wp.Value.Location);
|
||||
|
||||
Console.WriteLine("Loaded Smudges:");
|
||||
foreach (var s in Smudges)
|
||||
Console.WriteLine("\t{0} {1} {2}", s.Type, s.Location, s.Depth);
|
||||
}
|
||||
|
||||
static T[,] ResizeArray<T>(T[,] ts, T t, int width, int height)
|
||||
{
|
||||
var result = new T[width, height];
|
||||
|
||||
45
OpenRA.FileFormats/Map/PlayerReference.cs
Normal file
45
OpenRA.FileFormats/Map/PlayerReference.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
public class PlayerReference
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Palette;
|
||||
public readonly string Race;
|
||||
public readonly bool OwnsWorld = false;
|
||||
public readonly bool NonCombatant = false;
|
||||
|
||||
public PlayerReference(MiniYaml my)
|
||||
{
|
||||
FieldLoader.Load(this, my);
|
||||
}
|
||||
|
||||
public PlayerReference(string name, string palette, string race, bool ownsworld, bool noncombatant)
|
||||
{
|
||||
Name = name;
|
||||
Palette = palette;
|
||||
Race = race;
|
||||
OwnsWorld = ownsworld;
|
||||
NonCombatant = noncombatant;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
@@ -102,6 +102,7 @@
|
||||
<Compile Include="Primitives\int2.cs" />
|
||||
<Compile Include="Map\MapStub.cs" />
|
||||
<Compile Include="Map\SmudgeReference.cs" />
|
||||
<Compile Include="Map\PlayerReference.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -20,21 +20,76 @@
|
||||
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public struct ChannelInfo
|
||||
{
|
||||
public bool Upload;
|
||||
public string Filename;
|
||||
public StreamWriter Writer;
|
||||
public bool Diff;
|
||||
}
|
||||
|
||||
public static class Log
|
||||
{
|
||||
static StreamWriter writer = File.CreateText(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + "openra.log.txt");
|
||||
public static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
|
||||
static Dictionary<string, ChannelInfo> channels = new Dictionary<string,ChannelInfo>();
|
||||
|
||||
static Log()
|
||||
{
|
||||
writer.AutoFlush = true;
|
||||
AddChannel("debug", "openra.log.txt", false, false);
|
||||
}
|
||||
|
||||
public static void Write(string format, params object[] args)
|
||||
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
|
||||
{
|
||||
writer.WriteLine(format, args);
|
||||
StreamWriter writer = File.CreateText(LogPathPrefix + filename);
|
||||
writer.AutoFlush = true;
|
||||
|
||||
channels.Add(channelName, new ChannelInfo() { Upload = upload, Filename = filename, Writer = writer, Diff = diff });
|
||||
}
|
||||
|
||||
public static void Write(string channel, string format, params object[] args)
|
||||
{
|
||||
ChannelInfo info;
|
||||
if (!channels.TryGetValue(channel, out info))
|
||||
throw new Exception("Tried logging to non-existant channel " + channel);
|
||||
|
||||
info.Writer.WriteLine(format, args);
|
||||
}
|
||||
|
||||
public static void Upload(int gameId)
|
||||
{
|
||||
foreach (var kvp in channels.Where(x => x.Value.Upload))
|
||||
{
|
||||
kvp.Value.Writer.Close();
|
||||
var logfile = File.OpenRead(Log.LogPathPrefix + kvp.Value.Filename);
|
||||
byte[] fileContents = logfile.ReadAllBytes();
|
||||
var ms = new MemoryStream();
|
||||
|
||||
using (var gzip = new GZipStream(ms, CompressionMode.Compress, true))
|
||||
gzip.Write(fileContents, 0, fileContents.Length);
|
||||
|
||||
ms.Position = 0;
|
||||
byte[] buffer = ms.ReadAllBytes();
|
||||
|
||||
WebRequest request = WebRequest.Create("http://open-ra.org/logs/upload.php");
|
||||
request.ContentType = "application/x-gzip";
|
||||
request.ContentLength = buffer.Length;
|
||||
request.Method = "POST";
|
||||
request.Headers.Add("Game-ID", gameId.ToString());
|
||||
request.Headers.Add("Channel", kvp.Key);
|
||||
request.Headers.Add("Diff", kvp.Value.Diff ? "1" : "0");
|
||||
|
||||
using (var requestStream = request.GetRequestStream())
|
||||
requestStream.Write(buffer, 0, buffer.Length);
|
||||
|
||||
var response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Support
|
||||
var time = sw.ElapsedTime();
|
||||
var dt = time - lastTime;
|
||||
if( dt > 0.0001 )
|
||||
Log.Write( message, dt );
|
||||
Log.Write("perf", message, dt );
|
||||
lastTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,15 +192,17 @@ namespace OpenRA
|
||||
Owner.Deaths++;
|
||||
|
||||
if (RemoveOnDeath)
|
||||
World.AddFrameEndTask(w => w.Remove(this));
|
||||
World.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
Log.Write("debug", "{0} #{1} killed by {2} #{3}", Info.Name, ActorID, attacker.Info.Name, attacker.ActorID);
|
||||
}
|
||||
|
||||
var maxHP = this.GetMaxHP();
|
||||
|
||||
if (Health > maxHP) Health = maxHP;
|
||||
|
||||
Log.Write("InflictDamage: {0} #{1} -> {2} #{3} raw={4} adj={5} hp={6} mod={7}",
|
||||
attacker.Info.Name, attacker.ActorID, Info.Name, ActorID, rawDamage, damage, Health, modifier);
|
||||
// Log.Write("debug", "InflictDamage: {0} #{1} -> {2} #{3} raw={4} adj={5} hp={6} mod={7}",
|
||||
// attacker.Info.Name, attacker.ActorID, Info.Name, ActorID, rawDamage, damage, Health, modifier);
|
||||
|
||||
var newState = GetDamageState();
|
||||
|
||||
|
||||
@@ -170,8 +170,8 @@ namespace OpenRA
|
||||
var h = 600;
|
||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
||||
|
||||
var typingBox = new Rectangle(r.Left + 20, r.Bottom - 47, r.Width - 40, 27);
|
||||
var chatBox = new Rectangle(r.Left + 20, r.Bottom - 269, r.Width - 40, 220);
|
||||
var typingBox = new Rectangle(r.Left + 20, r.Bottom - 77, r.Width - 40, 27);
|
||||
var chatBox = new Rectangle(r.Left + 20, r.Bottom - 269, r.Width - 40, 190);
|
||||
|
||||
DrawDialogBackground(typingBox, "dialog2");
|
||||
DrawDialogBackground(chatBox, "dialog3");
|
||||
|
||||
@@ -79,8 +79,7 @@ namespace OpenRA
|
||||
|
||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
|
||||
{
|
||||
if (!(orderGenerator is PlaceBuildingOrderGenerator))
|
||||
dragStart = dragEnd = xy;
|
||||
dragStart = dragEnd = xy;
|
||||
ApplyOrders(world, xy, mi);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Effects
|
||||
var cell = ((1f/Game.CellSize) * pos).ToInt2();
|
||||
|
||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.traits.Contains<Wall>()))
|
||||
a => a.traits.Contains<IBlocksBullets>()))
|
||||
{
|
||||
Args.dest = pos.ToInt2();
|
||||
Explode(world);
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Effects
|
||||
var cell = ((1f / Game.CellSize) * Pos).ToInt2();
|
||||
|
||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.traits.Contains<Wall>()))
|
||||
a => a.traits.Contains<IBlocksBullets>()))
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Effects
|
||||
{
|
||||
@@ -33,14 +35,21 @@ namespace OpenRA.Effects
|
||||
class TeslaZap : IEffect
|
||||
{
|
||||
readonly ProjectileArgs Args;
|
||||
readonly Sequence tesla;
|
||||
int timeUntilRemove = 2; // # of frames
|
||||
bool doneDamage = false;
|
||||
|
||||
const int numZaps = 3;
|
||||
|
||||
readonly List<Renderable> renderables = new List<Renderable>();
|
||||
|
||||
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
|
||||
{
|
||||
Args = args;
|
||||
tesla = SequenceProvider.GetSequence("litning", "bright");
|
||||
var bright = SequenceProvider.GetSequence("litning", "bright");
|
||||
var dim = SequenceProvider.GetSequence("litning", "dim");
|
||||
|
||||
for (var n = 0; n < numZaps; n++)
|
||||
renderables.AddRange(DrawZapWandering(args.src, args.dest, n == numZaps - 1 ? bright : dim));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
@@ -56,64 +65,67 @@ namespace OpenRA.Effects
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
var from = Args.src;
|
||||
var to = Args.dest;
|
||||
public IEnumerable<Renderable> Render() { return renderables; }
|
||||
|
||||
if( from.X < to.X )
|
||||
return DrawZap( from, to, tesla );
|
||||
else if( from.X > to.X || from.Y > to.Y )
|
||||
return DrawZap( to, from, tesla );
|
||||
else
|
||||
return DrawZap( from, to, tesla );
|
||||
}
|
||||
|
||||
static IEnumerable<Renderable> DrawZap( int2 from, int2 to, Sequence tesla )
|
||||
static IEnumerable<Renderable> DrawZapWandering(int2 from, int2 to, Sequence s)
|
||||
{
|
||||
int2 d = to - from;
|
||||
if( d.X < 8 )
|
||||
var z = float2.Zero; /* hack */
|
||||
var dist = to - from;
|
||||
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
||||
|
||||
var renderables = new List<Renderable>();
|
||||
if (Game.CosmeticRandom.Next(2) != 0)
|
||||
{
|
||||
var prev = new int2( 0, 0 );
|
||||
var y = d.Y;
|
||||
while( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return new Renderable( tesla.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 8 ) ), "effect");
|
||||
prev.Y += 8;
|
||||
}
|
||||
var p1 = from + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
var p2 = from + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, p2, s, out p2));
|
||||
renderables.AddRange(DrawZap(p2, to, s, out z));
|
||||
}
|
||||
else
|
||||
{
|
||||
var prev = new int2( 0, 0 );
|
||||
for( int i = 1 ; i < d.X ; i += 8 )
|
||||
{
|
||||
var y = i * d.Y / d.X;
|
||||
if( y <= prev.Y - 8 )
|
||||
{
|
||||
yield return new Renderable(tesla.GetSprite(3), (float2)(from + prev - new int2(8, 16)), "effect");
|
||||
prev.Y -= 8;
|
||||
while( y <= prev.Y - 8 )
|
||||
{
|
||||
yield return new Renderable(tesla.GetSprite(2), (float2)(from + prev - new int2(0, 16)), "effect");
|
||||
prev.Y -= 8;
|
||||
}
|
||||
}
|
||||
else if( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return new Renderable(tesla.GetSprite(0), (float2)(from + prev - new int2(8, 8)), "effect");
|
||||
prev.Y += 8;
|
||||
while( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return new Renderable(tesla.GetSprite(2), (float2)(from + prev - new int2(0, 8)), "effect");
|
||||
prev.Y += 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
yield return new Renderable(tesla.GetSprite(1), (float2)(from + prev - new int2(8, 8)), "effect");
|
||||
var p1 = from + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
prev.X += 8;
|
||||
}
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, to, s, out z));
|
||||
}
|
||||
|
||||
return renderables;
|
||||
}
|
||||
|
||||
static IEnumerable<Renderable> DrawZap(float2 from, float2 to, Sequence s, out float2 p)
|
||||
{
|
||||
var dist = to - from;
|
||||
var q = new float2(-dist.Y, dist.X);
|
||||
var c = -float2.Dot(from, q);
|
||||
var rs = new List<Renderable>();
|
||||
var z = from;
|
||||
|
||||
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
|
||||
{
|
||||
var step = steps.Where(t => (to - (z + new float2(t[0],t[1]))).LengthSquared < (to - z).LengthSquared )
|
||||
.OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();
|
||||
|
||||
rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), "effect"));
|
||||
z += new float2(step[0], step[1]);
|
||||
}
|
||||
|
||||
p = z;
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
static int[][] steps = new []
|
||||
{
|
||||
new int[] { 8, 8, -8, -8, 0 },
|
||||
new int[] { -8, -8, -16, -16, 0 },
|
||||
new int[] { 8, 0, -8, -8, 1 },
|
||||
new int[] { -8, 0, -16, -8, 1 },
|
||||
new int[] { 0, 8, -8, -8, 2 },
|
||||
new int[] { 0, -8, -8, -16, 2 },
|
||||
new int[] { -8, 8, -16, -8, 3 },
|
||||
new int[] { 8, -8, -8, -16, 3 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA
|
||||
a( x );
|
||||
var dt = sw.ElapsedTime() - t;
|
||||
if( dt > time )
|
||||
Log.Write( text, x, dt*1000 );
|
||||
Log.Write("perf", text, x, dt * 1000);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
#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.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
using Timer = OpenRA.Support.Timer;
|
||||
#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.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
using Timer = OpenRA.Support.Timer;
|
||||
using XRandom = OpenRA.Thirdparty.Random;
|
||||
|
||||
namespace OpenRA
|
||||
@@ -59,11 +59,16 @@ namespace OpenRA
|
||||
internal static Renderer renderer;
|
||||
static int2 clientSize;
|
||||
static string mapName;
|
||||
internal static Session LobbyInfo = new Session();
|
||||
public static Session LobbyInfo = new Session();
|
||||
static bool packageChangePending;
|
||||
static bool mapChangePending;
|
||||
static Pair<Assembly, string>[] ModAssemblies;
|
||||
|
||||
static internal bool scrollUp = false;
|
||||
static internal bool scrollDown = false;
|
||||
static internal bool scrollLeft = false;
|
||||
static internal bool scrollRight = false;
|
||||
|
||||
static void LoadModPackages(Manifest manifest)
|
||||
{
|
||||
FileSystem.UnmountAll();
|
||||
@@ -249,12 +254,12 @@ namespace OpenRA
|
||||
var f = syncReports.FirstOrDefault(a => a.First == frame);
|
||||
if (f == null)
|
||||
{
|
||||
Log.Write("No sync report available!");
|
||||
Log.Write("sync", "No sync report available!");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Write("Sync for net frame {0} -------------", f.First);
|
||||
Log.Write("{0}", f.Second);
|
||||
Log.Write("sync", "Sync for net frame {0} -------------", f.First);
|
||||
Log.Write("sync", "{0}", f.Second);
|
||||
}
|
||||
|
||||
static void Tick()
|
||||
@@ -308,6 +313,15 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
if (scrollUp == true)
|
||||
viewport.Scroll(new float2(0, -10));
|
||||
if (scrollRight == true)
|
||||
viewport.Scroll(new float2(10, 0));
|
||||
if (scrollDown == true)
|
||||
viewport.Scroll(new float2(0, 10));
|
||||
if (scrollLeft == true)
|
||||
viewport.Scroll(new float2(-10, 0));
|
||||
|
||||
using (new PerfSample("render"))
|
||||
{
|
||||
++RenderFrame;
|
||||
@@ -385,10 +399,6 @@ namespace OpenRA
|
||||
LoadMap(map);
|
||||
world.Queries = new World.AllQueries(world);
|
||||
|
||||
foreach (var p in world.players.Values)
|
||||
foreach (var q in world.players.Values)
|
||||
p.Stances[q] = ChooseInitialStance(p, q);
|
||||
|
||||
foreach (var gs in world.WorldActor.traits.WithInterface<IGameStarted>())
|
||||
gs.GameStarted(world);
|
||||
orderManager.StartGame();
|
||||
@@ -400,15 +410,6 @@ namespace OpenRA
|
||||
if (orderManager.GameStarted) return;
|
||||
chat.Reset();
|
||||
|
||||
world.SetLocalPlayer(orderManager.Connection.LocalClientId);
|
||||
|
||||
foreach (var c in LobbyInfo.Clients)
|
||||
world.AddPlayer(new Player(world, c));
|
||||
|
||||
foreach (var p in world.players.Values)
|
||||
foreach (var q in world.players.Values)
|
||||
p.Stances[q] = ChooseInitialStance(p, q);
|
||||
|
||||
world.Queries = new World.AllQueries(world);
|
||||
|
||||
foreach (var gs in world.WorldActor.traits.WithInterface<IGameStarted>())
|
||||
@@ -418,10 +419,12 @@ namespace OpenRA
|
||||
orderManager.StartGame();
|
||||
}
|
||||
|
||||
static Stance ChooseInitialStance(Player p, Player q)
|
||||
public static Stance ChooseInitialStance(Player p, Player q)
|
||||
{
|
||||
if (p == q) return Stance.Ally;
|
||||
if (p == world.NeutralPlayer || q == world.NeutralPlayer) return Stance.Neutral;
|
||||
|
||||
// Hack: All map players are neutral wrt everyone else
|
||||
if (p.Index < 0 || q.Index < 0) return Stance.Neutral;
|
||||
|
||||
var pc = GetClientForPlayer(p);
|
||||
var qc = GetClientForPlayer(q);
|
||||
@@ -476,18 +479,18 @@ namespace OpenRA
|
||||
get { return LobbyInfo.Clients.FirstOrDefault(c => c.Index == orderManager.Connection.LocalClientId); }
|
||||
}
|
||||
|
||||
static Dictionary<char, char> RemapKeys = new Dictionary<char, char>
|
||||
{
|
||||
{ '!', '1' },
|
||||
{ '@', '2' },
|
||||
{ '#', '3' },
|
||||
{ '$', '4' },
|
||||
{ '%', '5' },
|
||||
{ '^', '6' },
|
||||
{ '&', '7' },
|
||||
{ '*', '8' },
|
||||
{ '(', '9' },
|
||||
{ ')', '0' },
|
||||
static Dictionary<char, char> RemapKeys = new Dictionary<char, char>
|
||||
{
|
||||
{ '!', '1' },
|
||||
{ '@', '2' },
|
||||
{ '#', '3' },
|
||||
{ '$', '4' },
|
||||
{ '%', '5' },
|
||||
{ '^', '6' },
|
||||
{ '&', '7' },
|
||||
{ '*', '8' },
|
||||
{ '(', '9' },
|
||||
{ ')', '0' },
|
||||
};
|
||||
|
||||
public static void HandleKeyPress(KeyPressEventArgs e, Modifiers modifiers)
|
||||
@@ -522,6 +525,26 @@ namespace OpenRA
|
||||
throw new InvalidOperationException("Desync in OnKeyPress");
|
||||
}
|
||||
|
||||
public static void HandleArrowKeyScroll(String k, Boolean pressed)
|
||||
{
|
||||
if (k == "up")
|
||||
{
|
||||
scrollUp = pressed;
|
||||
}
|
||||
if (k == "left")
|
||||
{
|
||||
scrollLeft = pressed;
|
||||
}
|
||||
if (k == "down")
|
||||
{
|
||||
scrollDown = pressed;
|
||||
}
|
||||
if (k == "right")
|
||||
{
|
||||
scrollRight = pressed;
|
||||
}
|
||||
}
|
||||
|
||||
public static void HandleModifierKeys(Modifiers mods)
|
||||
{
|
||||
controller.SetModifiers(mods);
|
||||
@@ -543,13 +566,6 @@ namespace OpenRA
|
||||
internal static void Initialize(Settings settings)
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||
while (!Directory.Exists("mods"))
|
||||
{
|
||||
var current = Directory.GetCurrentDirectory();
|
||||
if (Directory.GetDirectoryRoot(current) == current)
|
||||
throw new InvalidOperationException("Unable to find game root.");
|
||||
Directory.SetCurrentDirectory("..");
|
||||
}
|
||||
|
||||
LoadUserSettings(settings);
|
||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
||||
@@ -584,6 +600,8 @@ namespace OpenRA
|
||||
LoadShellMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid);
|
||||
|
||||
ResetTimer();
|
||||
|
||||
Log.AddChannel("sync", "openra.syncreport.txt", true, true);
|
||||
}
|
||||
|
||||
static void LoadUserSettings(Settings settings)
|
||||
@@ -621,5 +639,26 @@ namespace OpenRA
|
||||
Chrome.rootWidget.CloseWindow();
|
||||
Chrome.rootWidget.OpenWindow("MAINMENU_BG");
|
||||
}
|
||||
|
||||
internal static int GetGameId()
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = File.ReadAllText(Log.LogPathPrefix + "openra.gameid");
|
||||
return int.Parse(s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetGameId(int id)
|
||||
{
|
||||
var file = File.CreateText(Log.LogPathPrefix + "openra.gameid");
|
||||
file.Write(id);
|
||||
file.Flush();
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,8 @@ namespace OpenRA.GameRules
|
||||
while( t.Count != 0 )
|
||||
{
|
||||
if( index >= t.Count )
|
||||
throw new InvalidOperationException( "Trait prerequisites not satisfied (or prerequisite loop)" );
|
||||
throw new InvalidOperationException( "Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1}".F(
|
||||
Name, string.Join( ",", t.Select( x => x.GetType().Name ).ToArray())));
|
||||
|
||||
var prereqs = PrerequisitesOf( t[ index ] );
|
||||
if( prereqs.Count == 0 || prereqs.All( n => ret.Any( x => x.GetType() == n || x.GetType().IsSubclassOf( n ) ) ) )
|
||||
|
||||
@@ -25,7 +25,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.GameRules
|
||||
{
|
||||
static class Footprint
|
||||
public static class Footprint
|
||||
{
|
||||
public static IEnumerable<int2> Tiles( string name, BuildingInfo buildingInfo, int2 topLeft )
|
||||
{
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace OpenRA
|
||||
|
||||
public static void LoadRules(Manifest m, Map map)
|
||||
{
|
||||
Log.Write("Using rules files: ");
|
||||
Log.Write("debug", "Using rules files: ");
|
||||
foreach (var y in m.Rules)
|
||||
Log.Write(" -- {0}", y);
|
||||
Log.Write("debug", " -- {0}", y);
|
||||
|
||||
Log.Write("Using Map: {0}",map.Uid);
|
||||
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));
|
||||
|
||||
@@ -22,15 +22,15 @@ using System.Drawing;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
class SheetBuilder
|
||||
public class SheetBuilder
|
||||
{
|
||||
public static SheetBuilder SharedInstance;
|
||||
public static void Initialize(Renderer r)
|
||||
internal static void Initialize(Renderer r)
|
||||
{
|
||||
SharedInstance = new SheetBuilder(r, TextureChannel.Red);
|
||||
}
|
||||
|
||||
public SheetBuilder(Renderer r, TextureChannel ch)
|
||||
internal SheetBuilder(Renderer r, TextureChannel ch)
|
||||
{
|
||||
renderer = r;
|
||||
current = null;
|
||||
|
||||
@@ -20,19 +20,21 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
static class SpriteSheetBuilder
|
||||
{
|
||||
static TheaterInfo GetTheater(Map map)
|
||||
{ // todo: move this somewhere else
|
||||
return Rules.Info["world"].Traits.WithInterface<TheaterInfo>().FirstOrDefault(t => t.Theater == map.Theater);
|
||||
}
|
||||
|
||||
public static void Initialize( Map map )
|
||||
{
|
||||
exts = new[] {
|
||||
"." + map.Theater.Substring( 0, 3 ).ToLowerInvariant(),
|
||||
".shp",
|
||||
".tem",
|
||||
".sno",
|
||||
".int" };
|
||||
/* .tem: hack to allow incomplete theaters (interior) to work, falling back to temperate for the missing art */
|
||||
exts = new[] { "." + GetTheater(map).Suffix, ".shp", ".tem" };
|
||||
sprites = new Cache<string, Sprite[]>( LoadSprites );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ using OpenRA.FileFormats.Graphics;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
static class Util
|
||||
public static class Util
|
||||
{
|
||||
public static string[] ReadAllLines(Stream s)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Graphics
|
||||
bool gameWasStarted = false;
|
||||
public void DrawRegions( World world )
|
||||
{
|
||||
// Timer.Time( "DrawRegions start" );
|
||||
Timer.Time( "DrawRegions start" );
|
||||
|
||||
world.WorldRenderer.palette.Update(
|
||||
world.WorldActor.traits.WithInterface<IPaletteModifier>());
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
renderer.BeginFrame(r1, r2, scrollPosition.ToInt2());
|
||||
world.WorldRenderer.Draw();
|
||||
// Timer.Time( "worldRenderer: {0}" );
|
||||
Timer.Time( "worldRenderer: {0}" );
|
||||
if( Game.orderManager.GameStarted && world.LocalPlayer != null)
|
||||
{
|
||||
if (!gameWasStarted)
|
||||
@@ -88,6 +88,7 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
|
||||
Game.chrome.Draw( world );
|
||||
Timer.Time( "chromedraw: {0}" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -128,6 +129,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
lastConnectionState = state;
|
||||
|
||||
Timer.Time( "connectionState: {0}" );
|
||||
}
|
||||
Game.chrome.DrawWidgets(world);
|
||||
if (Chrome.rootWidget.GetWidget("SERVER_LOBBY").Visible)
|
||||
@@ -135,19 +137,19 @@ namespace OpenRA.Graphics
|
||||
else if (Chrome.rootWidget.GetWidget("MAP_CHOOSER").Visible)
|
||||
Game.chrome.DrawMapChooser();
|
||||
|
||||
// Timer.Time( "widgets: {0}" );
|
||||
Timer.Time( "widgets: {0}" );
|
||||
|
||||
var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world );
|
||||
var c = new Cursor(cursorName);
|
||||
cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor");
|
||||
// Timer.Time( "cursors: {0}" );
|
||||
Timer.Time( "cursors: {0}" );
|
||||
|
||||
renderer.RgbaSpriteRenderer.Flush();
|
||||
renderer.SpriteRenderer.Flush();
|
||||
renderer.WorldSpriteRenderer.Flush();
|
||||
|
||||
renderer.EndFrame();
|
||||
// Timer.Time( "endFrame: {0}" );
|
||||
Timer.Time( "endFrame: {0}" );
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
|
||||
@@ -341,31 +341,36 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawLocus(Color c, int2[] cells)
|
||||
{
|
||||
foreach (var t in cells)
|
||||
{
|
||||
if (!cells.Contains(t + new int2(-1, 0)))
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
|
||||
c, c);
|
||||
if (!cells.Contains(t + new int2(1, 0)))
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1, 0)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c, c);
|
||||
if (!cells.Contains(t + new int2(0, -1)))
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1, 0)),
|
||||
c, c);
|
||||
if (!cells.Contains(t + new int2(0, 1)))
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0, 1)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c, c);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawRangeCircle(Color c, int2 location, int range)
|
||||
{
|
||||
DrawLocus(c, world.FindTilesInCircle(location, range).ToArray());
|
||||
}
|
||||
|
||||
public void DrawRangeCircle(Actor selectedUnit)
|
||||
{
|
||||
if (selectedUnit.Owner != world.LocalPlayer)
|
||||
return;
|
||||
|
||||
var range = (int)selectedUnit.GetPrimaryWeapon().Range;
|
||||
var r2 = range * range;
|
||||
|
||||
var c = Color.FromArgb(128, Color.Yellow);
|
||||
|
||||
foreach (var t in world.FindTilesInCircle(selectedUnit.Location, range))
|
||||
{
|
||||
if ((selectedUnit.Location - t - new int2(-1, 0)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(1, 0)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1,0)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(0,-1)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1,0)),
|
||||
c,c);
|
||||
if ((selectedUnit.Location - t - new int2(0,1)).LengthSquared > r2)
|
||||
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0,1)), Game.CellSize * (t + new int2(1, 1)),
|
||||
c,c);
|
||||
}
|
||||
if (selectedUnit.Owner == world.LocalPlayer)
|
||||
DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
||||
selectedUnit.Location,
|
||||
(int)selectedUnit.GetPrimaryWeapon().Range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
using System;
|
||||
#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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
|
||||
@@ -31,34 +31,38 @@ namespace OpenRA
|
||||
public readonly Actor TargetActor;
|
||||
public readonly int2 TargetLocation;
|
||||
public readonly string TargetString;
|
||||
public readonly bool Queued;
|
||||
public bool IsImmediate;
|
||||
|
||||
public Player Player { get { return Subject.Owner; } }
|
||||
|
||||
public Order(string orderString, Actor subject,
|
||||
Actor targetActor, int2 targetLocation, string targetString)
|
||||
Actor targetActor, int2 targetLocation, string targetString, bool queued)
|
||||
{
|
||||
this.OrderString = orderString;
|
||||
this.Subject = subject;
|
||||
this.TargetActor = targetActor;
|
||||
this.TargetLocation = targetLocation;
|
||||
this.TargetString = targetString;
|
||||
this.Queued = queued;
|
||||
}
|
||||
|
||||
public Order(string orderString, Actor subject)
|
||||
: this(orderString, subject, null, int2.Zero, null) { }
|
||||
: this(orderString, subject, null, int2.Zero, null, false) { }
|
||||
public Order(string orderString, Actor subject, Actor targetActor)
|
||||
: this(orderString, subject, targetActor, int2.Zero, null) { }
|
||||
: this(orderString, subject, targetActor, int2.Zero, null, false) { }
|
||||
public Order(string orderString, Actor subject, int2 targetLocation)
|
||||
: this(orderString, subject, null, targetLocation, null) { }
|
||||
: this(orderString, subject, null, targetLocation, null, false) { }
|
||||
public Order(string orderString, Actor subject, int2 targetLocation, bool queued)
|
||||
: this(orderString, subject, null, targetLocation, null, queued) { }
|
||||
public Order(string orderString, Actor subject, string targetString)
|
||||
: this(orderString, subject, null, int2.Zero, targetString) { }
|
||||
: this(orderString, subject, null, int2.Zero, targetString, false) { }
|
||||
public Order(string orderString, Actor subject, Actor targetActor, int2 targetLocation)
|
||||
: this(orderString, subject, targetActor, targetLocation, null) { }
|
||||
: this(orderString, subject, targetActor, targetLocation, null, false) { }
|
||||
public Order(string orderString, Actor subject, Actor targetActor, string targetString)
|
||||
: this(orderString, subject, targetActor, int2.Zero, targetString) { }
|
||||
: this(orderString, subject, targetActor, int2.Zero, targetString, false) { }
|
||||
public Order(string orderString, Actor subject, int2 targetLocation, string targetString)
|
||||
: this(orderString, subject, null, targetLocation, targetString) { }
|
||||
: this(orderString, subject, null, targetLocation, targetString, false) { }
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
@@ -92,6 +96,7 @@ namespace OpenRA
|
||||
w.Write(TargetString != null);
|
||||
if (TargetString != null)
|
||||
w.Write(TargetString);
|
||||
w.Write(Queued);
|
||||
return ret.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -111,12 +116,13 @@ namespace OpenRA
|
||||
var targetString = null as string;
|
||||
if (r.ReadBoolean())
|
||||
targetString = r.ReadString();
|
||||
var queued = r.ReadBoolean();
|
||||
|
||||
Actor subject, targetActor;
|
||||
if( !TryGetActorFromUInt( world, subjectId, out subject ) || !TryGetActorFromUInt( world, targetActorId, out targetActor ) )
|
||||
return null;
|
||||
|
||||
return new Order( order, subject, targetActor, targetLocation, targetString);
|
||||
return new Order( order, subject, targetActor, targetLocation, targetString, queued);
|
||||
}
|
||||
|
||||
case 0xfe:
|
||||
|
||||
@@ -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>
|
||||
@@ -35,7 +35,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
@@ -81,17 +81,15 @@
|
||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Traits\Activities\Leap.cs" />
|
||||
<Compile Include="Traits\AI\EmitInfantryOnSell.cs" />
|
||||
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
|
||||
<Compile Include="Traits\Attack\AttackLeap.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
|
||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||
<Compile Include="Traits\Player\TechTreeCache.cs" />
|
||||
<Compile Include="Traits\RevealsShroud.cs" />
|
||||
<Compile Include="Traits\Player\ConquestVictoryConditions.cs" />
|
||||
<Compile Include="Traits\Modifiers\HiddenUnderFog.cs" />
|
||||
<Compile Include="Traits\Render\RenderFlare.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" />
|
||||
@@ -105,7 +103,6 @@
|
||||
<Compile Include="Widgets\PostGameWidget.cs" />
|
||||
<Compile Include="Widgets\WidgetUtils.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\DelayedAction.cs" />
|
||||
<Compile Include="Effects\FlashTarget.cs" />
|
||||
<Compile Include="Effects\LaserZap.cs" />
|
||||
@@ -124,12 +121,9 @@
|
||||
<Compile Include="Graphics\Minimap.cs" />
|
||||
<Compile Include="Graphics\SpriteFont.cs" />
|
||||
<Compile Include="Network\Connection.cs" />
|
||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
||||
<Compile Include="Effects\Missile.cs" />
|
||||
<Compile Include="Network\OrderIO.cs" />
|
||||
<Compile Include="Network\OrderManager.cs" />
|
||||
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
||||
<Compile Include="Orders\SellOrderGenerator.cs" />
|
||||
<Compile Include="PathSearch.cs" />
|
||||
<Compile Include="Selection.cs" />
|
||||
<Compile Include="Server\Connection.cs" />
|
||||
@@ -141,25 +135,11 @@
|
||||
<Compile Include="Sound.cs" />
|
||||
<Compile Include="Support\PerfHistory.cs" />
|
||||
<Compile Include="Sync.cs" />
|
||||
<Compile Include="Traits\Attack\AttackOmni.cs" />
|
||||
<Compile Include="Traits\Attack\AttackTesla.cs" />
|
||||
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\World\SpatialBins.cs" />
|
||||
<Compile Include="Traits\World\SpawnDefaultUnits.cs" />
|
||||
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
||||
<Compile Include="Traits\World\Country.cs" />
|
||||
<Compile Include="Traits\World\CrateSpawner.cs" />
|
||||
<Compile Include="Traits\Activities\Attack.cs" />
|
||||
<Compile Include="Traits\Activities\CallFunc.cs" />
|
||||
<Compile Include="Traits\Activities\EnterTransport.cs" />
|
||||
<Compile Include="Traits\Activities\Fly.cs" />
|
||||
<Compile Include="Traits\Activities\FlyAttack.cs" />
|
||||
<Compile Include="Traits\Activities\FlyTimed.cs" />
|
||||
<Compile Include="Traits\Activities\HeliAttack.cs" />
|
||||
<Compile Include="Traits\Activities\HeliFly.cs" />
|
||||
<Compile Include="Traits\Activities\HeliLand.cs" />
|
||||
<Compile Include="Traits\Activities\HeliReturn.cs" />
|
||||
<Compile Include="Traits\Activities\TransformIntoActor.cs" />
|
||||
<Compile Include="Actor.cs" />
|
||||
<Compile Include="Effects\Bullet.cs" />
|
||||
@@ -175,11 +155,7 @@
|
||||
<Compile Include="Graphics\LineRenderer.cs" />
|
||||
<Compile Include="Graphics\WorldRenderer.cs" />
|
||||
<Compile Include="Traits\Activities\Idle.cs" />
|
||||
<Compile Include="Traits\Activities\Land.cs" />
|
||||
<Compile Include="Traits\Activities\Rearm.cs" />
|
||||
<Compile Include="Traits\Activities\RemoveSelf.cs" />
|
||||
<Compile Include="Traits\Activities\Repair.cs" />
|
||||
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
||||
<Compile Include="Traits\Activities\Sell.cs" />
|
||||
<Compile Include="Orders\IOrderGenerator.cs" />
|
||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||
@@ -203,80 +179,33 @@
|
||||
<Compile Include="GameRules\TerrainCost.cs" />
|
||||
<Compile Include="Graphics\TerrainRenderer.cs" />
|
||||
<Compile Include="Traits\Activities\Move.cs" />
|
||||
<Compile Include="Traits\Activities\Follow.cs" />
|
||||
<Compile Include="Traits\Activities\Turn.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\Activities\UnloadCargo.cs" />
|
||||
<Compile Include="Traits\Attack\AttackBase.cs" />
|
||||
<Compile Include="Traits\Attack\AttackFrontal.cs" />
|
||||
<Compile Include="Traits\Attack\AttackHeli.cs" />
|
||||
<Compile Include="Traits\Attack\AttackInfo.cs" />
|
||||
<Compile Include="Traits\Attack\AttackPlane.cs" />
|
||||
<Compile Include="Traits\Attack\AttackTurreted.cs" />
|
||||
<Compile Include="Traits\AI\AutoHeal.cs" />
|
||||
<Compile Include="Traits\AI\AutoTarget.cs" />
|
||||
<Compile Include="Traits\Modifiers\BelowUnits.cs" />
|
||||
<Compile Include="Traits\Bridge.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\CanPowerDown.cs" />
|
||||
<Compile Include="Traits\Cargo.cs" />
|
||||
<Compile Include="Traits\Crate.cs" />
|
||||
<Compile Include="Traits\Explodes.cs" />
|
||||
<Compile Include="Traits\Fake.cs" />
|
||||
<Compile Include="Traits\GeneratesGap.cs" />
|
||||
<Compile Include="Traits\Helicopter.cs" />
|
||||
<Compile Include="Traits\Modifiers\InvisibleToOthers.cs" />
|
||||
<Compile Include="Traits\ConstructionYard.cs" />
|
||||
<Compile Include="Traits\World\LightPaletteRotator.cs" />
|
||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||
<Compile Include="Traits\World\PaletteFromFile.cs" />
|
||||
<Compile Include="Traits\World\PaletteFromRGBA.cs" />
|
||||
<Compile Include="Traits\Passenger.cs" />
|
||||
<Compile Include="Traits\Player\PlaceBuilding.cs" />
|
||||
<Compile Include="Traits\World\PlayerColorPalette.cs" />
|
||||
<Compile Include="Traits\World\ResourceLayer.cs" />
|
||||
<Compile Include="Traits\World\ResourceType.cs" />
|
||||
<Compile Include="Traits\World\ShroudPalette.cs" />
|
||||
<Compile Include="Traits\SupportPower.cs" />
|
||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||
<Compile Include="Traits\Repairable.cs" />
|
||||
<Compile Include="Traits\Reservable.cs" />
|
||||
<Compile Include="Traits\Selectable.cs" />
|
||||
<Compile Include="Traits\AI\SelfHealing.cs" />
|
||||
<Compile Include="Traits\SquishByTank.cs" />
|
||||
<Compile Include="Traits\Plane.cs" />
|
||||
<Compile Include="Traits\Player\ProductionQueue.cs" />
|
||||
<Compile Include="Traits\ProductionSurround.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
|
||||
<Compile Include="Traits\Render\RenderInfantry.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\RenderBuilding.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingOre.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWarFactory.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnit.cs" />
|
||||
<Compile Include="Traits\Modifiers\WithMuzzleFlash.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitReload.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitRotor.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitSpinner.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitTurreted.cs" />
|
||||
<Compile Include="Traits\SeedsResource.cs" />
|
||||
<Compile Include="Traits\StoresOre.cs" />
|
||||
<Compile Include="Traits\Submarine.cs" />
|
||||
<Compile Include="Traits\AI\TakeCover.cs" />
|
||||
<Compile Include="Traits\Cloak.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
<Compile Include="Traits\Unit.cs" />
|
||||
<Compile Include="Traits\World\SpawnMapActors.cs" />
|
||||
<Compile Include="Traits\World\UnitInfluence.cs" />
|
||||
<Compile Include="Traits\World\WaterPaletteRotation.cs" />
|
||||
<Compile Include="Traits\Modifiers\WithShadow.cs" />
|
||||
<Compile Include="Network\UnitOrders.cs" />
|
||||
<Compile Include="Traits\Util.cs" />
|
||||
<Compile Include="UiOverlay.cs" />
|
||||
@@ -286,25 +215,17 @@
|
||||
<Compile Include="Widgets\WorldTooltipWidget.cs" />
|
||||
<Compile Include="World.cs" />
|
||||
<Compile Include="WorldUtils.cs" />
|
||||
<Compile Include="Traits\Wall.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
<Compile Include="Traits\Player\EvaAlerts.cs" />
|
||||
<Compile Include="Traits\World\ScreenShaker.cs" />
|
||||
<Compile Include="Traits\LineBuild.cs" />
|
||||
<Compile Include="Traits\World\Theater.cs" />
|
||||
<Compile Include="Traits\Cloak.cs" />
|
||||
<Compile Include="Widgets\WidgetLoader.cs" />
|
||||
<Compile Include="Widgets\ButtonWidget.cs" />
|
||||
<Compile Include="Widgets\Widget.cs" />
|
||||
<Compile Include="Widgets\BackgroundWidget.cs" />
|
||||
<Compile Include="Widgets\LabelWidget.cs" />
|
||||
<Compile Include="Widgets\CheckboxWidget.cs" />
|
||||
<Compile Include="Traits\HasUnitOnBuild.cs" />
|
||||
<Compile Include="Traits\Activities\Wait.cs" />
|
||||
<Compile Include="Traits\CrateAction.cs" />
|
||||
<Compile Include="Effects\CrateEffect.cs" />
|
||||
<Compile Include="Traits\World\GlobalDefaults.cs" />
|
||||
<Compile Include="Traits\RepairsUnits.cs" />
|
||||
<Compile Include="Traits\World\BibLayer.cs" />
|
||||
<Compile Include="Traits\World\SmudgeLayer.cs" />
|
||||
<Compile Include="Widgets\Delegates\IngameChromeDelegate.cs" />
|
||||
@@ -313,10 +234,10 @@
|
||||
<Compile Include="Widgets\PerfGraphWidget.cs" />
|
||||
<Compile Include="Widgets\Delegates\PerfDebugDelegate.cs" />
|
||||
<Compile Include="Widgets\BuildPaletteWidget.cs" />
|
||||
<Compile Include="Traits\World\BridgeLayer.cs" />
|
||||
<Compile Include="Widgets\Delegates\LobbyDelegate.cs" />
|
||||
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
||||
<Compile Include="GameRules\MusicInfo.cs" />
|
||||
<Compile Include="Widgets\PowerBinWidget.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -22,7 +22,6 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA.Orders
|
||||
{
|
||||
@@ -51,8 +50,16 @@ namespace OpenRA.Orders
|
||||
foreach (var a in Game.controller.selection.Actors)
|
||||
{
|
||||
world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
|
||||
if (a.traits.Contains<RenderRangeCircle>())
|
||||
world.WorldRenderer.DrawRangeCircle(a);
|
||||
if (a.Owner == world.LocalPlayer)
|
||||
{
|
||||
if (a.traits.Contains<RenderRangeCircle>())
|
||||
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
||||
a.Location, (int)a.GetPrimaryWeapon().Range);
|
||||
|
||||
if (a.traits.Contains<DetectCloaked>())
|
||||
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),
|
||||
a.Location, a.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +115,7 @@ namespace OpenRA.Orders
|
||||
case "Capture": return "capture";
|
||||
case "Harvest": return "attackmove";
|
||||
case "Steal" : return "enter";
|
||||
case "BeginMinefield": return "ability";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,33 +41,39 @@ namespace OpenRA
|
||||
public readonly string InternalName;
|
||||
public readonly CountryInfo Country;
|
||||
public readonly int Index;
|
||||
|
||||
public readonly bool NonCombatant = false;
|
||||
|
||||
public ShroudRenderer Shroud;
|
||||
public World World { get; private set; }
|
||||
|
||||
public Player( World world, Session.Client client )
|
||||
public Player( World world, PlayerReference pr, int index )
|
||||
{
|
||||
World = world;
|
||||
Shroud = new ShroudRenderer(this, world.Map);
|
||||
|
||||
PlayerActor = world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
|
||||
|
||||
if (client != null)
|
||||
{
|
||||
Index = client.Index;
|
||||
Palette = world.PlayerColors()[client.PaletteIndex % world.PlayerColors().Count()].Name;
|
||||
Color = world.PlayerColors()[client.PaletteIndex % world.PlayerColors().Count()].Color;
|
||||
PlayerName = client.Name;
|
||||
InternalName = "Multi{0}".F(client.Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
Index = -1;
|
||||
PlayerName = InternalName = "Neutral";
|
||||
Palette = "neutral";
|
||||
Color = Color.Gray; // HACK HACK
|
||||
}
|
||||
Index = index;
|
||||
Palette = pr.Palette;
|
||||
Color = world.PlayerColors().Where(c => c.Name == pr.Palette).FirstOrDefault().Color;
|
||||
PlayerName = InternalName = pr.Name;
|
||||
NonCombatant = pr.NonCombatant;
|
||||
Country = world.GetCountries()
|
||||
.FirstOrDefault(c => pr.Race == c.Race);
|
||||
}
|
||||
|
||||
public Player( World world, Session.Client client )
|
||||
{
|
||||
World = world;
|
||||
Shroud = new ShroudRenderer(this, world.Map);
|
||||
|
||||
PlayerActor = world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
|
||||
|
||||
Index = client.Index;
|
||||
Palette = world.PlayerColors()[client.PaletteIndex % world.PlayerColors().Count()].Name;
|
||||
Color = world.PlayerColors()[client.PaletteIndex % world.PlayerColors().Count()].Color;
|
||||
PlayerName = client.Name;
|
||||
InternalName = "Multi{0}".F(client.Index);
|
||||
Country = world.GetCountries()
|
||||
.FirstOrDefault(c => client != null && client.Country == c.Name)
|
||||
?? world.GetCountries().Random(world.SharedRandom);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace OpenRA.Server
|
||||
|
||||
class GameServer
|
||||
{
|
||||
public readonly int Id = 0;
|
||||
public readonly string Name = null;
|
||||
public readonly string Address = null;
|
||||
public readonly int State = 0;
|
||||
|
||||
@@ -28,6 +28,7 @@ using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Server
|
||||
{
|
||||
@@ -540,11 +541,14 @@ namespace OpenRA.Server
|
||||
if (wc.IsBusy || !isInternetServer) return;
|
||||
|
||||
var url = "ping.php?port={0}&name={1}&state={2}&players={3}&mods={4}&map={5}";
|
||||
wc.DownloadDataCompleted += PingMasterServerResponse;
|
||||
if (isInitialPing)
|
||||
{
|
||||
url += "&new=1";
|
||||
isInitialPing = false;
|
||||
}
|
||||
else
|
||||
wc.DownloadDataCompleted -= PingMasterServerResponse;
|
||||
|
||||
wc.DownloadDataAsync(new Uri(
|
||||
masterServerUrl + url.F(
|
||||
@@ -556,5 +560,14 @@ namespace OpenRA.Server
|
||||
|
||||
lastPing = Environment.TickCount;
|
||||
}
|
||||
|
||||
static void PingMasterServerResponse(object sender, DownloadDataCompletedEventArgs e)
|
||||
{
|
||||
string s = Encoding.UTF8.GetString(e.Result);
|
||||
int gameId;
|
||||
if (int.TryParse(s.Trim(), out gameId))
|
||||
Game.SetGameId(gameId);
|
||||
Log.Write("debug", "Game ID: {0}", gameId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace OpenRA
|
||||
Al.alGenSources(1, out source);
|
||||
if (0 != Al.alGetError())
|
||||
{
|
||||
Log.Write("Failed generating OpenAL source {0}", i);
|
||||
Log.Write("debug", "Failed generating OpenAL source {0}", i);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using System.Net;
|
||||
using System.IO.Compression;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -32,10 +35,11 @@ namespace OpenRA
|
||||
{
|
||||
// brutal hack
|
||||
Application.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
Log.AddChannel("perf", "openra.perf.txt", false, false);
|
||||
|
||||
if( Debugger.IsAttached )
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Run( args );
|
||||
Run(args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,7 +49,9 @@ namespace OpenRA
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.Write( "{0}", e.ToString() );
|
||||
Log.AddChannel("exception", "openra.exception.txt", true, false);
|
||||
Log.Write("exception", "{0}", e.ToString());
|
||||
Log.Upload(Game.GetGameId());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
/* non-turreted attack */
|
||||
class Attack : IActivity
|
||||
public class Attack : IActivity
|
||||
{
|
||||
Actor Target;
|
||||
int Range;
|
||||
|
||||
@@ -22,8 +22,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
|
||||
@@ -48,7 +48,9 @@ namespace OpenRA.Traits.Activities
|
||||
{
|
||||
if( !started )
|
||||
{
|
||||
framesRemaining = (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation) ? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
framesRemaining = self.traits.Get<RenderSimple>().anim.HasSequence("make")
|
||||
? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
|
||||
foreach( var ns in self.traits.WithInterface<INotifySold>() )
|
||||
ns.Selling( self );
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
class UndeployMcv : IActivity
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
|
||||
public class Wait: IActivity
|
||||
{
|
||||
int remainingTicks;
|
||||
|
||||
public Wait (int period)
|
||||
{
|
||||
remainingTicks = period;
|
||||
}
|
||||
|
||||
public IActivity Tick (Actor self)
|
||||
{
|
||||
if (remainingTicks-- == 0) return NextActivity;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void Cancel (Actor self)
|
||||
{
|
||||
remainingTicks = 0; NextActivity = null;
|
||||
}
|
||||
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
3
OpenRA.Game/Traits/Attack/AttackBase.cs → OpenRA.Game/Traits/AttackBase.cs
Executable file → Normal file
3
OpenRA.Game/Traits/Attack/AttackBase.cs → OpenRA.Game/Traits/AttackBase.cs
Executable file → Normal file
@@ -20,7 +20,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.FileFormats;
|
||||
@@ -43,7 +42,7 @@ namespace OpenRA.Traits
|
||||
public virtual object Create(Actor self) { return new AttackBase(self); }
|
||||
}
|
||||
|
||||
class AttackBase : IIssueOrder, IResolveOrder, ITick
|
||||
public class AttackBase : IIssueOrder, IResolveOrder, ITick
|
||||
{
|
||||
[Sync] public Actor target;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ValuedInfo : ITraitInfo
|
||||
public class ValuedInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Cost = 0;
|
||||
public readonly string Description = "";
|
||||
|
||||
@@ -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.
|
||||
@@ -20,40 +20,46 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class CloakInfo : ITraitInfo
|
||||
{
|
||||
public readonly float InitialDelay = .4f; // seconds
|
||||
public readonly float CloakDelay = 1.2f; // Seconds
|
||||
public readonly string CloakSound = "appear1.aud";
|
||||
public readonly string UncloakSound = "appear1.aud";
|
||||
public readonly string CloakSound = "subshow1.aud";
|
||||
public readonly string UncloakSound = "subshow1.aud";
|
||||
public object Create(Actor self) { return new Cloak(self); }
|
||||
}
|
||||
|
||||
class Cloak : IRenderModifier, INotifyAttack, ITick
|
||||
public class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage
|
||||
{
|
||||
[Sync]
|
||||
int remainingUncloakTime = 2; /* setup for initial cloak */
|
||||
|
||||
int remainingTime;
|
||||
|
||||
Actor self;
|
||||
public Cloak(Actor self)
|
||||
{
|
||||
remainingTime = (int)(self.Info.Traits.Get<CloakInfo>().InitialDelay * 25);
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void Attacking(Actor self)
|
||||
void DoSurface()
|
||||
{
|
||||
if (remainingUncloakTime <= 0)
|
||||
OnCloak();
|
||||
if (remainingTime <= 0)
|
||||
OnSurface();
|
||||
|
||||
remainingUncloakTime = (int)(self.Info.Traits.Get<CloakInfo>().CloakDelay * 25);
|
||||
remainingTime = Math.Max(remainingTime, (int)(self.Info.Traits.Get<CloakInfo>().CloakDelay * 25));
|
||||
}
|
||||
|
||||
public void Attacking(Actor self) { DoSurface(); }
|
||||
public void Damaged(Actor self, AttackInfo e) { DoSurface(); }
|
||||
|
||||
public IEnumerable<Renderable>
|
||||
ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||
{
|
||||
if (remainingUncloakTime > 0)
|
||||
if (remainingTime > 0)
|
||||
return rs;
|
||||
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
@@ -64,19 +70,27 @@ namespace OpenRA.Traits
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (remainingUncloakTime > 0)
|
||||
if (--remainingUncloakTime <= 0)
|
||||
OnUncloak();
|
||||
if (remainingTime > 0)
|
||||
if (--remainingTime <= 0)
|
||||
OnDive();
|
||||
}
|
||||
|
||||
void OnCloak()
|
||||
void OnSurface()
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<CloakInfo>().UncloakSound, self.CenterLocation);
|
||||
}
|
||||
|
||||
void OnDive()
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<CloakInfo>().CloakSound, self.CenterLocation);
|
||||
}
|
||||
|
||||
void OnUncloak()
|
||||
public bool Cloaked { get { return remainingTime > 0; } }
|
||||
|
||||
public void Decloak(int time)
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<CloakInfo>().UncloakSound, self.CenterLocation);
|
||||
DoSurface();
|
||||
remainingTime = Math.Max(remainingTime, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,77 +19,35 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ConstructionYardInfo : ITraitInfo
|
||||
class ConstructionYardInfo : TraitInfo<ConstructionYard> { }
|
||||
|
||||
public class ConstructionYard : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public readonly bool AllowUndeploy = true;
|
||||
|
||||
public object Create(Actor self) { return new ConstructionYard(self); }
|
||||
}
|
||||
|
||||
class ConstructionYard : IIssueOrder, IResolveOrder, IMovement
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
public ConstructionYard(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (!self.Info.Traits.Get<ConstructionYardInfo>().AllowUndeploy) return null;
|
||||
|
||||
if (mi.Button == MouseButton.Left) return null;
|
||||
|
||||
if (underCursor != null)
|
||||
{
|
||||
// force-move
|
||||
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
|
||||
if (!self.World.IsActorCrushableByActor(underCursor, self)) return null;
|
||||
}
|
||||
if (self.traits.GetOrDefault<IMovement>().CanEnterCell(xy))
|
||||
return new Order("Move", self, xy);
|
||||
else
|
||||
return null;
|
||||
|
||||
if (underCursor == self)
|
||||
return new Order("Deploy", self);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Move")
|
||||
if (order.OrderString == "Deploy")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new UndeployMcv());
|
||||
}
|
||||
}
|
||||
|
||||
// HACK: This should make reference to an MCV actor, and use of its Mobile trait
|
||||
public UnitMovementType GetMovementType() { return UnitMovementType.Wheel; }
|
||||
|
||||
public bool CanEnterCell(int2 a)
|
||||
{
|
||||
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(a)) return false;
|
||||
|
||||
var crushable = true;
|
||||
foreach (Actor actor in self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a))
|
||||
{
|
||||
if (actor == self) continue;
|
||||
|
||||
if (!self.World.IsActorCrushableByActor(actor, self))
|
||||
{
|
||||
crushable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!crushable) return false;
|
||||
|
||||
return self.World.Map.IsInMap(a.X, a.Y) &&
|
||||
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])]
|
||||
.GetCost(GetMovementType()) < float.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
|
||||
/* tag trait for "bases": mcv/fact */
|
||||
|
||||
class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
|
||||
class BaseBuilding { }
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace OpenRA.Traits
|
||||
// allow a nonstandard sell/repair value to avoid
|
||||
// buy-sell exploits like c&c's PROC.
|
||||
|
||||
class CustomSellValueInfo : TraitInfo<CustomSellValue>
|
||||
public class CustomSellValueInfo : TraitInfo<CustomSellValue>
|
||||
{
|
||||
public readonly int Value = 0;
|
||||
}
|
||||
|
||||
class CustomSellValue {}
|
||||
public class CustomSellValue { }
|
||||
}
|
||||
|
||||
58
OpenRA.Game/Traits/DetectCloaked.cs
Normal file
58
OpenRA.Game/Traits/DetectCloaked.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
#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.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class DetectCloakedInfo : TraitInfo<DetectCloaked>
|
||||
{
|
||||
public readonly int Interval = 12; // ~.5s
|
||||
public readonly float DecloakTime = 2f; // 2s
|
||||
public readonly int Range = 5;
|
||||
public readonly bool AffectOwnUnits = true;
|
||||
}
|
||||
|
||||
class DetectCloaked : ITick
|
||||
{
|
||||
[Sync] int ticks;
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
var info = self.Info.Traits.Get<DetectCloakedInfo>();
|
||||
ticks = info.Interval;
|
||||
|
||||
var toDecloak = self.World.FindUnitsInCircle(self.CenterLocation, info.Range * Game.CellSize)
|
||||
.Where(a => a.traits.Contains<Cloak>());
|
||||
|
||||
if (!info.AffectOwnUnits)
|
||||
toDecloak = toDecloak.Where(a => self.Owner.Stances[a.Owner] != Stance.Ally);
|
||||
|
||||
foreach (var a in toDecloak)
|
||||
a.traits.Get<Cloak>().Decloak((int)(25 * info.DecloakTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
class HasUnitOnBuildInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Unit = null;
|
||||
public readonly string InitialActivity = null;
|
||||
public readonly int2 SpawnOffset = int2.Zero;
|
||||
public readonly int Facing = 0;
|
||||
|
||||
public object Create( Actor self ) { return new HasUnitOnBuild(self); }
|
||||
}
|
||||
|
||||
public class HasUnitOnBuild
|
||||
{
|
||||
|
||||
public HasUnitOnBuild(Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.Get<HasUnitOnBuildInfo>();
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{
|
||||
var unit = w.CreateActor(info.Unit, self.Location
|
||||
+ info.SpawnOffset, self.Owner);
|
||||
var unitTrait = unit.traits.Get<Unit>();
|
||||
unitTrait.Facing = info.Facing;
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
unit.QueueActivity(Game.CreateObject<IActivity>(info.InitialActivity));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Traits
|
||||
var umt = self.Info.Traits.Get<MobileInfo>().MovementType;
|
||||
if (Util.GetEffectiveSpeed(self,umt) == 0) return null; /* allow disabling move orders from modifiers */
|
||||
if (xy == toCell) return null;
|
||||
return new Order("Move", self, xy);
|
||||
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
@@ -96,7 +96,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if (self.traits.GetOrDefault<IMovement>().CanEnterCell(order.TargetLocation))
|
||||
{
|
||||
self.CancelActivity();
|
||||
if( !order.Queued ) self.CancelActivity();
|
||||
self.QueueActivity(new Activities.Move(order.TargetLocation, 8));
|
||||
}
|
||||
}
|
||||
@@ -114,26 +114,16 @@ namespace OpenRA.Traits
|
||||
return self.Info.Traits.Get<MobileInfo>().MovementType;
|
||||
}
|
||||
|
||||
public bool CanEnterCell(int2 a)
|
||||
public bool CanEnterCell(int2 p)
|
||||
{
|
||||
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(a)) return false;
|
||||
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(p)) return false;
|
||||
|
||||
var crushable = true;
|
||||
foreach (Actor actor in self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a))
|
||||
{
|
||||
if (actor == self) continue;
|
||||
|
||||
if (!self.World.IsActorCrushableByActor(actor, self))
|
||||
{
|
||||
crushable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any(
|
||||
a => a != self && !self.World.IsActorCrushableByActor(a, self)))
|
||||
return false;
|
||||
|
||||
if (!crushable) return false;
|
||||
|
||||
return self.World.Map.IsInMap(a.X, a.Y) &&
|
||||
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])]
|
||||
return self.World.Map.IsInMap(p.X, p.Y) &&
|
||||
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[p.X, p.Y])]
|
||||
.GetCost(GetMovementType()) < float.PositiveInfinity;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class EvaAlertsInfo : TraitInfo<EvaAlerts>
|
||||
public class EvaAlertsInfo : TraitInfo<EvaAlerts>
|
||||
{
|
||||
// Sound effects
|
||||
public readonly string TabClick = "ramenu1.aud";
|
||||
@@ -59,5 +59,5 @@ namespace OpenRA.Traits
|
||||
public readonly string CreditsStolen = "credit1.aud";
|
||||
}
|
||||
|
||||
class EvaAlerts {}
|
||||
public class EvaAlerts {}
|
||||
}
|
||||
|
||||
@@ -27,41 +27,44 @@ namespace OpenRA.Traits
|
||||
|
||||
class PlaceBuilding : IResolveOrder
|
||||
{
|
||||
public void ResolveOrder( Actor self, Order order )
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if( order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild" )
|
||||
if (order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild")
|
||||
{
|
||||
self.World.AddFrameEndTask( w =>
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var prevItems = GetNumBuildables(self.Owner);
|
||||
|
||||
var queue = self.traits.Get<ProductionQueue>();
|
||||
var unit = Rules.Info[ order.TargetString ];
|
||||
var unit = Rules.Info[order.TargetString];
|
||||
var producing = queue.CurrentItem(unit.Category);
|
||||
|
||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||
if (producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0)
|
||||
return;
|
||||
|
||||
if( order.OrderString == "LineBuild" )
|
||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||
|
||||
if (order.OrderString == "LineBuild")
|
||||
{
|
||||
bool playSounds = true;
|
||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||
foreach( var t in LineBuildUtils.GetLineBuildCells( w, order.TargetLocation, order.TargetString, buildingInfo ) )
|
||||
foreach (var t in LineBuildUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
|
||||
{
|
||||
var building = w.CreateActor( order.TargetString, t, order.Player );
|
||||
if( playSounds )
|
||||
foreach( var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds )
|
||||
Sound.PlayToPlayer( order.Player, s, building.CenterLocation );
|
||||
var building = w.CreateActor(order.TargetString, t, order.Player);
|
||||
if (playSounds)
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
|
||||
playSounds = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var building = w.CreateActor( order.TargetString, order.TargetLocation, order.Player );
|
||||
foreach (var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds)
|
||||
var building = w.CreateActor(order.TargetString, order.TargetLocation, order.Player);
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
|
||||
}
|
||||
|
||||
/* todo: reimpl this properly */
|
||||
|
||||
var facts = w.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<ConstructionYard>().Select(x => x.Actor);
|
||||
|
||||
@@ -77,7 +80,7 @@ namespace OpenRA.Traits
|
||||
w.Add(new DelayedAction(10,
|
||||
() => Sound.PlayToPlayer(order.Player,
|
||||
w.WorldActor.Info.Traits.Get<EvaAlertsInfo>().NewOptions)));
|
||||
} );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace OpenRA.Traits
|
||||
return production[category];
|
||||
}
|
||||
|
||||
public void CancelProduction( string itemName )
|
||||
void CancelProduction( string itemName )
|
||||
{
|
||||
var category = Rules.Info[itemName].Category;
|
||||
var queue = production[ category ];
|
||||
@@ -149,12 +149,12 @@ namespace OpenRA.Traits
|
||||
queue.RemoveAt(0);
|
||||
}
|
||||
|
||||
public void BeginProduction( string group, ProductionItem item )
|
||||
void BeginProduction( string group, ProductionItem item )
|
||||
{
|
||||
production[group].Add(item);
|
||||
}
|
||||
|
||||
public void BuildUnit( string name )
|
||||
void BuildUnit( string name )
|
||||
{
|
||||
var newUnitType = Rules.Info[ name ];
|
||||
var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType );
|
||||
@@ -193,7 +193,7 @@ namespace OpenRA.Traits
|
||||
return;
|
||||
}
|
||||
|
||||
if( producer.traits.WithInterface<IProducer>().Any( p => p.Produce( producer, newUnitType ) ) )
|
||||
if( producer.traits.WithInterface<Production>().Any( p => p.Produce( producer, newUnitType ) ) )
|
||||
FinishProduction( newUnitType.Category );
|
||||
}
|
||||
}
|
||||
@@ -214,12 +214,13 @@ namespace OpenRA.Traits
|
||||
|
||||
public ProductionItem(string item, int time, int cost, Action onComplete)
|
||||
{
|
||||
if (time <= 0)
|
||||
time = 1;
|
||||
if (time <= 0) time = 1;
|
||||
Item = item;
|
||||
RemainingTime = TotalTime = time;
|
||||
RemainingCost = TotalCost = cost;
|
||||
OnComplete = onComplete;
|
||||
|
||||
Log.Write("debug", "new ProductionItem: {0} time={1} cost={2}", item, time, cost);
|
||||
}
|
||||
|
||||
public void Tick(Player player)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -34,11 +34,8 @@ namespace OpenRA.Traits
|
||||
public virtual object Create(Actor self) { return new Production(self); }
|
||||
}
|
||||
|
||||
public class Production : IIssueOrder, IResolveOrder, IProducer, ITags
|
||||
{
|
||||
bool isPrimary = false;
|
||||
public bool IsPrimary { get { return isPrimary; } }
|
||||
|
||||
public class Production : IIssueOrder, IResolveOrder, ITags
|
||||
{
|
||||
public Production( Actor self ) { }
|
||||
|
||||
public virtual int2? CreationLocation( Actor self, ActorInfo producee )
|
||||
@@ -96,9 +93,16 @@ namespace OpenRA.Traits
|
||||
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
||||
t.UnitProduced(self, newUnit);
|
||||
|
||||
Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// "primary building" crap - perhaps this should be split?
|
||||
|
||||
bool isPrimary = false;
|
||||
public bool IsPrimary { get { return isPrimary; } }
|
||||
|
||||
public IEnumerable<TagType> GetTags()
|
||||
{
|
||||
yield return (isPrimary) ? TagType.Primary : TagType.None;
|
||||
|
||||
@@ -22,10 +22,7 @@ using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ProvidesRadarInfo : ITraitInfo
|
||||
{
|
||||
public object Create( Actor self ) { return new ProvidesRadar(); }
|
||||
}
|
||||
class ProvidesRadarInfo : TraitInfo<ProvidesRadar> { }
|
||||
|
||||
class ProvidesRadar : ITick
|
||||
{
|
||||
@@ -46,10 +43,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
|
||||
class JamsRadarInfo : TraitInfo<JamsRadar>
|
||||
{
|
||||
public readonly int Range = 0;
|
||||
}
|
||||
class JamsRadarInfo : TraitInfo<JamsRadar> { public readonly int Range = 0; }
|
||||
|
||||
class JamsRadar { }
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits.Render
|
||||
{
|
||||
class RenderFlareInfo : RenderSimpleInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new RenderFlare(self); }
|
||||
}
|
||||
|
||||
class RenderFlare : RenderSimple
|
||||
{
|
||||
public RenderFlare(Actor self)
|
||||
: base(self, () => 0)
|
||||
{
|
||||
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,4 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
#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 OpenRA.GameRules;
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class SquishByTankInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new SquishByTank(self); }
|
||||
}
|
||||
|
||||
class SquishByTank : ICrushable
|
||||
{
|
||||
readonly Actor self;
|
||||
public SquishByTank(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
// ... this wasnt working ANYWAY ...
|
||||
// self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]);
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return IsCrushableBy(umt, player);
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
if (player == self.Owner) return false;
|
||||
switch (umt)
|
||||
{
|
||||
case UnitMovementType.Track: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
#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.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class SubmarineInfo : ITraitInfo
|
||||
{
|
||||
public readonly float SubmergeDelay = 1.2f; // Seconds
|
||||
public readonly string SubmergeSound = "subshow1.aud";
|
||||
public readonly string SurfaceSound = "subshow1.aud";
|
||||
public object Create(Actor self) { return new Submarine(self); }
|
||||
}
|
||||
|
||||
class Submarine : IRenderModifier, INotifyAttack, ITick, INotifyDamage
|
||||
{
|
||||
[Sync]
|
||||
int remainingSurfaceTime = 2; /* setup for initial dive */
|
||||
|
||||
Actor self;
|
||||
public Submarine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
void DoSurface()
|
||||
{
|
||||
if (remainingSurfaceTime <= 0)
|
||||
OnSurface();
|
||||
|
||||
remainingSurfaceTime = (int)(self.Info.Traits.Get<SubmarineInfo>().SubmergeDelay * 25);
|
||||
}
|
||||
|
||||
public void Attacking(Actor self) { DoSurface(); }
|
||||
public void Damaged(Actor self, AttackInfo e) { DoSurface(); }
|
||||
|
||||
public IEnumerable<Renderable>
|
||||
ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||
{
|
||||
if (remainingSurfaceTime > 0)
|
||||
return rs;
|
||||
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
return rs.Select(a => a.WithPalette("shadow"));
|
||||
else
|
||||
return new Renderable[] { };
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (remainingSurfaceTime > 0)
|
||||
if (--remainingSurfaceTime <= 0)
|
||||
OnDive();
|
||||
}
|
||||
|
||||
void OnSurface()
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<SubmarineInfo>().SurfaceSound, self.CenterLocation);
|
||||
}
|
||||
|
||||
void OnDive()
|
||||
{
|
||||
Sound.Play(self.Info.Traits.Get<SubmarineInfo>().SubmergeSound, self.CenterLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,15 @@ namespace OpenRA.Traits
|
||||
public enum TagType { None, Fake, Primary };
|
||||
public enum Stance { Enemy, Neutral, Ally };
|
||||
|
||||
public class AttackInfo
|
||||
{
|
||||
public Actor Attacker;
|
||||
public WarheadInfo Warhead;
|
||||
public int Damage;
|
||||
public DamageState DamageState;
|
||||
public bool DamageStateChanged;
|
||||
}
|
||||
|
||||
public interface ITick { void Tick(Actor self); }
|
||||
public interface IRender { IEnumerable<Renderable> Render(Actor self); }
|
||||
public interface IIssueOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); }
|
||||
@@ -50,14 +59,9 @@ namespace OpenRA.Traits
|
||||
float GetCost(int2 p, UnitMovementType umt);
|
||||
float GetSpeedModifier(int2 p, UnitMovementType umt);
|
||||
}
|
||||
|
||||
public interface IDisable { bool Disabled { get; } }
|
||||
|
||||
public interface IDisable { bool Disabled { get; set; } }
|
||||
|
||||
interface IProducer
|
||||
{
|
||||
bool Produce( Actor self, ActorInfo producee );
|
||||
void SetPrimaryProducer(Actor self, bool isPrimary);
|
||||
}
|
||||
public interface IOccupySpace { IEnumerable<int2> OccupiedCells(); }
|
||||
public interface INotifyAttack { void Attacking(Actor self); }
|
||||
public interface IRenderModifier { IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r); }
|
||||
@@ -135,4 +139,5 @@ namespace OpenRA.Traits
|
||||
public interface INotifyIdle { void Idle(Actor self); }
|
||||
|
||||
public interface IVictoryConditions { bool HasLost { get; } bool HasWon { get; } }
|
||||
public interface IBlocksBullets { }
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Traits
|
||||
public object Create(Actor self) { return new Turreted(self); }
|
||||
}
|
||||
|
||||
class Turreted : ITick
|
||||
public class Turreted : ITick
|
||||
{
|
||||
[Sync]
|
||||
public int turretFacing = 0;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
|
||||
@@ -68,8 +68,8 @@ namespace OpenRA.Traits
|
||||
|
||||
int bib = Array.IndexOf(info.BibWidths,size);
|
||||
if (bib < 0)
|
||||
{
|
||||
Log.Write("Cannot bib {0}-wide building {1}",size,b.Info.Name);
|
||||
{
|
||||
Log.Write("debug", "Cannot bib {0}-wide building {1}", size, b.Info.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public class ShroudInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Shroud(self, this); }
|
||||
public object Create(Actor self) { return new Shroud(self); }
|
||||
}
|
||||
|
||||
public class Shroud
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Traits
|
||||
public Rectangle? exploredBounds;
|
||||
public event Action Dirty = () => { };
|
||||
|
||||
public Shroud(Actor self, ShroudInfo info)
|
||||
public Shroud(Actor self)
|
||||
{
|
||||
map = self.World.Map;
|
||||
visibleCells = new int[map.MapSize.X, map.MapSize.Y];
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class SpawnMapActorsInfo : TraitInfo<SpawnMapActors> { }
|
||||
|
||||
public class SpawnMapActors : IGameStarted
|
||||
{
|
||||
public Dictionary<string, Actor> MapActors = new Dictionary<string, Actor>();
|
||||
|
||||
public void GameStarted(World world)
|
||||
{
|
||||
Game.skipMakeAnims = true; // rude hack
|
||||
|
||||
foreach (var actorReference in world.Map.Actors)
|
||||
MapActors[actorReference.Key] = world.CreateActor(actorReference.Value.Name, actorReference.Value.Location,
|
||||
world.players.Values.FirstOrDefault(p => p.InternalName == actorReference.Value.Owner)
|
||||
?? world.NeutralPlayer);
|
||||
|
||||
Game.skipMakeAnims = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,14 @@ namespace OpenRA
|
||||
public void Draw( World world )
|
||||
{
|
||||
if (Game.Settings.UnitDebug)
|
||||
for (var i = 0; i < world.Map.MapSize.X; i++)
|
||||
for (var j = 0; j < world.Map.MapSize.Y; j++)
|
||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(new int2(i, j)).Any())
|
||||
{
|
||||
var uim = world.WorldActor.traits.Get<UnitInfluence>();
|
||||
|
||||
for (var i = world.Map.Bounds.Left; i < world.Map.Bounds.Right; i++)
|
||||
for (var j = world.Map.Bounds.Top; j < world.Map.Bounds.Bottom; j++)
|
||||
if (uim.GetUnitsAt(new int2(i, j)).Any())
|
||||
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), "terrain");
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawBuildingGrid( World world, string name, BuildingInfo bi )
|
||||
|
||||
@@ -25,17 +25,11 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public readonly string Background = "dialog";
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
var pos = DrawPosition();
|
||||
var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
||||
WidgetUtils.DrawPanel(Background, rect);
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
public BackgroundWidget() : base() { }
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Draw (World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
int paletteHeight = DrawPalette(world, currentTab);
|
||||
DrawBuildTabs(world, paletteHeight);
|
||||
@@ -181,11 +181,6 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
|
||||
|
||||
if (!Visible)
|
||||
{
|
||||
base.Draw(world);
|
||||
return 0;
|
||||
}
|
||||
buttons.Clear();
|
||||
|
||||
|
||||
|
||||
@@ -79,13 +79,8 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
var pos = DrawPosition();
|
||||
|
||||
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||
@@ -97,8 +92,6 @@ namespace OpenRA.Widgets
|
||||
new int2( pos.X + Bounds.Width / 2, pos.Y + Bounds.Height / 2)
|
||||
- new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2,
|
||||
Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White);
|
||||
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
|
||||
@@ -28,13 +28,8 @@ namespace OpenRA.Widgets
|
||||
public string Text = "";
|
||||
public Func<bool> Checked = () => {return false;};
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
var pos = DrawPosition();
|
||||
var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
||||
WidgetUtils.DrawPanel("dialog3", new Rectangle(rect.Location,
|
||||
@@ -56,8 +51,6 @@ namespace OpenRA.Widgets
|
||||
Color.White);
|
||||
Game.chrome.lineRenderer.Flush();
|
||||
}
|
||||
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
public CheckboxWidget() : base() { }
|
||||
|
||||
@@ -44,18 +44,11 @@ namespace OpenRA.Widgets
|
||||
return new ColorBlockWidget(this);
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
|
||||
var pos = DrawPosition();
|
||||
var paletteRect = new RectangleF(pos.X + Game.viewport.Location.X, pos.Y + Game.viewport.Location.Y, Bounds.Width, Bounds.Height);
|
||||
Game.chrome.lineRenderer.FillRect(paletteRect, GetColor());
|
||||
base.Draw(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
r.GetWidget("CREATESERVER_BUTTON_START").OnMouseUp = mi => {
|
||||
r.OpenWindow("SERVER_LOBBY");
|
||||
Log.Write("Creating server");
|
||||
Log.Write("debug", "Creating server");
|
||||
|
||||
// TODO: Get this from a map chooser
|
||||
string map = Game.AvailableMaps.Keys.FirstOrDefault();
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
gameName, Game.Settings.ListenPort,
|
||||
Game.Settings.ExternalPort, mods, map);
|
||||
|
||||
Log.Write("Joining server");
|
||||
Log.Write("debug", "Joining server");
|
||||
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.Children.RemoveAll(w => controls.Contains(w));
|
||||
controls.Clear();
|
||||
|
||||
var unwantedPlayers = new[] { Game.world.NeutralPlayer, Game.world.LocalPlayer };
|
||||
var y = 50;
|
||||
var margin = 20;
|
||||
var labelWidth = (bg.Bounds.Width - 3 * margin) / 3;
|
||||
@@ -58,7 +57,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
y += 35;
|
||||
|
||||
foreach (var p in Game.world.players.Values.Except(unwantedPlayers))
|
||||
foreach (var p in Game.world.players.Values.Where(a => a != Game.world.LocalPlayer && !a.NonCombatant))
|
||||
{
|
||||
var pp = p;
|
||||
var label = new LabelWidget
|
||||
|
||||
@@ -44,9 +44,14 @@ namespace OpenRA.Widgets.Delegates
|
||||
r.OpenWindow("MAP_CHOOSER");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||
|
||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnMouseUp = mi => {
|
||||
Game.Disconnect();
|
||||
return true;
|
||||
};
|
||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||
}
|
||||
|
||||
@@ -114,7 +119,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
}
|
||||
}
|
||||
|
||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index) && Game.world.PlayerColors()[index % Game.world.PlayerColors().Count].Playable; }
|
||||
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||
|
||||
bool CyclePalette(MouseInput mi)
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
r.GetWidget("JOINSERVER_BG").Visible = false;
|
||||
Game.JoinServer(g.Address.Split(':')[0], int.Parse(g.Address.Split(':')[1]));
|
||||
Game.SetGameId(g.Id);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -52,14 +52,8 @@ namespace OpenRA.Widgets
|
||||
GetText = (other as LabelWidget).GetText;
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
|
||||
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
|
||||
var text = GetText();
|
||||
int2 textSize = font.Measure(text);
|
||||
@@ -69,7 +63,6 @@ namespace OpenRA.Widgets
|
||||
position += new int2((Bounds.Width - textSize.X)/2, 0);
|
||||
|
||||
font.DrawText(text, position, Color.White);
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { return new MapPreviewWidget(this); }
|
||||
|
||||
public override void Draw( World world )
|
||||
public override void DrawInner( World world )
|
||||
{
|
||||
var map = Game.chrome.currentMap;
|
||||
if( map == null ) return;
|
||||
@@ -55,7 +55,6 @@ namespace OpenRA.Widgets
|
||||
new float2( mapRect.Size ) );
|
||||
|
||||
DrawSpawnPoints( map, new Rectangle(pos.X, pos.Y, Parent.Bounds.Width, Parent.Bounds.Height ), world );
|
||||
base.Draw( world );
|
||||
}
|
||||
|
||||
void DrawSpawnPoints(MapStub map, Rectangle container, World world)
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { return new MoneyBinWidget(this); }
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
var playerResources = world.LocalPlayer.PlayerActor.traits.Get<PlayerResources>();
|
||||
|
||||
|
||||
@@ -32,13 +32,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { return new PerfGraphWidget(this); }
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
var pos = DrawPosition();
|
||||
var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
||||
float2 origin = Game.viewport.Location + new float2(rect.Right,rect.Bottom);
|
||||
@@ -62,8 +57,6 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
Game.chrome.lineRenderer.Flush();
|
||||
|
||||
base.Draw(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,16 +36,14 @@ namespace OpenRA.Widgets
|
||||
|
||||
// todo: all this shit needs to move, probably to Player.
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
base.Draw(world);
|
||||
|
||||
if (world.LocalPlayer == null) return;
|
||||
|
||||
if (world.players.Count > 2) /* more than just us + neutral */
|
||||
{
|
||||
var conds = world.Queries.WithTrait<IVictoryConditions>()
|
||||
.Where(c => c.Actor.Owner != world.NeutralPlayer);
|
||||
.Where(c => !c.Actor.Owner.NonCombatant);
|
||||
|
||||
if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost))
|
||||
DrawText("YOU ARE DEFEATED");
|
||||
|
||||
100
OpenRA.Game/Widgets/PowerBinWidget.cs
Normal file
100
OpenRA.Game/Widgets/PowerBinWidget.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
#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.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
|
||||
public class PowerBinWidget : Widget
|
||||
{
|
||||
// Power bar
|
||||
static float2 powerOrigin = new float2(42, 205); // Relative to radarOrigin
|
||||
static Size powerSize = new Size(138, 5);
|
||||
float? lastPowerProvidedPos;
|
||||
float? lastPowerDrainedPos;
|
||||
string powerCollection;
|
||||
|
||||
public override Widget Clone() { throw new NotImplementedException("Why are you Cloning PowerBin?"); }
|
||||
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
||||
|
||||
var resources = world.LocalPlayer.PlayerActor.traits.Get<PlayerResources>();
|
||||
|
||||
// Nothing to draw
|
||||
if (resources.PowerProvided == 0
|
||||
&& resources.PowerDrained == 0)
|
||||
return;
|
||||
|
||||
var renderer = Game.chrome.renderer;
|
||||
var lineRenderer = Game.chrome.lineRenderer;
|
||||
var rgbaRenderer = renderer.RgbaSpriteRenderer;
|
||||
|
||||
// Draw bar horizontally
|
||||
var barStart = powerOrigin + RadarBinWidget.radarOrigin;
|
||||
var barEnd = barStart + new float2(powerSize.Width, 0);
|
||||
|
||||
float powerScaleBy = 100;
|
||||
var maxPower = Math.Max(resources.PowerProvided, resources.PowerDrained);
|
||||
while (maxPower >= powerScaleBy) powerScaleBy *= 2;
|
||||
|
||||
// Current power supply
|
||||
var powerLevelTemp = barStart.X + (barEnd.X - barStart.X) * (resources.PowerProvided / powerScaleBy);
|
||||
lastPowerProvidedPos = float2.Lerp(lastPowerProvidedPos.GetValueOrDefault(powerLevelTemp), powerLevelTemp, .3f);
|
||||
float2 powerLevel = new float2(lastPowerProvidedPos.Value, barStart.Y);
|
||||
|
||||
var color = Color.LimeGreen;
|
||||
if (resources.GetPowerState() == PowerState.Low)
|
||||
color = Color.Orange;
|
||||
if (resources.GetPowerState() == PowerState.Critical)
|
||||
color = Color.Red;
|
||||
|
||||
var colorDark = Graphics.Util.Lerp(0.25f, color, Color.Black);
|
||||
for (int i = 0; i < powerSize.Height; i++)
|
||||
{
|
||||
color = (i - 1 < powerSize.Height / 2) ? color : colorDark;
|
||||
float2 leftOffset = new float2(0, i);
|
||||
float2 rightOffset = new float2(0, i);
|
||||
// Indent corners
|
||||
if ((i == 0 || i == powerSize.Height - 1) && powerLevel.X - barStart.X > 1)
|
||||
{
|
||||
leftOffset.X += 1;
|
||||
rightOffset.X -= 1;
|
||||
}
|
||||
lineRenderer.DrawLine(Game.viewport.Location + barStart + leftOffset, Game.viewport.Location + powerLevel + rightOffset, color, color);
|
||||
}
|
||||
lineRenderer.Flush();
|
||||
|
||||
// Power usage indicator
|
||||
var indicator = ChromeProvider.GetImage(renderer, powerCollection, "power-indicator");
|
||||
var powerDrainedTemp = barStart.X + (barEnd.X - barStart.X) * (resources.PowerDrained / powerScaleBy);
|
||||
lastPowerDrainedPos = float2.Lerp(lastPowerDrainedPos.GetValueOrDefault(powerDrainedTemp), powerDrainedTemp, .3f);
|
||||
float2 powerDrainLevel = new float2(lastPowerDrainedPos.Value - indicator.size.X / 2, barStart.Y - 1);
|
||||
|
||||
rgbaRenderer.DrawSprite(indicator, powerDrainLevel, "chrome");
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -29,10 +28,9 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public class RadarBinWidget : Widget
|
||||
{
|
||||
// Radar
|
||||
static float2 radarOpenOrigin = new float2(Game.viewport.Width - 215, 29);
|
||||
static float2 radarClosedOrigin = new float2(Game.viewport.Width - 215, -166);
|
||||
static float2 radarOrigin = radarClosedOrigin;
|
||||
public static float2 radarOrigin = radarClosedOrigin;
|
||||
float radarMinimapHeight;
|
||||
const int radarSlideAnimationLength = 15;
|
||||
const int radarActivateAnimationLength = 5;
|
||||
@@ -40,12 +38,6 @@ namespace OpenRA.Widgets
|
||||
bool radarAnimating = false;
|
||||
bool hasRadar = false;
|
||||
|
||||
// Power bar
|
||||
static float2 powerOrigin = new float2(42, 205); // Relative to radarOrigin
|
||||
static Size powerSize = new Size(138, 5);
|
||||
float? lastPowerProvidedPos;
|
||||
float? lastPowerDrainedPos;
|
||||
|
||||
string radarCollection;
|
||||
|
||||
public override bool HandleInput(MouseInput mi)
|
||||
@@ -86,10 +78,36 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { throw new NotImplementedException("Why are you Cloning RadarBin?"); }
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
DrawRadar(world);
|
||||
DrawPower(world);
|
||||
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
||||
|
||||
var hasNewRadar = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<ProvidesRadar>()
|
||||
.Any(a => a.Trait.IsActive);
|
||||
|
||||
if (hasNewRadar != hasRadar)
|
||||
radarAnimating = true;
|
||||
|
||||
hasRadar = hasNewRadar;
|
||||
|
||||
var renderer = Game.chrome.renderer;
|
||||
var rgbaRenderer = renderer.RgbaSpriteRenderer;
|
||||
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "left"), radarOrigin, "chrome");
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "right"), radarOrigin + new float2(201, 0), "chrome");
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "bottom"), radarOrigin + new float2(0, 192), "chrome");
|
||||
|
||||
if (radarAnimating)
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "bg"), radarOrigin + new float2(9, 0), "chrome");
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
if (radarAnimationFrame >= radarSlideAnimationLength)
|
||||
{
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2, 192, radarMinimapHeight);
|
||||
world.Minimap.Draw(mapRect);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Tick(World world)
|
||||
@@ -128,95 +146,5 @@ namespace OpenRA.Widgets
|
||||
if (radarAnimationFrame == (hasRadar ? radarSlideAnimationLength+radarActivateAnimationLength : 0))
|
||||
radarAnimating = false;
|
||||
}
|
||||
|
||||
void DrawRadar(World world)
|
||||
{
|
||||
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
||||
|
||||
var hasNewRadar = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<ProvidesRadar>()
|
||||
.Any(a => a.Trait.IsActive);
|
||||
|
||||
if (hasNewRadar != hasRadar)
|
||||
radarAnimating = true;
|
||||
|
||||
hasRadar = hasNewRadar;
|
||||
|
||||
var renderer = Game.chrome.renderer;
|
||||
var rgbaRenderer = renderer.RgbaSpriteRenderer;
|
||||
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "left"), radarOrigin, "chrome");
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "right"), radarOrigin + new float2(201, 0), "chrome");
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "bottom"), radarOrigin + new float2(0, 192), "chrome");
|
||||
|
||||
if (radarAnimating)
|
||||
rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, radarCollection, "bg"), radarOrigin + new float2(9, 0), "chrome");
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
if (radarAnimationFrame >= radarSlideAnimationLength)
|
||||
{
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2, 192, radarMinimapHeight);
|
||||
world.Minimap.Draw(mapRect);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawPower(World world)
|
||||
{
|
||||
var resources = world.LocalPlayer.PlayerActor.traits.Get<PlayerResources>();
|
||||
|
||||
// Nothing to draw
|
||||
if (resources.PowerProvided == 0
|
||||
&& resources.PowerDrained == 0)
|
||||
return;
|
||||
|
||||
var renderer = Game.chrome.renderer;
|
||||
var lineRenderer = Game.chrome.lineRenderer;
|
||||
var rgbaRenderer = renderer.RgbaSpriteRenderer;
|
||||
|
||||
// Draw bar horizontally
|
||||
var barStart = powerOrigin + radarOrigin;
|
||||
var barEnd = barStart + new float2(powerSize.Width, 0);
|
||||
|
||||
float powerScaleBy = 100;
|
||||
var maxPower = Math.Max(resources.PowerProvided, resources.PowerDrained);
|
||||
while (maxPower >= powerScaleBy) powerScaleBy *= 2;
|
||||
|
||||
// Current power supply
|
||||
var powerLevelTemp = barStart.X + (barEnd.X - barStart.X) * (resources.PowerProvided / powerScaleBy);
|
||||
lastPowerProvidedPos = float2.Lerp(lastPowerProvidedPos.GetValueOrDefault(powerLevelTemp), powerLevelTemp, .3f);
|
||||
float2 powerLevel = new float2(lastPowerProvidedPos.Value, barStart.Y);
|
||||
|
||||
var color = Color.LimeGreen;
|
||||
if (resources.GetPowerState() == PowerState.Low)
|
||||
color = Color.Orange;
|
||||
if (resources.GetPowerState() == PowerState.Critical)
|
||||
color = Color.Red;
|
||||
|
||||
var colorDark = Graphics.Util.Lerp(0.25f, color, Color.Black);
|
||||
for (int i = 0; i < powerSize.Height; i++)
|
||||
{
|
||||
color = (i - 1 < powerSize.Height / 2) ? color : colorDark;
|
||||
float2 leftOffset = new float2(0, i);
|
||||
float2 rightOffset = new float2(0, i);
|
||||
// Indent corners
|
||||
if ((i == 0 || i == powerSize.Height - 1) && powerLevel.X - barStart.X > 1)
|
||||
{
|
||||
leftOffset.X += 1;
|
||||
rightOffset.X -= 1;
|
||||
}
|
||||
lineRenderer.DrawLine(Game.viewport.Location + barStart + leftOffset, Game.viewport.Location + powerLevel + rightOffset, color, color);
|
||||
}
|
||||
lineRenderer.Flush();
|
||||
|
||||
// Power usage indicator
|
||||
var indicator = ChromeProvider.GetImage(renderer, radarCollection, "power-indicator");
|
||||
var powerDrainedTemp = barStart.X + (barEnd.X - barStart.X) * (resources.PowerDrained / powerScaleBy);
|
||||
lastPowerDrainedPos = float2.Lerp(lastPowerDrainedPos.GetValueOrDefault(powerDrainedTemp), powerDrainedTemp, .3f);
|
||||
float2 powerDrainLevel = new float2(lastPowerDrainedPos.Value - indicator.size.X / 2, barStart.Y - 1);
|
||||
|
||||
rgbaRenderer.DrawSprite(indicator, powerDrainLevel, "chrome");
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,13 +80,8 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!Visible)
|
||||
{
|
||||
base.Draw(world);
|
||||
return;
|
||||
}
|
||||
buttons.Clear();
|
||||
|
||||
var powers = world.LocalPlayer.PlayerActor.traits.WithInterface<SupportPower>();
|
||||
@@ -170,7 +165,6 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
}
|
||||
Game.chrome.renderer.WorldSpriteRenderer.Flush();
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
Action<MouseInput> HandleSupportPower(SupportPower sp)
|
||||
|
||||
@@ -166,12 +166,17 @@ namespace OpenRA.Widgets
|
||||
|
||||
throw new InvalidOperationException("Impossible");
|
||||
}
|
||||
|
||||
public abstract void DrawInner( World world );
|
||||
|
||||
public virtual void Draw(World world)
|
||||
public void Draw(World world)
|
||||
{
|
||||
if (IsVisible())
|
||||
{
|
||||
DrawInner( world );
|
||||
foreach (var child in Children)
|
||||
child.Draw(world);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Tick(World world)
|
||||
@@ -229,6 +234,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
public ContainerWidget(Widget other) : base(other) { }
|
||||
|
||||
public override void DrawInner( World world ) { }
|
||||
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
}
|
||||
public interface IWidgetDelegate { }
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { return new WorldTooltipWidget(this); }
|
||||
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (Game.chrome.ticksSinceLastMove < worldTooltipDelay || world == null || world.LocalPlayer == null)
|
||||
return;
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Widgets
|
||||
? actor.Info.Traits.Get<ValuedInfo>().Description
|
||||
: actor.Info.Name;
|
||||
var text2 = (actor.Owner == world.LocalPlayer)
|
||||
? "" : (actor.Owner == world.NeutralPlayer ? "{0}" : "{0} ({1})").F(actor.Owner.PlayerName, world.LocalPlayer.Stances[actor.Owner]);
|
||||
? "" : (actor.Owner.NonCombatant ? "{0}" : "{0} ({1})").F(actor.Owner.PlayerName, world.LocalPlayer.Stances[actor.Owner]);
|
||||
|
||||
var renderer = Game.chrome.renderer;
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ namespace OpenRA
|
||||
get { return players.ContainsKey(localPlayerIndex) ? players[localPlayerIndex] : null; }
|
||||
}
|
||||
|
||||
public Player NeutralPlayer { get; private set; }
|
||||
|
||||
public void SetLocalPlayer(int index)
|
||||
{
|
||||
localPlayerIndex = index;
|
||||
@@ -91,7 +89,27 @@ namespace OpenRA
|
||||
Timer.Time("renderer: {0}");
|
||||
|
||||
WorldActor = CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||
AddPlayer(NeutralPlayer = new Player(this, null)); // add the neutral player
|
||||
|
||||
// Add Map Players
|
||||
int mapPlayerIndex = -1;
|
||||
foreach (var kv in Map.Players)
|
||||
{
|
||||
var player = new Player(this, kv.Value, mapPlayerIndex--);
|
||||
AddPlayer(player);
|
||||
|
||||
if (kv.Value.OwnsWorld)
|
||||
WorldActor.Owner = player;
|
||||
}
|
||||
|
||||
// Add real players
|
||||
SetLocalPlayer(Game.orderManager.Connection.LocalClientId);
|
||||
|
||||
foreach (var c in Game.LobbyInfo.Clients)
|
||||
AddPlayer(new Player(this, c));
|
||||
|
||||
foreach (var p in players.Values)
|
||||
foreach (var q in players.Values)
|
||||
p.Stances[q] = Game.ChooseInitialStance(p, q);
|
||||
|
||||
Timer.Time( "worldActor: {0}" );
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -93,16 +94,19 @@ namespace OpenRA
|
||||
|
||||
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
|
||||
{
|
||||
var min = a - new float2(r, r);
|
||||
var max = a + new float2(r, r);
|
||||
using (new PerfSample("FindUnitsInCircle"))
|
||||
{
|
||||
var min = a - new float2(r, r);
|
||||
var max = a + new float2(r, r);
|
||||
|
||||
var actors = world.FindUnits( min, max );
|
||||
var actors = world.FindUnits(min, max);
|
||||
|
||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||
|
||||
var inBox = actors.Where(x => x.GetBounds(false).IntersectsWith(rect));
|
||||
var inBox = actors.Where(x => x.GetBounds(false).IntersectsWith(rect));
|
||||
|
||||
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
||||
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> FindTilesInCircle(this World world, int2 a, int r)
|
||||
@@ -144,7 +148,7 @@ namespace OpenRA
|
||||
world.IsCellBuildable(t, building.WaterBound, toIgnore));
|
||||
}
|
||||
|
||||
public static bool IsVisible(this Actor a)
|
||||
public static bool IsVisible(this Actor a) /* must never be relied on in synced code! */
|
||||
{
|
||||
if (a.World.LocalPlayer != null && a.World.LocalPlayer.Shroud.Disabled)
|
||||
return true;
|
||||
@@ -157,6 +161,10 @@ namespace OpenRA
|
||||
if (huf != null && !huf.IsVisible(a))
|
||||
return false;
|
||||
|
||||
var cloak = a.traits.GetOrDefault<Cloak>();
|
||||
if (cloak != null && cloak.Cloaked && a.Owner != a.World.LocalPlayer)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -189,20 +197,7 @@ namespace OpenRA
|
||||
|
||||
static int2 ClampToWorld( this World world, int2 xy )
|
||||
{
|
||||
var mapStart = world.Map.TopLeft;
|
||||
// TODO: Revist this and fix properly
|
||||
var mapEnd = world.Map.BottomRight;
|
||||
if( xy.X < mapStart.X )
|
||||
xy.X = mapStart.X;
|
||||
if( xy.X > mapEnd.X )
|
||||
xy.X = mapEnd.X;
|
||||
|
||||
if( xy.Y < mapStart.Y )
|
||||
xy.Y = mapStart.Y;
|
||||
if( xy.Y > mapEnd.Y )
|
||||
xy.Y = mapEnd.Y;
|
||||
|
||||
return xy;
|
||||
return int2.Min(world.Map.BottomRight, int2.Max(world.Map.TopLeft, xy));
|
||||
}
|
||||
|
||||
public static int2 ChooseRandomEdgeCell(this World w)
|
||||
@@ -244,9 +239,7 @@ namespace OpenRA
|
||||
|
||||
public static List<PlayerColorPaletteInfo> PlayerColors(this World world)
|
||||
{
|
||||
return world.WorldActor.Info.Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||
.Where(p => p.Playable)
|
||||
.ToList();
|
||||
return world.WorldActor.Info.Traits.WithInterface<PlayerColorPaletteInfo>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using Tao.Cg;
|
||||
using Tao.OpenGl;
|
||||
using Tao.Sdl;
|
||||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using Tao.Cg;
|
||||
using Tao.OpenGl;
|
||||
using Tao.Sdl;
|
||||
|
||||
[assembly: Renderer( typeof( OpenRA.GlRenderer.GraphicsDevice ))]
|
||||
|
||||
namespace OpenRA.GlRenderer
|
||||
{
|
||||
public class GraphicsDevice : IGraphicsDevice
|
||||
{
|
||||
public class GraphicsDevice : IGraphicsDevice
|
||||
{
|
||||
Size windowSize;
|
||||
internal IntPtr cgContext;
|
||||
internal int vertexProfile, fragmentProfile;
|
||||
internal IntPtr cgContext;
|
||||
internal int vertexProfile, fragmentProfile;
|
||||
|
||||
IntPtr surf;
|
||||
|
||||
public Size WindowSize { get { return windowSize; } }
|
||||
|
||||
internal static void CheckGlError()
|
||||
{
|
||||
internal static void CheckGlError()
|
||||
{
|
||||
var n = Gl.glGetError();
|
||||
if (n != Gl.GL_NO_ERROR)
|
||||
throw new InvalidOperationException("GL Error");
|
||||
}
|
||||
throw new InvalidOperationException("GL Error");
|
||||
}
|
||||
|
||||
public GraphicsDevice( int width, int height, bool windowed, bool vsync )
|
||||
public GraphicsDevice(int width, int height, bool windowed, bool vsync)
|
||||
{
|
||||
Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
|
||||
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
|
||||
@@ -73,65 +73,65 @@ namespace OpenRA.GlRenderer
|
||||
|
||||
Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
|
||||
Sdl.SDL_ShowCursor(0);
|
||||
Sdl.SDL_EnableUNICODE( 1 );
|
||||
Sdl.SDL_EnableUNICODE(1);
|
||||
Sdl.SDL_EnableKeyRepeat(Sdl.SDL_DEFAULT_REPEAT_INTERVAL, Sdl.SDL_DEFAULT_REPEAT_DELAY);
|
||||
|
||||
CheckGlError();
|
||||
|
||||
windowSize = new Size( width, height );
|
||||
windowSize = new Size(width, height);
|
||||
|
||||
cgContext = Cg.cgCreateContext();
|
||||
|
||||
Cg.cgSetErrorCallback( CgErrorCallback );
|
||||
Cg.cgSetErrorCallback(CgErrorCallback);
|
||||
|
||||
CgGl.cgGLRegisterStates( cgContext );
|
||||
CgGl.cgGLSetManageTextureParameters( cgContext, true );
|
||||
vertexProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_VERTEX );
|
||||
fragmentProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_FRAGMENT );
|
||||
CgGl.cgGLRegisterStates(cgContext);
|
||||
CgGl.cgGLSetManageTextureParameters(cgContext, true);
|
||||
vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
|
||||
fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
|
||||
|
||||
Console.WriteLine("VP Profile: " + vertexProfile);
|
||||
Console.WriteLine("FP Profile: " + fragmentProfile);
|
||||
|
||||
Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
|
||||
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
|
||||
CheckGlError();
|
||||
Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
|
||||
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
static Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () =>
|
||||
{
|
||||
var err = Cg.cgGetError();
|
||||
var str = Cg.cgGetErrorString( err );
|
||||
var str = Cg.cgGetErrorString(err);
|
||||
throw new InvalidOperationException(
|
||||
string.Format( "CG Error: {0}: {1}", err, str ) );
|
||||
string.Format("CG Error: {0}: {1}", err, str));
|
||||
};
|
||||
|
||||
public void EnableScissor(int left, int top, int width, int height)
|
||||
{
|
||||
if( width < 0 ) width = 0;
|
||||
if( height < 0 ) height = 0;
|
||||
Gl.glScissor( left, windowSize.Height - ( top + height ), width, height );
|
||||
CheckGlError();
|
||||
Gl.glEnable(Gl.GL_SCISSOR_TEST);
|
||||
CheckGlError();
|
||||
}
|
||||
public void EnableScissor(int left, int top, int width, int height)
|
||||
{
|
||||
if (width < 0) width = 0;
|
||||
if (height < 0) height = 0;
|
||||
Gl.glScissor(left, windowSize.Height - (top + height), width, height);
|
||||
CheckGlError();
|
||||
Gl.glEnable(Gl.GL_SCISSOR_TEST);
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
public void DisableScissor()
|
||||
{
|
||||
Gl.glDisable(Gl.GL_SCISSOR_TEST);
|
||||
CheckGlError();
|
||||
}
|
||||
public void DisableScissor()
|
||||
{
|
||||
Gl.glDisable(Gl.GL_SCISSOR_TEST);
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
public void Begin() { }
|
||||
public void End() { }
|
||||
public void Begin() { }
|
||||
public void End() { }
|
||||
|
||||
public void Clear(Color c)
|
||||
{
|
||||
Gl.glClearColor(0, 0, 0, 0);
|
||||
CheckGlError();
|
||||
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
|
||||
CheckGlError();
|
||||
}
|
||||
public void Clear(Color c)
|
||||
{
|
||||
Gl.glClearColor(0, 0, 0, 0);
|
||||
CheckGlError();
|
||||
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
MouseButtons lastButtonBits = (MouseButtons)0;
|
||||
|
||||
@@ -150,8 +150,8 @@ namespace OpenRA.GlRenderer
|
||||
| ((raw & Sdl.KMOD_SHIFT) != 0 ? Modifiers.Shift : 0);
|
||||
}
|
||||
|
||||
public void Present()
|
||||
{
|
||||
public void Present()
|
||||
{
|
||||
Sdl.SDL_GL_SwapBuffers();
|
||||
|
||||
var mods = MakeModifiers(Sdl.SDL_GetModState());
|
||||
@@ -195,279 +195,294 @@ namespace OpenRA.GlRenderer
|
||||
|
||||
case Sdl.SDL_KEYDOWN:
|
||||
{
|
||||
if( e.key.keysym.unicode != 0 )
|
||||
Game.HandleKeyPress( new KeyPressEventArgs( (char)e.key.keysym.unicode ), mods );
|
||||
|
||||
else if( mods != 0 )
|
||||
switch (e.key.keysym.sym)
|
||||
{
|
||||
var keyName = Sdl.SDL_GetKeyName( e.key.keysym.sym );
|
||||
if( keyName.Length == 1 )
|
||||
Game.HandleKeyPress( new KeyPressEventArgs( keyName[ 0 ] ), mods );
|
||||
else if( keyName == "f4" && ( ( mods & Modifiers.Alt ) != 0 ) )
|
||||
case Sdl.SDLK_UP: Game.HandleArrowKeyScroll("up", true); break;
|
||||
case Sdl.SDLK_LEFT: Game.HandleArrowKeyScroll("left", true); break;
|
||||
case Sdl.SDLK_DOWN: Game.HandleArrowKeyScroll("down", true); break;
|
||||
case Sdl.SDLK_RIGHT: Game.HandleArrowKeyScroll("right", true); break;
|
||||
}
|
||||
|
||||
if (e.key.keysym.unicode != 0)
|
||||
Game.HandleKeyPress(new KeyPressEventArgs((char)e.key.keysym.unicode), mods);
|
||||
|
||||
else if (mods != 0)
|
||||
{
|
||||
var keyName = Sdl.SDL_GetKeyName(e.key.keysym.sym);
|
||||
if (keyName.Length == 1)
|
||||
Game.HandleKeyPress(new KeyPressEventArgs(keyName[0]), mods);
|
||||
else if (keyName == "f4" && ((mods & Modifiers.Alt) != 0))
|
||||
OpenRA.Game.Exit();
|
||||
}
|
||||
} break;
|
||||
|
||||
case Sdl.SDL_KEYUP:
|
||||
{
|
||||
switch (e.key.keysym.sym)
|
||||
{
|
||||
case Sdl.SDLK_UP: Game.HandleArrowKeyScroll("up", false); break;
|
||||
case Sdl.SDLK_LEFT: Game.HandleArrowKeyScroll("left", false); break;
|
||||
case Sdl.SDLK_DOWN: Game.HandleArrowKeyScroll("down", false); break;
|
||||
case Sdl.SDLK_RIGHT: Game.HandleArrowKeyScroll("right", false); break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
CheckGlError();
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawIndexedPrimitives( PrimitiveType pt, Range<int> vertices, Range<int> indices )
|
||||
public void DrawIndexedPrimitives(PrimitiveType pt, Range<int> vertices, Range<int> indices)
|
||||
{
|
||||
Gl.glDrawElements( ModeFromPrimitiveType( pt ), indices.End - indices.Start, Gl.GL_UNSIGNED_SHORT, new IntPtr( indices.Start * 2 ) );
|
||||
Gl.glDrawElements(ModeFromPrimitiveType(pt), indices.End - indices.Start, Gl.GL_UNSIGNED_SHORT, new IntPtr(indices.Start * 2));
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
public void DrawIndexedPrimitives( PrimitiveType pt, int numVerts, int numPrimitives )
|
||||
public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives)
|
||||
{
|
||||
Gl.glDrawElements( ModeFromPrimitiveType( pt ), numPrimitives * IndicesPerPrimitive( pt ), Gl.GL_UNSIGNED_SHORT, IntPtr.Zero );
|
||||
Gl.glDrawElements(ModeFromPrimitiveType(pt), numPrimitives * IndicesPerPrimitive(pt), Gl.GL_UNSIGNED_SHORT, IntPtr.Zero);
|
||||
CheckGlError();
|
||||
}
|
||||
|
||||
static int ModeFromPrimitiveType( PrimitiveType pt )
|
||||
static int ModeFromPrimitiveType(PrimitiveType pt)
|
||||
{
|
||||
switch( pt )
|
||||
switch (pt)
|
||||
{
|
||||
case PrimitiveType.PointList: return Gl.GL_POINTS;
|
||||
case PrimitiveType.LineList: return Gl.GL_LINES;
|
||||
case PrimitiveType.TriangleList: return Gl.GL_TRIANGLES;
|
||||
case PrimitiveType.PointList: return Gl.GL_POINTS;
|
||||
case PrimitiveType.LineList: return Gl.GL_LINES;
|
||||
case PrimitiveType.TriangleList: return Gl.GL_TRIANGLES;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
static int IndicesPerPrimitive( PrimitiveType pt )
|
||||
static int IndicesPerPrimitive(PrimitiveType pt)
|
||||
{
|
||||
switch( pt )
|
||||
switch (pt)
|
||||
{
|
||||
case PrimitiveType.PointList: return 1;
|
||||
case PrimitiveType.LineList: return 2;
|
||||
case PrimitiveType.TriangleList: return 3;
|
||||
case PrimitiveType.PointList: return 1;
|
||||
case PrimitiveType.LineList: return 2;
|
||||
case PrimitiveType.TriangleList: return 3;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region IGraphicsDevice Members
|
||||
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer( int size )
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer(int size)
|
||||
{
|
||||
return new VertexBuffer<Vertex>( this, size );
|
||||
return new VertexBuffer<Vertex>(this, size);
|
||||
}
|
||||
|
||||
public IIndexBuffer CreateIndexBuffer( int size )
|
||||
public IIndexBuffer CreateIndexBuffer(int size)
|
||||
{
|
||||
return new IndexBuffer( this, size );
|
||||
return new IndexBuffer(this, size);
|
||||
}
|
||||
|
||||
public ITexture CreateTexture( Bitmap bitmap )
|
||||
public ITexture CreateTexture(Bitmap bitmap)
|
||||
{
|
||||
return new Texture( this, bitmap );
|
||||
return new Texture(this, bitmap);
|
||||
}
|
||||
|
||||
public IShader CreateShader( Stream stream )
|
||||
public IShader CreateShader(Stream stream)
|
||||
{
|
||||
return new Shader( this, stream );
|
||||
return new Shader(this, stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class VertexBuffer<T> : IVertexBuffer<T>, IDisposable
|
||||
public class VertexBuffer<T> : IVertexBuffer<T>, IDisposable
|
||||
where T : struct
|
||||
{
|
||||
int buffer;
|
||||
{
|
||||
int buffer;
|
||||
|
||||
public VertexBuffer(GraphicsDevice dev, int size)
|
||||
{
|
||||
Gl.glGenBuffers(1, out buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
public VertexBuffer(GraphicsDevice dev, int size)
|
||||
{
|
||||
Gl.glGenBuffers(1, out buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
public void SetData(T[] data)
|
||||
{
|
||||
Bind();
|
||||
Gl.glBufferData(Gl.GL_ARRAY_BUFFER,
|
||||
new IntPtr(Marshal.SizeOf(typeof(T))*data.Length), data, Gl.GL_DYNAMIC_DRAW);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
public void SetData(T[] data)
|
||||
{
|
||||
Bind();
|
||||
Gl.glBufferData(Gl.GL_ARRAY_BUFFER,
|
||||
new IntPtr(Marshal.SizeOf(typeof(T)) * data.Length), data, Gl.GL_DYNAMIC_DRAW);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glVertexPointer(3, Gl.GL_FLOAT, Marshal.SizeOf(typeof(T)), IntPtr.Zero);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexCoordPointer(4, Gl.GL_FLOAT, Marshal.SizeOf(typeof(T)), new IntPtr(12));
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
GC.SuppressFinalize(this);
|
||||
Gl.glDeleteBuffers(1, ref buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
disposed = true;
|
||||
}
|
||||
public void Bind()
|
||||
{
|
||||
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glVertexPointer(3, Gl.GL_FLOAT, Marshal.SizeOf(typeof(T)), IntPtr.Zero);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexCoordPointer(4, Gl.GL_FLOAT, Marshal.SizeOf(typeof(T)), new IntPtr(12));
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
//~VertexBuffer() { Dispose(); }
|
||||
}
|
||||
bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
GC.SuppressFinalize(this);
|
||||
Gl.glDeleteBuffers(1, ref buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public class IndexBuffer : IIndexBuffer, IDisposable
|
||||
{
|
||||
int buffer;
|
||||
//~VertexBuffer() { Dispose(); }
|
||||
}
|
||||
|
||||
public IndexBuffer(GraphicsDevice dev, int size)
|
||||
{
|
||||
Gl.glGenBuffers(1, out buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
public class IndexBuffer : IIndexBuffer, IDisposable
|
||||
{
|
||||
int buffer;
|
||||
|
||||
public void SetData(ushort[] data)
|
||||
{
|
||||
Bind();
|
||||
Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER,
|
||||
new IntPtr(2 * data.Length), data, Gl.GL_DYNAMIC_DRAW);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
public IndexBuffer(GraphicsDevice dev, int size)
|
||||
{
|
||||
Gl.glGenBuffers(1, out buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
Gl.glBindBuffer(Gl.GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
public void SetData(ushort[] data)
|
||||
{
|
||||
Bind();
|
||||
Gl.glBufferData(Gl.GL_ELEMENT_ARRAY_BUFFER,
|
||||
new IntPtr(2 * data.Length), data, Gl.GL_DYNAMIC_DRAW);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
GC.SuppressFinalize(this);
|
||||
Gl.glDeleteBuffers(1, ref buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
disposed = true;
|
||||
}
|
||||
public void Bind()
|
||||
{
|
||||
Gl.glBindBuffer(Gl.GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
//~IndexBuffer() { Dispose(); }
|
||||
}
|
||||
bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
GC.SuppressFinalize(this);
|
||||
Gl.glDeleteBuffers(1, ref buffer);
|
||||
GraphicsDevice.CheckGlError();
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public class Shader : IShader
|
||||
{
|
||||
IntPtr effect;
|
||||
IntPtr technique;
|
||||
GraphicsDevice dev;
|
||||
//~IndexBuffer() { Dispose(); }
|
||||
}
|
||||
|
||||
public Shader(GraphicsDevice dev, Stream s)
|
||||
{
|
||||
this.dev = dev;
|
||||
public class Shader : IShader
|
||||
{
|
||||
IntPtr effect;
|
||||
IntPtr technique;
|
||||
GraphicsDevice dev;
|
||||
|
||||
public Shader(GraphicsDevice dev, Stream s)
|
||||
{
|
||||
this.dev = dev;
|
||||
string code;
|
||||
using (var file = new StreamReader(s))
|
||||
code = file.ReadToEnd();
|
||||
effect = Cg.cgCreateEffect(dev.cgContext, code, null);
|
||||
effect = Cg.cgCreateEffect(dev.cgContext, code, null);
|
||||
|
||||
if (effect == IntPtr.Zero)
|
||||
{
|
||||
var err = Cg.cgGetErrorString(Cg.cgGetError());
|
||||
var results = Cg.cgGetLastListing(dev.cgContext);
|
||||
throw new InvalidOperationException(
|
||||
string.Format("Cg compile failed ({0}):\n{1}", err, results));
|
||||
}
|
||||
|
||||
technique = Cg.cgGetFirstTechnique( effect );
|
||||
if( technique == IntPtr.Zero )
|
||||
throw new InvalidOperationException("No techniques");
|
||||
while( Cg.cgValidateTechnique( technique ) == 0 )
|
||||
if (effect == IntPtr.Zero)
|
||||
{
|
||||
technique = Cg.cgGetNextTechnique( technique );
|
||||
if( technique == IntPtr.Zero )
|
||||
throw new InvalidOperationException("No valid techniques");
|
||||
var err = Cg.cgGetErrorString(Cg.cgGetError());
|
||||
var results = Cg.cgGetLastListing(dev.cgContext);
|
||||
throw new InvalidOperationException(
|
||||
string.Format("Cg compile failed ({0}):\n{1}", err, results));
|
||||
}
|
||||
|
||||
technique = Cg.cgGetFirstTechnique(effect);
|
||||
if (technique == IntPtr.Zero)
|
||||
throw new InvalidOperationException("No techniques");
|
||||
while (Cg.cgValidateTechnique(technique) == 0)
|
||||
{
|
||||
technique = Cg.cgGetNextTechnique(technique);
|
||||
if (technique == IntPtr.Zero)
|
||||
throw new InvalidOperationException("No valid techniques");
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(Action a)
|
||||
{
|
||||
CgGl.cgGLEnableProfile(dev.vertexProfile);
|
||||
CgGl.cgGLEnableProfile(dev.fragmentProfile);
|
||||
public void Render(Action a)
|
||||
{
|
||||
CgGl.cgGLEnableProfile(dev.vertexProfile);
|
||||
CgGl.cgGLEnableProfile(dev.fragmentProfile);
|
||||
|
||||
var pass = Cg.cgGetFirstPass(technique);
|
||||
while (pass != IntPtr.Zero)
|
||||
{
|
||||
Cg.cgSetPassState(pass);
|
||||
a();
|
||||
Cg.cgResetPassState(pass);
|
||||
pass = Cg.cgGetNextPass(pass);
|
||||
}
|
||||
|
||||
CgGl.cgGLDisableProfile(dev.fragmentProfile);
|
||||
CgGl.cgGLDisableProfile(dev.vertexProfile);
|
||||
}
|
||||
|
||||
public void SetValue(string name, ITexture t)
|
||||
{
|
||||
var texture = (Texture)t;
|
||||
var param = Cg.cgGetNamedEffectParameter( effect, name );
|
||||
if( param != IntPtr.Zero && texture != null )
|
||||
CgGl.cgGLSetupSampler( param, texture.texture );
|
||||
}
|
||||
|
||||
public void SetValue(string name, float x, float y)
|
||||
{
|
||||
var param = Cg.cgGetNamedEffectParameter(effect, name);
|
||||
if( param != IntPtr.Zero )
|
||||
CgGl.cgGLSetParameter2f(param, x, y);
|
||||
}
|
||||
|
||||
public void Commit() { }
|
||||
}
|
||||
|
||||
public class Texture : ITexture
|
||||
{
|
||||
internal int texture;
|
||||
|
||||
public Texture(GraphicsDevice dev, Bitmap bitmap)
|
||||
{
|
||||
Gl.glGenTextures(1, out texture);
|
||||
GraphicsDevice.CheckGlError();
|
||||
SetData(bitmap);
|
||||
}
|
||||
|
||||
public void SetData(Bitmap bitmap)
|
||||
{
|
||||
if( !IsPowerOf2( bitmap.Width ) || !IsPowerOf2( bitmap.Height ) )
|
||||
var pass = Cg.cgGetFirstPass(technique);
|
||||
while (pass != IntPtr.Zero)
|
||||
{
|
||||
//throw new InvalidOperationException( "non-power-of-2-texture" );
|
||||
bitmap = new Bitmap( bitmap, new Size( NextPowerOf2( bitmap.Width ), NextPowerOf2( bitmap.Height ) ) );
|
||||
Cg.cgSetPassState(pass);
|
||||
a();
|
||||
Cg.cgResetPassState(pass);
|
||||
pass = Cg.cgGetNextPass(pass);
|
||||
}
|
||||
|
||||
Gl.glBindTexture( Gl.GL_TEXTURE_2D, texture );
|
||||
CgGl.cgGLDisableProfile(dev.fragmentProfile);
|
||||
CgGl.cgGLDisableProfile(dev.vertexProfile);
|
||||
}
|
||||
|
||||
public void SetValue(string name, ITexture t)
|
||||
{
|
||||
var texture = (Texture)t;
|
||||
var param = Cg.cgGetNamedEffectParameter(effect, name);
|
||||
if (param != IntPtr.Zero && texture != null)
|
||||
CgGl.cgGLSetupSampler(param, texture.texture);
|
||||
}
|
||||
|
||||
public void SetValue(string name, float x, float y)
|
||||
{
|
||||
var param = Cg.cgGetNamedEffectParameter(effect, name);
|
||||
if (param != IntPtr.Zero)
|
||||
CgGl.cgGLSetParameter2f(param, x, y);
|
||||
}
|
||||
|
||||
public void Commit() { }
|
||||
}
|
||||
|
||||
public class Texture : ITexture
|
||||
{
|
||||
internal int texture;
|
||||
|
||||
public Texture(GraphicsDevice dev, Bitmap bitmap)
|
||||
{
|
||||
Gl.glGenTextures(1, out texture);
|
||||
GraphicsDevice.CheckGlError();
|
||||
SetData(bitmap);
|
||||
}
|
||||
|
||||
public void SetData(Bitmap bitmap)
|
||||
{
|
||||
if (!IsPowerOf2(bitmap.Width) || !IsPowerOf2(bitmap.Height))
|
||||
{
|
||||
//throw new InvalidOperationException( "non-power-of-2-texture" );
|
||||
bitmap = new Bitmap(bitmap, new Size(NextPowerOf2(bitmap.Width), NextPowerOf2(bitmap.Height)));
|
||||
}
|
||||
|
||||
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
|
||||
GraphicsDevice.CheckGlError();
|
||||
|
||||
var bits = bitmap.LockBits(
|
||||
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.ReadOnly,
|
||||
PixelFormat.Format32bppArgb);
|
||||
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.ReadOnly,
|
||||
PixelFormat.Format32bppArgb);
|
||||
|
||||
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_BASE_LEVEL, 0);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAX_LEVEL, 0);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, bits.Width, bits.Height,
|
||||
0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bits.Scan0); // todo: weird strides
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_BASE_LEVEL, 0);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAX_LEVEL, 0);
|
||||
GraphicsDevice.CheckGlError();
|
||||
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, bits.Width, bits.Height,
|
||||
0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bits.Scan0); // todo: weird strides
|
||||
GraphicsDevice.CheckGlError();
|
||||
|
||||
bitmap.UnlockBits(bits);
|
||||
}
|
||||
|
||||
bool IsPowerOf2( int v )
|
||||
{
|
||||
return ( v & ( v - 1 ) ) == 0;
|
||||
bitmap.UnlockBits(bits);
|
||||
}
|
||||
|
||||
int NextPowerOf2( int v )
|
||||
bool IsPowerOf2(int v)
|
||||
{
|
||||
return (v & (v - 1)) == 0;
|
||||
}
|
||||
|
||||
int NextPowerOf2(int v)
|
||||
{
|
||||
--v;
|
||||
v |= v >> 1;
|
||||
@@ -477,5 +492,5 @@ namespace OpenRA.GlRenderer
|
||||
++v;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -17,7 +17,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -75,6 +75,7 @@
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -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.
|
||||
@@ -59,18 +59,17 @@ namespace OpenRA.Mods.Aftermath
|
||||
{
|
||||
if (order.OrderString == "Deploy")
|
||||
{
|
||||
Game.controller.orderGenerator = new SetChronoTankDestination(self);
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.orderGenerator = new SetChronoTankDestination(self);
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMovement>();
|
||||
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
|
||||
{
|
||||
// Cannot chronoshift into unexplored location
|
||||
if (!self.Owner.Shroud.IsExplored(order.TargetLocation))
|
||||
return;
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
Game.controller.CancelInputMode();
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Teleport(order.TargetLocation));
|
||||
Sound.Play("chrotnk1.aud", self.CenterLocation);
|
||||
@@ -78,7 +77,7 @@ namespace OpenRA.Mods.Aftermath
|
||||
chargeTick = 25 * self.Info.Traits.Get<ChronoshiftDeployInfo>().ChargeTime;
|
||||
|
||||
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
||||
a.Trait.DoChronoshift();
|
||||
a.Trait.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace OpenRA.Mods.Aftermath.Orders
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return new Order("ChronoshiftSelf", self, xy);
|
||||
if (world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
yield return new Order("ChronoshiftSelf", self, xy);
|
||||
}
|
||||
|
||||
public void Tick( World world ) { }
|
||||
|
||||
@@ -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.
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Effects
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
Util.CenterOfCell(Target) - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
||||
Traits.Util.CenterOfCell(Target) - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
||||
"effect");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?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>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{6CA925E5-4A47-46AC-9DE3-FA341F7C94A7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRA.Mods.RA_NG</RootNamespace>
|
||||
<AssemblyName>OpenRA.Mods.RA_NG</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Mods.RA\OpenRA.Mods.RA.csproj">
|
||||
<Project>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</Project>
|
||||
<Name>OpenRA.Mods.RA</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>mkdir "$(SolutionDir)mods/ra-ng/"
|
||||
copy "$(TargetPath)" "$(SolutionDir)mods/ra-ng/"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenRA.Mods.RA-NG")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OpenRA")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2007,2009,2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("3c94e0bf-6350-4703-a770-59cbc260d0a1")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -19,8 +19,9 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class CallFunc : IActivity
|
||||
{
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class EnterTransport : IActivity
|
||||
{
|
||||
@@ -20,8 +20,9 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Fly : IActivity
|
||||
{
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user