Upload from upload_mods.ps1
This commit is contained in:
56
Scripts/Command/ConsoleCmdListPrefabs.cs
Normal file
56
Scripts/Command/ConsoleCmdListPrefabs.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class ConsoleCmdListPrefabs : ConsoleCmdAbstract
|
||||
{
|
||||
public override bool IsExecuteOnClient => true;
|
||||
public override bool AllowedInMainMenu => false;
|
||||
public override int DefaultPermissionLevel => 1000;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
if (GameManager.Instance.adminTools == null)
|
||||
return;
|
||||
|
||||
List<PrefabInstance> uniquePrefabs = new List<PrefabInstance>();
|
||||
|
||||
// Iterate over all prefabs
|
||||
for (int i = 0; i < GameManager.Instance.GetDynamicPrefabDecorator().allPrefabs.Count; i++)
|
||||
{
|
||||
PrefabInstance prefabInstance = GameManager.Instance.GetDynamicPrefabDecorator().allPrefabs[i];
|
||||
|
||||
if (prefabInstance == null) continue;
|
||||
|
||||
bool proceed = prefabInstance.prefab.SleeperVolumes.Count > 0 && !prefabInstance.prefab.Tags.Test_AnySet(FastTags<TagGroup.Poi>.Parse("rwgonly,streettile,hideui,part"));
|
||||
|
||||
if (!proceed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if prefab already exists in the list (by prefabName)
|
||||
if (uniquePrefabs.Any(p => p.prefab.PrefabName == prefabInstance.prefab.PrefabName)) continue;
|
||||
|
||||
// Add unique prefab instance to the list
|
||||
uniquePrefabs.Add(prefabInstance);
|
||||
}
|
||||
|
||||
// Sort the list by difficultyTier
|
||||
uniquePrefabs = uniquePrefabs.OrderBy(p => p.prefab.DifficultyTier).ToList();
|
||||
|
||||
foreach (PrefabInstance prefabInstance in uniquePrefabs)
|
||||
{
|
||||
Log.Out("ConsoleCmdListPrefabs-Execute prefab: " + prefabInstance.prefab.PrefabName + " [" + prefabInstance.prefab.DifficultyTier + "] + / tags: " + prefabInstance.prefab.Tags);
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new string[1] { "listprefabs" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "List the prefabs on the current map";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user