-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using OpenRCT2.Generators.Map.Retro.Providers; | ||
|
||
#nullable enable | ||
|
||
namespace OpenRCT2.Behaviours.Generators.Objects | ||
{ | ||
public static class ProviderHelper | ||
{ | ||
public static IReadOnlyDictionary<string, IObjectProvider<T>> CreateLookup<T>(ProviderObject<T>[] providers) where T : struct | ||
{ | ||
var lookup = new Dictionary<string, IObjectProvider<T>>(); | ||
|
||
foreach (var provider in providers) | ||
{ | ||
var entries = provider.GetEntries(); | ||
|
||
foreach (var identifier in entries.identifiers) | ||
{ | ||
lookup.Add(identifier, entries.provider); | ||
} | ||
} | ||
|
||
return lookup; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
|
||
#nullable enable | ||
|
||
namespace OpenRCT2.Generators.Map.Retro.Providers | ||
{ | ||
/// <summary> | ||
/// Unity object that can create a game object provider for a set of OpenRCT2 object identifiers. | ||
/// </summary> | ||
public abstract class ProviderObject<T> : ScriptableObject where T : struct | ||
{ | ||
/// <summary> | ||
/// Get all identifiers and their object provider. | ||
/// </summary> | ||
public abstract (string[] identifiers, IObjectProvider<T> provider) GetEntries(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using OpenRCT2.Bindings.TileElements; | ||
using OpenRCT2.Generators.Map.Retro.Data; | ||
using OpenRCT2.Utilities; | ||
using UnityEngine; | ||
|
||
#nullable enable | ||
|
||
namespace OpenRCT2.Generators.Map.Retro.Providers | ||
{ | ||
[CreateAssetMenu(menuName = ("OpenRCT2/Objects/" + nameof(SmallScenerySpriteProviderObject)))] | ||
public class SmallScenerySpriteProviderObject : ProviderObject<SmallSceneryInfo> | ||
{ | ||
[SerializeField, Required] GameObject? _prefab; | ||
[SerializeField] Shader? _animationShader; | ||
[SerializeField] ObjectScaleMode _scaleMode; | ||
|
||
[ContextMenuItem("Sort Alphabetically ", nameof(SortObjectIds))] | ||
[SerializeField] string[] _identifiers = Array.Empty<string>(); | ||
|
||
public override (string[] identifiers, IObjectProvider<SmallSceneryInfo> provider) GetEntries() | ||
{ | ||
Assert.IsNotNull(_prefab); | ||
|
||
var provider = new SmallScenerySpriteObjectProvider(_prefab, _animationShader, _scaleMode); | ||
return (_identifiers, provider); | ||
} | ||
|
||
/// <summary> | ||
/// Sorts all object ids alphabetically. | ||
/// </summary> | ||
void SortObjectIds() | ||
{ | ||
Array.Sort(_identifiers); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using OpenRCT2.Bindings.TileElements; | ||
using UnityEngine; | ||
|
||
#nullable enable | ||
|
||
namespace OpenRCT2.Generators.Map.Retro.Providers | ||
{ | ||
public interface IObjectProvider<T> where T : struct | ||
{ | ||
/// <summary> | ||
/// Creates an object according to the provider's implementation. | ||
/// </summary> | ||
GameObject CreateObject(int x, int y, int index, in TileElementInfo element, in T data); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.