Initial Commit

This commit is contained in:
Lachlan Leone
2024-01-20 20:00:35 +11:00
commit d78ae93c97
70 changed files with 3212 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using Kitchen.Modules;
using UnityEngine;
namespace Pets.Menus
{
public class EditorGridMenu : GridMenu<GridItemOption>
{
public EditorGridMenu(List<GridItemOption> items, Transform container, int player, bool has_back) : base(items, container, player, has_back)
{
}
protected override int ColumnLength => 1;
protected override void SetupElement(GridItemOption item, GridMenuElement element)
{
element.Set(item);
}
protected override void OnSelect(GridItemOption item)
{
item.DoCallback();
}
}
[Serializable]
public struct GridItemOption : IGridItem
{
public readonly int ActionID;
public Texture2D icon;
private Action<int> SelectCallback;
public GridItemOption(int ActionID, Action<int> callback, Texture2D icon = null)
{
this.ActionID = ActionID;
this.icon = icon;
SelectCallback = callback;
}
public int SnapshotKey => ActionID;
public Texture2D GetSnapshot()
{
if (ActionID == 0)
{
return Mod.Bundle.LoadAsset<Texture2D>("MenuBack");
}
return icon;
}
public void DoCallback()
{
SelectCallback?.Invoke(ActionID);
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using Kitchen.Modules;
using UnityEngine;
namespace Pets.Menus
{
public class GridMenuEditorConfig : GridMenuConfig
{
public override GridMenu Instantiate(Transform container, int player, bool has_back)
{
return new EditorGridMenu(new List<GridItemOption>(), container, player, has_back);
}
public virtual EditorGridMenu Instantiate(Action<int> callback, Transform container, int player, bool has_back)
{
List<GridItemOption> gridAppliances = new List<GridItemOption>()
{
new GridItemOption(0, callback),
new GridItemOption(1, callback, Mod.Bundle.LoadAsset<Texture2D>("Stop")),
new GridItemOption(2, callback, Mod.Bundle.LoadAsset<Texture2D>("Activity")),
new GridItemOption(99, callback, Mod.Bundle.LoadAsset<Texture2D>("Rename"))
};
return new EditorGridMenu(gridAppliances, container, player, has_back);
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using Kitchen.Modules;
using Pets.Customs.Types;
using UnityEngine;
namespace Pets.Menus
{
public class GridMenuPetConfig : GridMenuConfig
{
public override GridMenu Instantiate(Transform container, int player, bool has_back)
{
return new PetGridMenu(Pets, container, player, has_back);
}
public List<Pet> Pets = new List<Pet>();
}
}
+32
View File
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using Kitchen;
using Kitchen.Modules;
using Pets.Customs.Types;
using Pets.Views;
using UnityEngine;
namespace Pets.Menus
{
public class PetGridMenu : GridMenu<Pet>
{
public PetGridMenu(List<Pet> items, Transform container, int player, bool has_back) : base(items, container, player, has_back)
{
}
protected override int ColumnLength => 3;
protected override void SetupElement(Pet item, GridMenuElement element)
{
element.Set(PrefabSnapshot.GetSnapshot(item.IconPrefab));
}
protected override void OnSelect(Pet item)
{
if (Player != 0 && item != null)
{
PetRequestView.PlayerID = Player;
PetRequestView.PetID = item.ID;
}
}
}
}