Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View soraphis's full-sized avatar

Soraphis soraphis

View GitHub Profile
@soraphis
soraphis / UnityAppStatusBarExtender.cs
Last active April 23, 2023 21:02
Pendant for the https://github.com/marijnz/unity-toolbar-extender just for the bottom status bar. Add
/*
* This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@soraphis
soraphis / trait_impl_proposal.md
Created February 18, 2023 11:48
C# trait interface implementation proposal

Disclaimer: ChatGPT helped me to write this markdown file

Proposal for a C# Language Feature: Trait Implementations

Summary

This proposal introduces a new language feature for C# called Trait Implementations. This feature allows developers to provide implementations for interfaces on types that they don't have access to. Trait Implementations can also be used to extend existing interfaces with default implementations.

@soraphis
soraphis / RevertibleChangeProxy.cs
Last active March 8, 2023 11:12
a realproxy implementation of IRevertibleChangeTracking
/*
Copyright © 2021 github.com/soraphis
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
@soraphis
soraphis / singleton.cs
Last active October 8, 2019 07:34
generic version of thread safe singletons based on: https://csharpindepth.com/Articles/Singleton
// ---------------------------------------------------------------------------------------------
// SOME UTILY CLASSES
// ---------------------------------------------------------------------------------------------
public abstract class ThreadSafeSingleton<T> where T : ThreadSafeSingleton<T>, new()
{
static ThreadSafeSingleton(){}
protected ThreadSafeSingleton() { }
public static T Instance { get; } = new T();
}
@soraphis
soraphis / 01_ProfilerResults.png
Last active April 9, 2019 16:40
Testing garbage allocation of strings and string concatenation in unity
01_ProfilerResults.png
@soraphis
soraphis / CInput.cs
Last active January 5, 2019 13:04
Unity3D more Complex Input. Differentiate between UI clicks and world clicks, check if mouse is dragging
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Experimental.PlayerLoop;
using UInput = UnityEngine.Input;
public static class CInput {
[RuntimeInitializeOnLoadMethod]
@soraphis
soraphis / _output
Last active January 7, 2018 22:58
python file that calculates base ressources needed to craft components.
Minecraft Mod: "Solar Flux"
Modpack: Project Ozone Lite
Calculating Cost Efficiency
3 x Chaotic Solar Panel -> 1572864.0 RF/t 100.00%
4 x Draconic Solar Panel -> 524288.0 RF/t 33.33%
8 x Solar Panel 8 -> 262144.0 RF/t 16.67%
/*
this is an example
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
@soraphis
soraphis / SomeCameraTest.cs
Last active October 8, 2016 21:44
a script for orthogonal cameras, which starts moving the camera when the player is about to leave the visible region. can be seen here: https://gfycat.com/NecessaryFelineHare
using UnityEngine;
public class SomeCameraTest : MonoBehaviour {
private Bounds outer_bounds;
private Bounds inner_bounds;
private bool bounds_reached = false;
[SerializeField] private Transform target;
[SerializeField] private Camera cam;
[SerializeField] private float camSpeed = 8f; // set to player speed