Skip to content

Instantly share code, notes, and snippets.

@xepherys
xepherys / TheFarmerWasReplaced_UNLOCKS_ORDER.py
Last active February 6, 2026 18:03
TheFarmerWasReplaced_UNLOCKS_ORDER.py
# UNLOCKS_ORDER is a static dictionary where the key is the order in which the unlocks should occur. This is subject
# to change with testing and verification. Unlock is what Unlock should be executed. Level is what level of the
# unlock should be queued. Requirements set is the list of requirements needed to unlock that level.
#
# Order Unlock Level Requirements Set
# ----- ------ ----- ----------------
UNLOCKS_ORDER = {0: [Unlocks.Speed, 1, UNLOCKS_DATA[Unlocks.Speed] [0]],
1: [Unlocks.Expand, 1, UNLOCKS_DATA[Unlocks.Expand] [0]],
2: [Unlocks.Plant, 1, UNLOCKS_DATA[Unlocks.Plant] [0]],
3: [Unlocks.Expand, 2, UNLOCKS_DATA[Unlocks.Expand] [1]], #SKIP
@xepherys
xepherys / TheFarmerWasReplaced_UNLOCKS_DATA.py
Last active February 6, 2026 20:23
TheFarmerWasReplaced_UNLOCKS_DATA.py
# UNLOCKS_DATA is valid currently as of February 2026, but is subject to change as the game progresses
# UNLOCKS_DATA is a static dictionary where the key is the Unlocks type and the value is a collection of requirements
# for each level.
# The commented columns exist to help folk who are learning, or just for visualizing data at a quick glance. The 'Index'
# is the index value of the requirements list, e.g. UNLOCKS_DATA[Unlocks.Cactus][2] is the second (2nd) index, which is
# the requirements that need to be met to unlock the third (3rd) 'Level' of Unlocks.Cactus.
#
# The 'ResIdx' the index value of the resource for that given level. NOTE: When a level unlock requires more than
# one resource, you can't index it because it's a dictionary - this is for visualization only. You'll need to iterate
# over each using something like: 'for key in dict:'
@xepherys
xepherys / Cast From Object to Generic
Created February 2, 2023 14:59
Cast from an object to the target type of a generic in a generic Class<T>.
using System;
public class Program
{
public static void Main()
{
int myInt = 5;
TestValue<float> testValue = new TestValue<float>();
@xepherys
xepherys / UnityVisualElement.cs
Created December 12, 2022 14:18
Unity VisualElement CustomStyleProperties and Callbacks
class MyElement : VisualElement
{
static readonly CustomStyleProperty<int> k_CellSizeProperty = new CustomStyleProperty<int>("--cell-size");
static readonly CustomStyleProperty<Color> k_OddCellColorProperty = new CustomStyleProperty<Color>("--odd-cell-color");
static readonly CustomStyleProperty<Color> k_EvenCellColorProperty = new CustomStyleProperty<Color>("--even-cell-color");
int m_CellSize;
Color m_OddCellColor;
Color m_EvenCellColor;
@xepherys
xepherys / EditPrefab.cs
Created November 8, 2021 12:31 — forked from ulrikdamm/EditPrefab.cs
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
public class EditPrefab {
static Object getPrefab(Object selection) {
@xepherys
xepherys / EditPrefabInScene.cs
Created October 11, 2021 14:08 — forked from JohannesDeml/EditPrefabInScene.cs
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
// From https://gist.github.com/JohannesDeml/5802473b569718c9c86de906b7039aec
// Original https://gist.github.com/ulrikdamm/338392c3b0900de225ec6dd10864cab4
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
@xepherys
xepherys / ReflectiveEnumerator.cs
Created September 6, 2021 17:38
ReflectiveEnumerator - Enumerate classes inheriting from a specified abstract class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public static class ReflectiveEnumerator
{
/// <summary>
/// Original class from StackExchange post
/// https://stackoverflow.com/questions/5411694/get-all-inherited-classes-of-an-abstract-class/6944605#6944605
@xepherys
xepherys / RollingList.cs
Created September 29, 2020 16:12
RollingList Type that will move the indexer back to 0 when the end of the list is reached.
public class RollingList<T> : List<T>
{
private int indexer = 0;
private int maxIndexer;
public RollingList() : base()
{
maxIndexer = this.Count;
}
@xepherys
xepherys / Xeph.Windows.Forms.ExtendedControls.cs
Last active February 20, 2020 23:13
Extended Windows Forms Controls for Visual Studio
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Windows.Forms;
namespace Xeph.Windows.Forms.ExtendedControls
@xepherys
xepherys / MainCameraEllipticalMWE.cs
Created November 14, 2019 01:28
Unity camera script for tracking around an elliptical or circular path
using System;
using UnityEngine;
/// <summary>
/// The MainCameraEllipticalMWE class provides motion of the camera in an ellipse (or a circle)
/// given sizeX and sizeZ where one is the major axis and the other the minor axis. Which is
/// which isn't important, and they can be equal (x == z) if the camera is to track in a circle.
///
/// The size values assume a 2D surface where x=0, z=0 is at the bottom left and built in both x+
/// and z+ directions.