Skip to content

Instantly share code, notes, and snippets.

View eelstork's full-sized avatar

T.E.A de Souza eelstork

View GitHub Profile
@eelstork
eelstork / status.cs
Last active October 11, 2022 20:38
BT via ternary logic in C#
public readonly struct status{
readonly int ω;
public static readonly status done = new status( +1 ), fail = new status( -1 ), cont = new status( 0 );
public bool failing => ω == -1;
public bool running => ω == 0;
public bool complete => ω == +1;
using Ex = System.Exception;
using T = UnityEngine.Transform; using UnityEngine;
using Active.Core; using static Active.Core.status; using Active.Util;
namespace Activ.Kabuki{
public class Actor : XTask{
public float speed = 1, rotationSpeed = 180;
public Transform hold; // for holding an object in hand
public Vector3 holdOffset;
@eelstork
eelstork / Cache.howl
Created August 1, 2020 20:23
Time-sensitive cache; Howl code sample
// (╯°□°)╯ ⌢ C#
⊐ System; ⊐̥ UnityEngine.Time;
⊓ Active.Howl{
‒ ○ Cache<T> ¿ T: ⊟{
T? ω; ⒡<T> evaluator; ㅅ duration, end;
‒ Cache(⒡<T> φ, ㅅ expiry = 1f){
evaluator = φ; duration = expiry;
@eelstork
eelstork / Duelist.cs
Created August 30, 2019 09:27
A code snippet demonstrating the Active Logic Library
using UnityEngine;
using Active.Core;
using static Active.Core.status;
using Auto = System.Runtime.CompilerServices.CallerMemberNameAttribute;
public class Duelist : UTask{
const string WALK = "Walk", RUN = "Run", IDLE = "Idle";
const float rotationalSpeed = 180;
//
public string targetName;
@eelstork
eelstork / Cooldown.cs
Created August 29, 2019 08:55
Demonstrates implementing an Active Logic Decorator
using System;
using Active.Core;
using static Active.Core.status;
using Tag = System.Runtime.CompilerServices.CallerLineNumberAttribute;
[Serializable] public class Cooldown : Conditional {
public float duration = 1f;
float stamp = System.Single.MinValue;
@eelstork
eelstork / install-aws-cli
Last active August 25, 2017 03:17
Install the AWS cli
set -ex
apt-get update
apt-get install -y python3-pip
pip3 install —upgrade pip
pip3 install awscli --upgrade --user
echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc
aws —version
@eelstork
eelstork / SimpleFlightControls.cs
Last active March 1, 2017 11:03
Simple flight controls (no physics/collision) useful for inspecting or demoing a scene. Add to camera and you are set. [ = ] to accelerate; [ - ] to decelerate; SPACE to stop and start.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class SimpleFlightControls : MonoBehaviour {
[Header("Parameters")]
[Tooltip("Current/Default Speed")]
public float speed = 1.0f;
@eelstork
eelstork / Hop.cs
Created January 15, 2017 16:42
Script allowing a physics enabled character to hop over small steps/fences
using UnityEngine;
public class Hop : MonoBehaviour {
public float low=0.14f; // min hopping height
public float high=0.6f; // max hopping height
public float distance=1.0f; // distance to hop
public float cooldown = 0.5f; // min. time between hops
public float strength=2.5f; // impulse in Newtons/kg
public float minSpeed = 0.3f; // min speed to hop
@eelstork
eelstork / Count.swift
Created August 8, 2016 04:01
Count in base N
var base = 3
var max = 20
var data = [0]
var index = 0
for _ in 1...max{
var applied = false
while !applied{
if index>=data.count{
data.append(0)
@eelstork
eelstork / PUNNetworkController.cs
Last active February 28, 2016 11:18
A component that connects to Photon Unity Network and joins or creates a room.
using UnityEngine;
public class PUNNetworkController : MonoBehaviour {
void Start(){ PhotonNetwork.ConnectUsingSettings("v4.2"); }
void OnJoinLobby(){ StartGame (); }
void OnConnectedToMaster(){ StartGame (); }
void StartGame(){ PhotonNetwork.JoinRandomRoom(); }
void OnPhotonRandomJoinFailed(){ PhotonNetwork.CreateRoom("MyMatch"); }
void OnPhotonCreateGameFailed(){ Debug.LogError ("Create game failed"); }