Skip to content

Instantly share code, notes, and snippets.

View dresswithpockets's full-sized avatar
💝
comfy

Ashley dresswithpockets

💝
comfy
View GitHub Profile
#define DEBUG_CC2D_RAYS
using UnityEngine;
using System;
using System.Collections.Generic;
// ReSharper disable All
namespace Prime31
{
[RequireComponent(typeof(BoxCollider2D), typeof(Rigidbody2D))]
public sealed class CharacterController2D : MonoBehaviour
#define DEBUG_CC2D_RAYS
using UnityEngine;
using System;
using System.Collections.Generic;
// ReSharper disable All
namespace Prime31
{
[RequireComponent(typeof(BoxCollider2D), typeof(Rigidbody2D))]
public sealed class CharacterController2D : MonoBehaviour
@dresswithpockets
dresswithpockets / gdnative.odin
Last active April 17, 2022 08:11
gdnative binding
package gdnative
import _c "core:c"
Int :: _c.int;
Real :: _c.float;
Bool :: _c.bool;
Object :: rawptr;
ClassConstructor :: #type proc "c" () -> rawptr;
GdnativeInitFn :: #type proc "c" (unamed0 : ^GdnativeInitOptions);
@dresswithpockets
dresswithpockets / TestButton.gd
Last active April 17, 2022 08:27
Odin gdnative binding borked on linux, works fine on windows.
extends Button
const SIMPLE = preload("res://romper/simple.gdns")
var data
func _on_Button_pressed():
if data:
print("Data = " + data.get_data())
else:
@dresswithpockets
dresswithpockets / build_and_run.sh
Last active April 14, 2022 04:49
Testing odin interop
odin build test.odin -file -build-mode:shared -out:libtest.so || exit $?;
$1 -Wall -Werror -o test_dlopen main.c || exit $?;
$1 -Wall -Werror -o test_linked main.c -ltest -L. -DTEST_LINKED || exit $?;
printf '\n[mode: dlopen]\n'
LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH} ./test_dlopen || exit $?;
printf '\n[mode: linked]\n'
LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH} ./test_linked || exit $?;
public class BetterSimpleStateMachine<TEnum> : Component, IUpdatable
where TEnum : struct, IComparable, IFormattable
{
class StateMethodCache
{
public Action EnterState;
public Func<TEnum> Tick;
public Action ExitState;
}
Windows 10 x64
Radeon 1500x (8 CPUs) ~3.5 GHz
./main.exe
[1M Iterations Internal Lerp] 1000000 rounds in 28827000 ns
34689700.628 rounds/s
[100M Iterations Internal Lerp] 100000000 rounds in 2900400700 ns
34477994.713 rounds/s
[1M Iterations Custom Lerp] 1000000 rounds in 21413900 ns
46698639.669 rounds/s
public static class TaskExtensions
{
public static Task OnSuccess(this Task task, Action<Task> success)
{
_ = task.ContinueWith(success, TaskContinuationOptions.OnlyOnRanToCompletion);
return task;
}
public static Task OnError(this Task task, Action<Task> error)
{
/*Start Minimal GC Styling*/
.controller.custom {
background: url(https://imgur.com/CdyFFZZ.png);
height: 441px;
width: 981px;
}
.custom .bumpers{
position: absolute;
height: 100px;
@dresswithpockets
dresswithpockets / Go.cs
Created December 14, 2021 22:47
Working in C# like its Go
public record User(int Id, string Username);
// might have some state, doesnt necessarily need any though
public record UserController();
public static class UserControllerExt {
public static void DoComplexActionAgainstUser(
this UserController uc,
IUserConn conn,
int id) {