mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Backwards compat
This commit is contained in:
parent
3b19c81b42
commit
cdb5604cff
121
NewHorizons/External/Configs/PlanetConfig.cs
vendored
121
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -241,54 +241,6 @@ namespace NewHorizons.External.Configs
|
||||
if (Bramble?.dimension != null) canShowOnTitle = false;
|
||||
if (Orbit?.staticPosition != null) Orbit.isStatic = true;
|
||||
|
||||
// For each quantum group, verify the following:
|
||||
// this group's id should be unique
|
||||
// if type == sockets, group.sockets should not be null or empty
|
||||
// if type == sockets, count every prop that references this group. the number should be < group.sockets.Count
|
||||
// if type == sockets, for each socket, if rotation == null, rotation = Vector3.zero
|
||||
// if type == sockets, for each socket, position must not be null
|
||||
// For each detail prop,
|
||||
// if detail.quantumGroupID != null, there exists a quantum group with that id
|
||||
if (Props?.quantumGroups != null && Props?.details != null)
|
||||
{
|
||||
Dictionary<string, QuantumGroupInfo> existingGroups = new Dictionary<string, QuantumGroupInfo>();
|
||||
foreach (var quantumGroup in Props.quantumGroups)
|
||||
{
|
||||
if (existingGroups.ContainsKey(quantumGroup.id)) { NHLogger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
|
||||
existingGroups[quantumGroup.id] = quantumGroup;
|
||||
if (quantumGroup.type == QuantumGroupType.Sockets)
|
||||
{
|
||||
if (quantumGroup.sockets?.Length == 0) { NHLogger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
else
|
||||
{
|
||||
foreach (var socket in quantumGroup.sockets)
|
||||
{
|
||||
if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero;
|
||||
if (socket.position == null) { NHLogger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var existingGroupsPropCounts = new Dictionary<string, int>();
|
||||
foreach (var prop in Props?.details)
|
||||
{
|
||||
if (prop.quantumGroupID == null) continue;
|
||||
if (!existingGroups.ContainsKey(prop.quantumGroupID)) NHLogger.LogWarning($"A prop wants to be a part of quantum group {prop.quantumGroupID}, but this group does not exist.");
|
||||
else existingGroupsPropCounts[prop.quantumGroupID] = existingGroupsPropCounts.GetValueOrDefault(prop.quantumGroupID) + 1;
|
||||
}
|
||||
|
||||
foreach (var quantumGroup in Props.quantumGroups)
|
||||
{
|
||||
if (quantumGroup.type == QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length)
|
||||
{
|
||||
NHLogger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets.");
|
||||
quantumGroup.type = QuantumGroupType.FailedValidation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stars and focal points shouldnt be destroyed by stars
|
||||
if (Star != null || FocalPoint != null) Base.hasFluidDetector = false;
|
||||
|
||||
@ -705,6 +657,79 @@ namespace NewHorizons.External.Configs
|
||||
{
|
||||
Base.hasFluidDetector = false;
|
||||
}
|
||||
|
||||
// OLD QUANTUM VALIDATION
|
||||
// For each quantum group, verify the following:
|
||||
// this group's id should be unique
|
||||
// if type == sockets, group.sockets should not be null or empty
|
||||
// if type == sockets, count every prop that references this group. the number should be < group.sockets.Count
|
||||
// if type == sockets, for each socket, if rotation == null, rotation = Vector3.zero
|
||||
// if type == sockets, for each socket, position must not be null
|
||||
// For each detail prop,
|
||||
// if detail.quantumGroupID != null, there exists a quantum group with that id
|
||||
if (Props?.quantumGroups != null && Props?.details != null)
|
||||
{
|
||||
Dictionary<string, QuantumGroupInfo> existingGroups = new Dictionary<string, QuantumGroupInfo>();
|
||||
foreach (var quantumGroup in Props.quantumGroups)
|
||||
{
|
||||
if (existingGroups.ContainsKey(quantumGroup.id)) { NHLogger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
|
||||
existingGroups[quantumGroup.id] = quantumGroup;
|
||||
if (quantumGroup.type == QuantumGroupType.Sockets)
|
||||
{
|
||||
if (quantumGroup.sockets?.Length == 0) { NHLogger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
else
|
||||
{
|
||||
foreach (var socket in quantumGroup.sockets)
|
||||
{
|
||||
if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero;
|
||||
if (socket.position == null) { NHLogger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = QuantumGroupType.FailedValidation; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var existingGroupsPropCounts = new Dictionary<string, int>();
|
||||
foreach (var prop in Props?.details)
|
||||
{
|
||||
if (prop.quantumGroupID == null) continue;
|
||||
if (!existingGroups.ContainsKey(prop.quantumGroupID)) NHLogger.LogWarning($"A prop wants to be a part of quantum group {prop.quantumGroupID}, but this group does not exist.");
|
||||
else existingGroupsPropCounts[prop.quantumGroupID] = existingGroupsPropCounts.GetValueOrDefault(prop.quantumGroupID) + 1;
|
||||
}
|
||||
|
||||
foreach (var quantumGroup in Props.quantumGroups)
|
||||
{
|
||||
if (quantumGroup.type == QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length)
|
||||
{
|
||||
NHLogger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets.");
|
||||
quantumGroup.type = QuantumGroupType.FailedValidation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Props != null)
|
||||
{
|
||||
var socketQuantumGroups = Props.quantumGroups.Where(x => x.type == QuantumGroupType.Sockets).Select(x => new SocketQuantumGroupInfo()
|
||||
{
|
||||
id = x.id,
|
||||
sockets = x.sockets,
|
||||
});
|
||||
if (socketQuantumGroups.Any())
|
||||
{
|
||||
Props.socketQuantumGroups = socketQuantumGroups.ToArray();
|
||||
}
|
||||
var stateQuantumGroups = Props.quantumGroups.Where(x => x.type == QuantumGroupType.States).Select(x => new StateQuantumGroupInfo()
|
||||
{
|
||||
id = x.id,
|
||||
hasEmptyState = x.hasEmptyState,
|
||||
loop = x.loop,
|
||||
sequential = x.sequential
|
||||
});
|
||||
if (stateQuantumGroups.Any())
|
||||
{
|
||||
Props.stateQuantumGroups = stateQuantumGroups.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user