Added RocketAssemblyStation and ReadyRocket
This commit is contained in:
@@ -23,7 +23,7 @@ public sealed class ItemCatalog : ScriptableObject
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemsById.TryGetValue(itemId.Trim().ToLowerInvariant(), out definition);
|
||||
return itemsById.TryGetValue(NormalizeId(itemId), out definition);
|
||||
}
|
||||
|
||||
private void RebuildIndex()
|
||||
@@ -39,4 +39,7 @@ public sealed class ItemCatalog : ScriptableObject
|
||||
Debug.LogError($"Duplicate item id '{definition.ItemId}' in {name}.", this);
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizeId(string value) =>
|
||||
value.Trim().ToLowerInvariant().Replace(' ', '-');
|
||||
}
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
public enum ItemCategory
|
||||
{
|
||||
Scrap,
|
||||
SmeltedMaterial,
|
||||
RocketPart,
|
||||
Tool,
|
||||
Consumable
|
||||
}
|
||||
|
||||
[CreateAssetMenu(fileName = "ItemDefinition", menuName = "FORT-BO/Items/Item Definition")]
|
||||
public sealed class ItemDefinition : ScriptableObject
|
||||
public class ItemDefinition : ScriptableObject
|
||||
{
|
||||
[SerializeField] private string itemId;
|
||||
[SerializeField] private string displayName;
|
||||
[SerializeField] private ItemCategory category;
|
||||
[SerializeField] private bool isAssemblyReady;
|
||||
[SerializeField] private NetworkObject worldPrefab;
|
||||
|
||||
public string ItemId => itemId;
|
||||
public string DisplayName => string.IsNullOrWhiteSpace(displayName) ? name : displayName;
|
||||
public ItemCategory Category => category;
|
||||
public bool IsAssemblyReady => isAssemblyReady;
|
||||
public NetworkObject WorldPrefab => worldPrefab;
|
||||
|
||||
private void OnValidate()
|
||||
protected virtual void OnValidate()
|
||||
{
|
||||
itemId = itemId?.Trim().ToLowerInvariant();
|
||||
itemId = NormalizeId(itemId);
|
||||
displayName = displayName?.Trim();
|
||||
}
|
||||
|
||||
protected static string NormalizeId(string value) =>
|
||||
value?.Trim().ToLowerInvariant().Replace(' ', '-');
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@ public sealed class NetworkItem : NetworkBehaviour
|
||||
public ItemDefinition Definition => definition;
|
||||
public string ItemId => definition != null ? definition.ItemId : string.Empty;
|
||||
public string DisplayName => definition != null ? definition.DisplayName : name;
|
||||
public ItemCategory Category => definition != null ? definition.Category : default;
|
||||
|
||||
public bool TryGetDefinition<TDefinition>(out TDefinition typedDefinition)
|
||||
where TDefinition : ItemDefinition
|
||||
{
|
||||
typedDefinition = definition as TDefinition;
|
||||
return typedDefinition != null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user