First attempt; works, but has regressions in several areas
This commit is contained in:
@@ -41,17 +41,19 @@ namespace OpenRA.FileFormats
|
|||||||
public string Author;
|
public string Author;
|
||||||
public int PlayerCount;
|
public int PlayerCount;
|
||||||
public string Tileset;
|
public string Tileset;
|
||||||
|
|
||||||
|
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
|
||||||
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
||||||
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
||||||
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
||||||
|
|
||||||
// Rules overrides
|
// Rules overrides
|
||||||
public Dictionary<string, MiniYaml> Rules = new Dictionary<string, MiniYaml>();
|
public Dictionary<string, MiniYaml> Rules = new Dictionary<string, MiniYaml>();
|
||||||
public Dictionary<string, MiniYaml> Weapons = 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> Voices = new Dictionary<string, MiniYaml>();
|
||||||
public Dictionary<string, MiniYaml> Music = 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
|
// Binary map data
|
||||||
public byte TileFormat = 1;
|
public byte TileFormat = 1;
|
||||||
public int2 MapSize;
|
public int2 MapSize;
|
||||||
@@ -93,13 +95,20 @@ namespace OpenRA.FileFormats
|
|||||||
string[] loc = wp.Value.Value.Split(',');
|
string[] loc = wp.Value.Value.Split(',');
|
||||||
Waypoints.Add(wp.Key, new int2(int.Parse(loc[0]), int.Parse(loc[1])));
|
Waypoints.Add(wp.Key, new int2(int.Parse(loc[0]), int.Parse(loc[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actors
|
// Players
|
||||||
|
foreach (var kv in yaml["Players"].Nodes)
|
||||||
|
{
|
||||||
|
var player = new PlayerReference(kv.Value);
|
||||||
|
Players.Add(player.Name, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actors
|
||||||
foreach (var kv in yaml["Actors"].Nodes)
|
foreach (var kv in yaml["Actors"].Nodes)
|
||||||
{
|
{
|
||||||
string[] vals = kv.Value.Value.Split(' ');
|
string[] vals = kv.Value.Value.Split(' ');
|
||||||
string[] loc = vals[2].Split(',');
|
string[] loc = vals[2].Split(',');
|
||||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[2]);
|
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[1]);
|
||||||
Actors.Add(kv.Key, a);
|
Actors.Add(kv.Key, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
OpenRA.FileFormats/Map/PlayerReference.cs
Normal file
34
OpenRA.FileFormats/Map/PlayerReference.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#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 PlayerReference(MiniYaml my)
|
||||||
|
{
|
||||||
|
FieldLoader.Load(this, my);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -102,6 +102,7 @@
|
|||||||
<Compile Include="Primitives\int2.cs" />
|
<Compile Include="Primitives\int2.cs" />
|
||||||
<Compile Include="Map\MapStub.cs" />
|
<Compile Include="Map\MapStub.cs" />
|
||||||
<Compile Include="Map\SmudgeReference.cs" />
|
<Compile Include="Map\SmudgeReference.cs" />
|
||||||
|
<Compile Include="Map\PlayerReference.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -420,6 +420,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
static Stance ChooseInitialStance(Player p, Player q)
|
static Stance ChooseInitialStance(Player p, Player q)
|
||||||
{
|
{
|
||||||
|
// HACK
|
||||||
|
return Stance.Enemy;
|
||||||
|
|
||||||
if (p == q) return Stance.Ally;
|
if (p == q) return Stance.Ally;
|
||||||
if (p == world.NeutralPlayer || q == world.NeutralPlayer) return Stance.Neutral;
|
if (p == world.NeutralPlayer || q == world.NeutralPlayer) return Stance.Neutral;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -26,6 +26,9 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void Tick( Player owner, Cache<string, List<Actor>> buildings )
|
public void Tick( Player owner, Cache<string, List<Actor>> buildings )
|
||||||
{
|
{
|
||||||
|
// HACK
|
||||||
|
return;
|
||||||
|
|
||||||
var effectivePrereq = prerequisites.Where( a => a.Traits.Get<BuildableInfo>().Owner.Contains( owner.Country.Race ) );
|
var effectivePrereq = prerequisites.Where( a => a.Traits.Get<BuildableInfo>().Owner.Contains( owner.Country.Race ) );
|
||||||
var nowHasPrerequisites = effectivePrereq.Any() &&
|
var nowHasPrerequisites = effectivePrereq.Any() &&
|
||||||
effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.traits.Get<Building>().Disabled ) );
|
effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.traits.Get<Building>().Disabled ) );
|
||||||
|
|||||||
@@ -91,7 +91,27 @@ namespace OpenRA
|
|||||||
Timer.Time("renderer: {0}");
|
Timer.Time("renderer: {0}");
|
||||||
|
|
||||||
WorldActor = CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
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, null);
|
||||||
|
Console.WriteLine("Creating Player {0}", kv.Key);
|
||||||
|
|
||||||
|
// Lets just pretend that i didn't do this.... Will fix later
|
||||||
|
player.GetType().GetField("Index").SetValue( player, mapPlayerIndex-- );
|
||||||
|
player.GetType().GetField("Palette").SetValue( player, kv.Value.Palette );// Todo: set Player.Color as well
|
||||||
|
player.GetType().GetField("PlayerName").SetValue( player, kv.Value.Name );
|
||||||
|
player.GetType().GetField("InternalName").SetValue( player, kv.Value.Name );
|
||||||
|
player.GetType().GetField("Country").SetValue( player, this.GetCountries().FirstOrDefault(c => kv.Value.Race == c.Name) );
|
||||||
|
|
||||||
|
AddPlayer(player);
|
||||||
|
|
||||||
|
// Todo: Obsolete usage of "World.NeutralPlayer"
|
||||||
|
if (kv.Value.Name == "Neutral")
|
||||||
|
NeutralPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
Timer.Time( "worldActor: {0}" );
|
Timer.Time( "worldActor: {0}" );
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,20 @@ TopLeft: 26,36
|
|||||||
|
|
||||||
BottomRight: 118,93
|
BottomRight: 118,93
|
||||||
|
|
||||||
|
Players:
|
||||||
|
PlayerReference@Neutral:
|
||||||
|
Name: Neutral
|
||||||
|
Palette: neutral
|
||||||
|
Race: allies
|
||||||
|
PlayerReference@GoodGuy:
|
||||||
|
Name: GoodGuy
|
||||||
|
Palette: player1
|
||||||
|
Race: allies
|
||||||
|
PlayerReference@Greece:
|
||||||
|
Name: Greece
|
||||||
|
Palette: player4
|
||||||
|
Race: soviet
|
||||||
|
|
||||||
Actors:
|
Actors:
|
||||||
Actor0: brik Neutral 32,43
|
Actor0: brik Neutral 32,43
|
||||||
Actor1: brik Neutral 33,43
|
Actor1: brik Neutral 33,43
|
||||||
|
|||||||
@@ -18,39 +18,45 @@ TopLeft: 14,19
|
|||||||
|
|
||||||
BottomRight: 60,60
|
BottomRight: 60,60
|
||||||
|
|
||||||
|
Players:
|
||||||
|
PlayerReference@Neutral:
|
||||||
|
Name: Neutral
|
||||||
|
Palette: neutral
|
||||||
|
Race: allies
|
||||||
|
|
||||||
Actors:
|
Actors:
|
||||||
Actor0: tc02 25,39 25,39
|
Actor0: tc02 Neutral 25,39
|
||||||
Actor1: tc01 26,40 26,40
|
Actor1: tc01 Neutral 26,40
|
||||||
Actor2: tc01 27,39 27,39
|
Actor2: tc01 Neutral 27,39
|
||||||
Actor3: tc05 30,40 30,40
|
Actor3: tc05 Neutral 30,40
|
||||||
Actor4: tc04 37,39 37,39
|
Actor4: tc04 Neutral 37,39
|
||||||
Actor5: tc04 39,37 39,37
|
Actor5: tc04 Neutral 39,37
|
||||||
Actor6: tc04 41,35 41,35
|
Actor6: tc04 Neutral 41,35
|
||||||
Actor7: t01 42,33 42,33
|
Actor7: t01 Neutral 42,33
|
||||||
Actor8: t01 50,24 50,24
|
Actor8: t01 Neutral 50,24
|
||||||
Actor9: t05 49,25 49,25
|
Actor9: t05 Neutral 49,25
|
||||||
Actor10: t08 45,29 45,29
|
Actor10: t08 Neutral 45,29
|
||||||
Actor11: tc04 43,49 43,49
|
Actor11: tc04 Neutral 43,49
|
||||||
Actor12: tc01 45,51 45,51
|
Actor12: tc01 Neutral 45,51
|
||||||
Actor13: tc01 48,52 48,52
|
Actor13: tc01 Neutral 48,52
|
||||||
Actor14: t03 40,42 40,42
|
Actor14: t03 Neutral 40,42
|
||||||
Actor15: t03 35,40 35,40
|
Actor15: t03 Neutral 35,40
|
||||||
Actor16: tc04 57,57 57,57
|
Actor16: tc04 Neutral 57,57
|
||||||
Actor17: tc02 58,19 58,19
|
Actor17: tc02 Neutral 58,19
|
||||||
Actor18: tc01 21,19 21,19
|
Actor18: tc01 Neutral 21,19
|
||||||
Actor19: tc02 19,20 19,20
|
Actor19: tc02 Neutral 19,20
|
||||||
Actor20: t08 16,22 16,22
|
Actor20: t08 Neutral 16,22
|
||||||
Actor21: v12 18,22 18,22
|
Actor21: v12 Neutral 18,22
|
||||||
Actor22: t05 18,55 18,55
|
Actor22: t05 Neutral 18,55
|
||||||
Actor23: tc02 16,54 16,54
|
Actor23: tc02 Neutral 16,54
|
||||||
Actor24: t16 29,39 29,39
|
Actor24: t16 Neutral 29,39
|
||||||
Actor25: t16 21,56 21,56
|
Actor25: t16 Neutral 21,56
|
||||||
Actor26: mine 33,45 33,45
|
Actor26: mine Neutral 33,45
|
||||||
Actor27: mine 36,45 36,45
|
Actor27: mine Neutral 36,45
|
||||||
Actor28: mine 44,43 44,43
|
Actor28: mine Neutral 44,43
|
||||||
Actor29: mine 45,40 45,40
|
Actor29: mine Neutral 45,40
|
||||||
Actor30: mine 37,34 37,34
|
Actor30: mine Neutral 37,34
|
||||||
Actor31: mine 35,37 35,37
|
Actor31: mine Neutral 35,37
|
||||||
|
|
||||||
Waypoints:
|
Waypoints:
|
||||||
wp0: 29,24
|
wp0: 29,24
|
||||||
|
|||||||
Reference in New Issue
Block a user