New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move voxel loader to Mods.Cnc. #13485
Changes from 8 commits
8ffe39e
0359495
7325de8
64cacab
7d5a173
774ca4f
e1ee6d2
48a7f37
9ebb892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ public class Ruleset | |
public readonly IReadOnlyDictionary<string, MusicInfo> Music; | ||
public readonly TileSet TileSet; | ||
public readonly SequenceProvider Sequences; | ||
public readonly IReadOnlyDictionary<string, MiniYamlNode> ModelSequences; | ||
|
||
public Ruleset( | ||
IReadOnlyDictionary<string, ActorInfo> actors, | ||
|
@@ -37,7 +38,8 @@ public class Ruleset | |
IReadOnlyDictionary<string, SoundInfo> notifications, | ||
IReadOnlyDictionary<string, MusicInfo> music, | ||
TileSet tileSet, | ||
SequenceProvider sequences) | ||
SequenceProvider sequences, | ||
IReadOnlyDictionary<string, MiniYamlNode> modelSequences) | ||
{ | ||
Actors = actors; | ||
Weapons = weapons; | ||
|
@@ -46,6 +48,7 @@ public class Ruleset | |
Music = music; | ||
TileSet = tileSet; | ||
Sequences = sequences; | ||
ModelSequences = modelSequences; | ||
|
||
foreach (var a in Actors.Values) | ||
{ | ||
|
@@ -119,8 +122,11 @@ public static Ruleset LoadDefaults(ModData modData) | |
var music = MergeOrDefault("Manifest,Music", fs, m.Music, null, null, | ||
k => new MusicInfo(k.Key, k.Value)); | ||
|
||
var modelSequences = MergeOrDefault("Manifest,ModelSequences", fs, m.ModelSequences, null, null, | ||
k => k); | ||
|
||
// The default ruleset does not include a preferred tileset or sequence set | ||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, null, null); | ||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, null, null, modelSequences); | ||
}; | ||
|
||
if (modData.IsOnMainThread) | ||
|
@@ -145,12 +151,13 @@ public static Ruleset LoadDefaultsForTileSet(ModData modData, string tileSet) | |
var dr = modData.DefaultRules; | ||
var ts = modData.DefaultTileSets[tileSet]; | ||
var sequences = modData.DefaultSequences[tileSet]; | ||
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, ts, sequences); | ||
|
||
return new Ruleset(dr.Actors, dr.Weapons, dr.Voices, dr.Notifications, dr.Music, ts, sequences, dr.ModelSequences); | ||
} | ||
|
||
public static Ruleset Load(ModData modData, IReadOnlyFileSystem fileSystem, string tileSet, | ||
MiniYaml mapRules, MiniYaml mapWeapons, MiniYaml mapVoices, MiniYaml mapNotifications, | ||
MiniYaml mapMusic, MiniYaml mapSequences) | ||
MiniYaml mapMusic, MiniYaml mapSequences, MiniYaml mapModelSequences) | ||
{ | ||
var m = modData.Manifest; | ||
var dr = modData.DefaultRules; | ||
|
@@ -180,8 +187,12 @@ public static Ruleset LoadDefaultsForTileSet(ModData modData, string tileSet) | |
var sequences = mapSequences == null ? modData.DefaultSequences[tileSet] : | ||
new SequenceProvider(fileSystem, modData, ts, mapSequences); | ||
|
||
// TODO: Add support for custom voxel sequences | ||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, ts, sequences); | ||
var modelSequences = dr.ModelSequences; | ||
if (mapModelSequences != null) | ||
modelSequences = MergeOrDefault("ModelSequences", fileSystem, m.ModelSequences, mapModelSequences, dr.ModelSequences, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can reuse here modelSequences for dr.ModelSequences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to keep it separate to make it clear that it is replacing |
||
k => k); | ||
|
||
ruleset = new Ruleset(actors, weapons, voices, notifications, music, ts, sequences, modelSequences); | ||
}; | ||
|
||
if (modData.IsOnMainThread) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2017 The OpenRA Developers (see AUTHORS) | ||
* This file is part of OpenRA, which is free software. It is made | ||
* available to you 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. For more | ||
* information, see COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System; | ||
using OpenRA.FileSystem; | ||
|
||
namespace OpenRA.Graphics | ||
{ | ||
public interface IModel | ||
{ | ||
uint Frames { get; } | ||
uint Sections { get; } | ||
|
||
float[] TransformationMatrix(uint section, uint frame); | ||
float[] Size { get; } | ||
float[] Bounds(uint frame); | ||
ModelRenderData RenderData(uint section); | ||
} | ||
|
||
public struct ModelRenderData | ||
{ | ||
public readonly int Start; | ||
public readonly int Count; | ||
public readonly Sheet Sheet; | ||
|
||
public ModelRenderData(int start, int count, Sheet sheet) | ||
{ | ||
Start = start; | ||
Count = count; | ||
Sheet = sheet; | ||
} | ||
} | ||
|
||
public interface IModelCache : IDisposable | ||
{ | ||
IModel GetModelSequence(string model, string sequence); | ||
bool HasModelSequence(string model, string sequence); | ||
IVertexBuffer<Vertex> VertexBuffer { get; } | ||
} | ||
|
||
public interface IModelSequenceLoader | ||
{ | ||
Action<string> OnMissingModelError { get; set; } | ||
IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions); | ||
} | ||
|
||
public class PlaceholderModelSequenceLoader : IModelSequenceLoader | ||
{ | ||
public Action<string> OnMissingModelError { get; set; } | ||
|
||
class PlaceholderModelCache : IModelCache | ||
{ | ||
public IVertexBuffer<Vertex> VertexBuffer { get { throw new NotImplementedException(); } } | ||
|
||
public void Dispose() { } | ||
|
||
public IModel GetModelSequence(string model, string sequence) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool HasModelSequence(string model, string sequence) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public PlaceholderModelSequenceLoader(ModData modData) { } | ||
|
||
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions) | ||
{ | ||
return new PlaceholderModelCache(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better MiniYamlNode than e.g. SequenceInfo like for other sections (MusicInfo, ActorInfo,...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a
*Info
for this: it is up to the mod-defined parser to parse what it wants from the yaml tree.