EVERYTHING
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using BlockSpace.Worlds;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BlockSpace.Nodes
|
||||
{
|
||||
public sealed class NodeWorldDefaultSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private NodeGraphManager nodeGraphManager;
|
||||
|
||||
[SerializeField]
|
||||
private float startX;
|
||||
|
||||
[SerializeField]
|
||||
private float y = 5f;
|
||||
|
||||
[SerializeField]
|
||||
private float z = 10f;
|
||||
|
||||
[SerializeField]
|
||||
private float xSpacing = 0.45f;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
nodeGraphManager = GetComponent<NodeGraphManager>();
|
||||
}
|
||||
|
||||
public void EnsureDefaultNodesSpawnedIfEmpty(List<WorldGroupsCodec.WorldNodeRecord> nodeRecords, bool broadcast)
|
||||
{
|
||||
if (nodeGraphManager == null)
|
||||
{
|
||||
nodeGraphManager = GetComponent<NodeGraphManager>();
|
||||
}
|
||||
if (nodeGraphManager == null || (nodeRecords != null && nodeRecords.Count > 0) || nodeGraphManager.GetAllNodesSnapshot().Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<NodeDefinition> allDefinitionsSnapshot = nodeGraphManager.GetAllDefinitionsSnapshot();
|
||||
if (allDefinitionsSnapshot == null || allDefinitionsSnapshot.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
allDefinitionsSnapshot.Sort((NodeDefinition a, NodeDefinition b) => string.CompareOrdinal((a != null) ? a.name : string.Empty, (b != null) ? b.name : string.Empty));
|
||||
float num = startX;
|
||||
for (int num2 = 0; num2 < allDefinitionsSnapshot.Count; num2++)
|
||||
{
|
||||
NodeDefinition nodeDefinition = allDefinitionsSnapshot[num2];
|
||||
if (!(nodeDefinition == null))
|
||||
{
|
||||
nodeGraphManager.SpawnNodeSystem(nodeDefinition, new Vector3(num, y, z), Quaternion.identity, broadcast);
|
||||
num += xSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11f32f2e483126a228fb4dd0930feab5
|
||||
timeCreated: 1780325055
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user