Skip to content

Commit f64a811

Browse files
Fix automatic generation of Rio de Janeiro airdrop spawns and set the storage of custom airdrops in Airdrops.xml
1 parent 4ee9cc9 commit f64a811

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

AirdropManager3/AirdropManager3.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net48</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<RootNamespace>RestoreMonarchy.AirdropManager3</RootNamespace>
7-
<Version>3.0.4</Version>
7+
<Version>3.0.5</Version>
88
</PropertyGroup>
99

1010
<ItemGroup>

AirdropManager3/Configurations/AirdropSpawnsXmlConfiguration.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
using RestoreMonarchy.AirdropManager3.Helpers;
22
using RestoreMonarchy.AirdropManager3.Models;
3-
using Rocket.Core.Logging;
43
using SDG.Unturned;
54
using System;
6-
using System.Collections;
75
using System.Collections.Generic;
86
using System.IO;
97
using System.Linq;
108
using System.Xml.Serialization;
119
using UnityEngine;
12-
using Logger = Rocket.Core.Logging.Logger;
1310

1411
namespace RestoreMonarchy.AirdropManager3.Configurations
1512
{
@@ -53,26 +50,29 @@ public void Save()
5350

5451
private AirdropSpawnsConfiguration Create()
5552
{
56-
IEnumerable<Node> nodes = ReflectionHelper.GetLevelNodesNodes();
57-
58-
if (nodes == null)
53+
IReadOnlyList<LocationDevkitNode> locationNodes = LocationDevkitNodeSystem.Get().GetAllNodes();
54+
List<AirdropDevkitNode> airdropNodes = ReflectionHelper.GetLevelManagerAirdropNodes();
55+
56+
if (locationNodes == null)
5957
{
60-
throw new Exception("Nodes are null.");
58+
locationNodes = [];
6159
}
6260

63-
IEnumerable<LocationNode> locationNodes = nodes.OfType<LocationNode>().ToArray();
64-
IEnumerable<AirdropNode> airdropNodes = nodes.OfType<AirdropNode>().ToArray();
61+
if (airdropNodes == null)
62+
{
63+
throw new Exception("Airdrop nodes are null. Please check if the level is loaded and airdrop nodes are present.");
64+
}
6565

6666
List<AirdropSpawn> airdropSpawns = new();
67-
foreach (AirdropNode airdropNode in airdropNodes)
67+
foreach (AirdropDevkitNode airdropNode in airdropNodes)
6868
{
69-
Vector3 position = airdropNode.point;
70-
LocationNode nearestNode = locationNodes.OrderBy(n => Vector3.Distance(n.point, position)).FirstOrDefault();
69+
Vector3 position = airdropNode.transform.position;
70+
LocationDevkitNode nearestNode = locationNodes.OrderBy(n => Vector3.Distance(n.transform.position, position)).FirstOrDefault();
7171

7272
AirdropSpawn airdropSpawn = new()
7373
{
7474
AirdropId = airdropNode.id,
75-
Name = nearestNode?.name ?? null,
75+
Name = nearestNode?.locationName ?? null,
7676
X = position.x,
7777
Y = position.y,
7878
Z = position.z

AirdropManager3/Configurations/AirdropsXmlConfiguration.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using RestoreMonarchy.AirdropManager3.Helpers;
2-
using RestoreMonarchy.AirdropManager3.Models;
3-
using Rocket.Core.Logging;
1+
using RestoreMonarchy.AirdropManager3.Models;
42
using SDG.Unturned;
53
using System;
6-
using System.Collections;
74
using System.Collections.Generic;
85
using System.IO;
96
using System.Xml.Serialization;
@@ -111,6 +108,14 @@ private AirdropsConfiguration Create()
111108
}
112109
}
113110

111+
LevelAsset levelAsset = Level.getAsset();
112+
AssetReference<AirdropAsset> assetReference = levelAsset != null ? levelAsset.airdropRef : AssetReference<AirdropAsset>.invalid;
113+
AirdropAsset airdropAsset = null;
114+
if (!assetReference.isNull)
115+
{
116+
airdropAsset = assetReference.Find();
117+
}
118+
114119
List<Airdrop> airdrops = new();
115120
foreach (ushort spawnId in spawnIds)
116121
{
@@ -129,6 +134,22 @@ private AirdropsConfiguration Create()
129134
Name = spawnAsset.name,
130135
Items = items
131136
};
137+
138+
if (airdropAsset != null)
139+
{
140+
ItemStorageAsset barricade = airdropAsset.barricadeRef.Find() as ItemStorageAsset;
141+
if (barricade != null)
142+
{
143+
airdrop.Storage = new()
144+
{
145+
BarricadeId = barricade.id,
146+
Name = barricade.FriendlyName,
147+
Width = barricade.storage_x,
148+
Height = barricade.storage_y
149+
};
150+
}
151+
}
152+
132153
airdrops.Add(airdrop);
133154
}
134155

0 commit comments

Comments
 (0)