Small changes
This commit is contained in:
@ -31,7 +31,8 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!new string[] { ".js", ".xml" }.Any(x => x == Path.GetExtension(name)))
|
|
||||||
|
if (!new string[] { ".js", ".xml" }.Any(x => x == Path.GetExtension(name)))
|
||||||
{
|
{
|
||||||
lock (_filesFinished)
|
lock (_filesFinished)
|
||||||
{
|
{
|
||||||
|
@ -6,30 +6,54 @@ using System.Collections.Generic;
|
|||||||
using GTA;
|
using GTA;
|
||||||
using GTA.Math;
|
using GTA.Math;
|
||||||
using GTA.Native;
|
using GTA.Native;
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace CoopClient
|
namespace CoopClient
|
||||||
{
|
{
|
||||||
public class Map
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[XmlRoot(ElementName = "Map")]
|
||||||
|
public class CoopMap
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
[XmlArray("Props")]
|
[XmlArray("Props")]
|
||||||
[XmlArrayItem("Prop")]
|
[XmlArrayItem("Prop")]
|
||||||
public Props[] Props { get; set; }
|
public List<CoopProp> Props { get; set; } = new List<CoopProp>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Props
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public struct CoopProp
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public Vector3 Rotation { get; set; }
|
public Vector3 Rotation { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int Hash { get; set; }
|
public int Hash { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool Dynamic { get; set; }
|
public bool Dynamic { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int Texture { get; set; }
|
public int Texture { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class MapLoader
|
internal static class MapLoader
|
||||||
{
|
{
|
||||||
// string = file name
|
// string = file name
|
||||||
private static readonly Dictionary<string, Map> _maps = new Dictionary<string, Map>();
|
private static readonly Dictionary<string, CoopMap> _maps = new Dictionary<string, CoopMap>();
|
||||||
private static readonly List<int> _createdObjects = new List<int>();
|
private static readonly List<int> _createdObjects = new List<int>();
|
||||||
|
|
||||||
public static void LoadAll()
|
public static void LoadAll()
|
||||||
@ -48,12 +72,12 @@ namespace CoopClient
|
|||||||
{
|
{
|
||||||
string filePath = files[i];
|
string filePath = files[i];
|
||||||
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(Map));
|
XmlSerializer serializer = new XmlSerializer(typeof(CoopMap));
|
||||||
Map map;
|
CoopMap map;
|
||||||
|
|
||||||
using (var stream = new FileStream(filePath, FileMode.Open))
|
using (var stream = new FileStream(filePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
map = (Map)serializer.Deserialize(stream);
|
map = (CoopMap)serializer.Deserialize(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
GTA.UI.Notification.Show($"{map.Props.Count()}");
|
GTA.UI.Notification.Show($"{map.Props.Count()}");
|
||||||
@ -75,14 +99,15 @@ namespace CoopClient
|
|||||||
if (!_maps.ContainsKey(name) || _createdObjects.Count != 0)
|
if (!_maps.ContainsKey(name) || _createdObjects.Count != 0)
|
||||||
{
|
{
|
||||||
GTA.UI.Notification.Show($"The map with the name \"{name}\" couldn't be loaded!");
|
GTA.UI.Notification.Show($"The map with the name \"{name}\" couldn't be loaded!");
|
||||||
|
Logger.Write($"The map with the name \"{name}\" couldn't be loaded!", Logger.LogLevel.Server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map map = _maps[name];
|
CoopMap map = _maps[name];
|
||||||
|
|
||||||
for (int i = 0; i < map.Props.Count(); i++)
|
for (int i = 0; i < map.Props.Count(); i++)
|
||||||
{
|
{
|
||||||
Props prop = map.Props[i];
|
CoopProp prop = map.Props[i];
|
||||||
|
|
||||||
Model model = prop.Hash.ModelRequest();
|
Model model = prop.Hash.ModelRequest();
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
Reference in New Issue
Block a user