Skip to content

Instantly share code, notes, and snippets.

@gamesbyangelina
Created August 28, 2025 20:19
Show Gist options
  • Select an option

  • Save gamesbyangelina/80e6a5ddf06371ac3b5dffe03dd89573 to your computer and use it in GitHub Desktop.

Select an option

Save gamesbyangelina/80e6a5ddf06371ac3b5dffe03dd89573 to your computer and use it in GitHub Desktop.
Root File: Breakout
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using GameFeelDescriptions.Examples;
public class BreakoutRoot : MonoBehaviour
{
object[] args;
Type[] types;
Dictionary<string, Action<object[]>> hookDictionary;
Dictionary<string, int> hookCalls;
// Start is called before the first frame update
void Start()
{
hookDictionary = new Dictionary<string, Action<object[]>>();
hookCalls = new Dictionary<string, int>();
//Search for any statically referenced methods that we can use
GameGeneration.RefreshStaticReferences();
//Add an external method that cannot be annotated because we don't have source access
GameGeneration.AddExternalMethod("UnityEngine.Vector2, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "Reflect");
GameGeneration.ForceAddField("GameFeelDescriptions.Examples.ballBehavior, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"transform.localScale",
"UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
//This is the list of arguments we will pass to our generated code
types = new Type[]{typeof(ballBehavior), typeof(increaseScore)};
AssemblyEvolution.instance.Setup(
new BreakoutRunSpec()
);
AssemblyEvolution.instance.EvolveViaSimpleMutation(
new HookSpec("onBrickBreak", typeof(ballBehavior), typeof(increaseScore)),
new HookSpec("onHitWall", typeof(ballBehavior), typeof(increaseScore)),
new HookSpec("onHitPaddle", typeof(ballBehavior), typeof(increaseScore))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment