half a loader

This commit is contained in:
Chris Forbes
2010-03-31 19:33:27 +13:00
parent 0f2d891f4b
commit 744eeabb3c
7 changed files with 84 additions and 3 deletions

View File

@@ -66,6 +66,7 @@ namespace OpenRA.FileFormats
public readonly string[] Chrome = { };
public readonly string[] Assemblies = { };
public readonly string[] ChromeLayout = { };
public readonly string[] Weapons = { };
public Manifest(string[] mods)
{
@@ -81,6 +82,7 @@ namespace OpenRA.FileFormats
Chrome = YamlList(yaml, "Chrome");
Assemblies = YamlList(yaml, "Assemblies");
ChromeLayout = YamlList(yaml, "ChromeLayout");
Weapons = YamlList(yaml, "Weapons");
}
static string[] YamlList(Dictionary<string, MiniYaml> ys, string key) { return ys[key].Nodes.Keys.ToArray(); }

View File

@@ -0,0 +1,70 @@
#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 OpenRA.FileFormats;
using OpenRA.Effects;
namespace OpenRA.GameRules
{
public interface IProjectileInfo
{
IEffect Create(); // todo: args for this
}
public class NewWeaponInfo
{
public readonly float Range = 0;
public readonly string Report = null;
public readonly int ROF = 1;
public IProjectileInfo Projectile;
public List<WarheadInfo> Warheads = new List<WarheadInfo>();
public NewWeaponInfo(string name, MiniYaml content)
{
foreach (var kv in content.Nodes)
{
var key = kv.Key.Split('@')[0];
switch (key)
{
case "Range": FieldLoader.LoadField(this, "Range", content.Nodes["Range"].Value); break;
case "ROF": FieldLoader.LoadField(this, "ROF", content.Nodes["ROF"].Value); break;
case "Report": FieldLoader.LoadField(this, "Report", content.Nodes["Report"].Value); break;
case "Warhead":
{
var warhead = new WarheadInfo();
FieldLoader.Load(warhead, kv.Value);
Warheads.Add(warhead);
} break;
// in this case, it's an implementation of IProjectileInfo
default:
{
// todo: create the right implementation!
// fill it with the args
// etc etc
} break;
}
}
}
}
}

View File

@@ -37,6 +37,7 @@ namespace OpenRA
public static TechTree TechTree;
public static Dictionary<string, ActorInfo> Info;
public static Dictionary<string, NewWeaponInfo> Weapons;
public static void LoadRules(string map, Manifest m)
{
@@ -64,11 +65,15 @@ namespace OpenRA
Log.Write(" -- {0}", y);
var yamlRules = m.Rules.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge);
Info = new Dictionary<string, ActorInfo>();
foreach( var kv in yamlRules )
Info.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
var weaponsYaml = m.Weapons.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge);
Weapons = new Dictionary<string, NewWeaponInfo>();
foreach (var kv in weaponsYaml)
Weapons.Add(kv.Key.ToLowerInvariant(), new NewWeaponInfo(kv.Key.ToLowerInvariant(), kv.Value));
TechTree = new TechTree();
}

View File

@@ -33,6 +33,7 @@ namespace OpenRA.GameRules
public readonly int InfDeath = 0;
public readonly string ImpactSound = null;
public readonly string WaterImpactSound = null;
public readonly int Damage = 0; // for new weapons infrastructure
public float EffectivenessAgainst(ArmorType at) { return Verses[ (int)at ]; }
}

View File

@@ -75,6 +75,7 @@
<ItemGroup>
<Compile Include="Chat.cs" />
<Compile Include="Chrome.cs" />
<Compile Include="GameRules\NewWeaponInfo.cs" />
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
<Compile Include="Traits\World\Shroud.cs" />
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />

View File

@@ -26,7 +26,6 @@ LegacyRules:
Rules:
mods/ra/defaults.yaml: Basic stuff
mods/ra/rules.yaml: OpenRA actorinfos
mods/ra/weapons.yaml: Weapon definitions
Sequences:
mods/ra/sequences.xml: Original animation sequences
@@ -39,3 +38,6 @@ Assemblies:
ChromeLayout:
mods/ra/menus.yaml:
Weapons:
mods/ra/weapons.yaml

View File

@@ -21,7 +21,7 @@ ZSU-23:
Speed: 100
Warhead:
Spread: 3
Versus: 30%,75%,75%,100%,50%
Verses: 30%,75%,75%,100%,50%
Explosion: 4
Damage: 25