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 / 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 February 28, 2025 14:16
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 May 28, 2025 23:41
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
@herohiralal
herohiralal / Archetype.cs
Created February 15, 2022 04:03
HiraBots sample 1
using UnityEngine;
using UnityEngine.AI;
namespace AIEngineTest
{
public class Archetype : MonoBehaviour,
IHiraBotArchetype<NavMeshAgent>,
IHiraBotArchetype<Animator>,
IHiraBotArchetype<ConsolidatedSensor>,
IHiraBotArchetype<HiraLGOAPRealtimeBot>,
@JuniorDjjr
JuniorDjjr / fakeMainOutputFile.sc
Created November 11, 2021 17:39
SA main.scm source code leaked from GTA SA The Definitive Edition
This file has been truncated, but you can view the full file.
// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************
// ****************************************PC SA Main Script********************************
// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************
SCRIPT_NAME MAIN //NEW MAIN