Skip to content

Instantly share code, notes, and snippets.

View ArnCarveris's full-sized avatar
🎯
R&D

Arn ArnCarveris

🎯
R&D
View GitHub Profile
@adammyhre
adammyhre / Targeting.cs
Last active September 24, 2025 00:44
Combinator Programming Pattern for Unity C#
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using CanTarget = And<And<InRange, IsAlive>, LineOfSight>;
// ---------- Domain ----------
class Health : MonoBehaviour {
public int hp = 10;
@unvestigate
unvestigate / BlenderSyncLib.cpp
Created April 17, 2025 08:12
The main source code files for the BlenderSync addon
#include "BlenderSyncLibExport.h"
#include <enet/enet.h>
#include <stdio.h>
#include <stdint.h>
#include <string>
#include <fstream>
#include "../Basis/include/editor/BasisBlenderSync.h"
@adammyhre
adammyhre / DamageCalculator.cs
Created November 17, 2024 08:57
Expression Trees in Unity Examples
using System;
using System.Linq.Expressions;
using UnityEngine;
public class DamageCalculator : MonoBehaviour {
void Start() {
Func<int, int, int> damageExpression = CreateDamageEvaluator();
int damage = damageExpression(10, 2);
Debug.Log($"Calculated Damage: {damage}");
<m-group id="agent-group">
<m-audio id="agent-audio" y="2" z="-2.7" loop="false"></m-audio>
<m-group id="float-wrapper">
<m-group id="actions-wrapper">
<m-model
id="agent-model"
src="/assets/playground/brainzo_draco.glb"
@adammyhre
adammyhre / PushDownAutomata.cs
Created October 26, 2024 16:50
Stack-Based Finite State Machine (Push Down Automata)
using System.Collections.Generic;
namespace Automata {
public abstract class State {
protected readonly PushDownAutomata pda;
protected State(PushDownAutomata pda) {
this.pda = pda;
}
@macklinb
macklinb / GetHashCode.cs
Last active August 27, 2024 14:12
.NET's String.GetHashCode in C# and JavaScript
// .NET 3.5 implementation
public int GetHashCodeDotNet35(string str)
{
int hashCode = 0;
foreach (char ch in str)
{
hashCode = (hashCode << 5) - hashCode + (int)ch;
}
return hashCode;
}
@adammyhre
adammyhre / SerializableType.cs
Last active November 17, 2025 01:34
SerializableType and Supporting classes
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
[Serializable]
public class SerializableType : ISerializationCallbackReceiver {
[SerializeField] string assemblyQualifiedName = string.Empty;
public Type Type { get; private set; }
@adammyhre
adammyhre / AbilitySystem.cs
Last active August 27, 2025 19:27
MVC Ability System
[CreateAssetMenu(fileName = "AbilityData", menuName = "ScriptableObjects/AbilityData", order = 1)]
public class AbilityData : ScriptableObject {
public AnimationClip animationClip;
public int animationHash;
public float duration;
public Sprite icon;
public string fullName;
void OnValidate() {
@msymt
msymt / REAMDE.md
Created July 23, 2022 07:07
C# to C IPC with memory mapped file

MappedMemory: C# to C

  1. From console create file: dd if=/dev/zero of=/tmp/sharedfile bs=12288 count=1
  2. The C# program
  3. The C program

usage

mcs Sender.cs
@retrogradeorbit
retrogradeorbit / Makefile
Last active May 16, 2024 16:25
Hot loading C wasm into the browser while preserving the state of the heap
CLANG_DIR = $(HOME)/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04
CLANG = $(CLANG_DIR)/bin/clang
LLC = $(CLANG_DIR)/bin/llc
LD = $(CLANG_DIR)/bin/wasm-ld
C_SRC := $(wildcard src/c/*.c)
OBJ_SRC := $(patsubst %.c, %.o, $(C_SRC))
%.o: %.c # delete competing implicit rule