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 / 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 7, 2024 12:31
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 November 7, 2024 12:33
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
@instance-id
instance-id / CreateAddressableWithShortName.cs
Last active July 9, 2024 23:57
An example of creating an Addressable GameObject from a prefab with a simplified name
// ------------------------------------------------------------------------------------ AddressInfo
// --- AddressInfo --------------------------------------------------------------------------------
public static class AddressInfo
{
public static string prefabGroup = "Prefabs";
public static string prefabLabel = "Prefab";
}
// ------------------------------------------------------------------------------ AddressableHelper
// --- AddressableHelper --------------------------------------------------------------------------
@cardsigner
cardsigner / CMakeLists.txt
Created April 16, 2020 17:29 — forked from baiwfg2/CMakeLists.txt
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)