first commit
This commit is contained in:
9
NitroxServer/Resources/IPrefabAsset.cs
Normal file
9
NitroxServer/Resources/IPrefabAsset.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using NitroxModel.DataStructures.Unity;
|
||||
|
||||
namespace NitroxServer.Resources;
|
||||
|
||||
public interface IPrefabAsset
|
||||
{
|
||||
public NitroxTransform Transform { get; set; }
|
||||
public string ClassId { get; }
|
||||
}
|
12
NitroxServer/Resources/PrefabPlaceholderAsset.cs
Normal file
12
NitroxServer/Resources/PrefabPlaceholderAsset.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using NitroxModel.DataStructures.Unity;
|
||||
using NitroxServer.GameLogic.Entities;
|
||||
|
||||
namespace NitroxServer.Resources;
|
||||
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Some PrefabPlaceholders spawn GameObjects that are always there (decor, environment ...)
|
||||
/// And some others spawn a GameObject with an EntitySlot in which case this field is not null.
|
||||
/// </summary>
|
||||
public record struct PrefabPlaceholderAsset(string ClassId, NitroxEntitySlot? EntitySlot = null, NitroxTransform Transform = null) : IPrefabAsset;
|
9
NitroxServer/Resources/PrefabPlaceholderRandomAsset.cs
Normal file
9
NitroxServer/Resources/PrefabPlaceholderRandomAsset.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using NitroxModel.DataStructures.Unity;
|
||||
|
||||
namespace NitroxServer.Resources;
|
||||
|
||||
public record struct PrefabPlaceholderRandomAsset(List<string> ClassIds, NitroxTransform Transform = null, string ClassId = null) : IPrefabAsset
|
||||
{
|
||||
public NitroxTransform Transform { get; set; } = Transform;
|
||||
}
|
11
NitroxServer/Resources/PrefabPlaceholdersGroupAsset.cs
Normal file
11
NitroxServer/Resources/PrefabPlaceholdersGroupAsset.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using NitroxModel.DataStructures.Unity;
|
||||
|
||||
namespace NitroxServer.Resources;
|
||||
|
||||
|
||||
[Serializable]
|
||||
/// <param name="PrefabAssets">
|
||||
/// All attached PrefabPlaceholders (and PrefabPlaceholdersGroup). Is in sync with PrefabPlaceholdersGroup.prefabPlaceholders
|
||||
/// </param>
|
||||
public record struct PrefabPlaceholdersGroupAsset(string ClassId, IPrefabAsset[] PrefabAssets, NitroxTransform Transform = null) : IPrefabAsset;
|
23
NitroxServer/Resources/RandomSpawnSpoofer.cs
Normal file
23
NitroxServer/Resources/RandomSpawnSpoofer.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using NitroxServer.Helper;
|
||||
|
||||
namespace NitroxServer.Resources;
|
||||
|
||||
public class RandomSpawnSpoofer
|
||||
{
|
||||
private readonly Dictionary<string, string[]> randomPossibilitiesByClassId;
|
||||
|
||||
public RandomSpawnSpoofer(Dictionary<string, string[]> randomPossibilitiesByClassId)
|
||||
{
|
||||
this.randomPossibilitiesByClassId = randomPossibilitiesByClassId;
|
||||
}
|
||||
|
||||
public void PickRandomClassIdIfRequired(ref string classId)
|
||||
{
|
||||
if (randomPossibilitiesByClassId.TryGetValue(classId, out string[] choices))
|
||||
{
|
||||
int randomIndex = XORRandom.NextIntRange(0, choices.Length);
|
||||
classId = choices[randomIndex];
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user