Skip to content

Instantly share code, notes, and snippets.

View fversnel's full-sized avatar

Frank Versnel fversnel

View GitHub Profile
public enum MoveType { LightPunch, MediumPunch, HeavyPunch, SuperPunch, Fireball }
public class InputSequence
{
public IList<IList> sequence;
}
public class Move
{
public MoveType type;
@fversnel
fversnel / AnonymousMonobehaviours.cs
Last active December 25, 2015 07:49
Creates an anonymous MonoBehaviour instance from a given update Action.
public static class AnonymousMonoBehaviours
{
private static readonly Action EmptyAction = () => { };
/// <summary>
/// Creates an anonymous MonoBehaviour instance from a given update Action.
/// The instance can be destroyed by calling Dispose on the returned IDisposable.
/// </summary>
/// <param name="updateFn">Called whenever AnonymousMonobehaviour.Update() is called.</param>
/// <param name="startFn">Called whenever AnonymousMonobehaviour.Start() is called.</param>
@fversnel
fversnel / UnitySingleton.cs
Created October 15, 2013 14:13
Singleton implementation from the 'Unite 2013 - Internal Unity Tips and Tricks' talk (http://www.youtube.com/watch?v=Ozc_hXzp_KU)
using UnityEngine;
public class Example : MonoBehaviour
{
public static Example Singleton;
void OnEnable()
{
if (Singleton == null)
Singleton = this;
@fversnel
fversnel / ObserveVsSelect.cs
Last active August 29, 2015 14:01
Difference between Select and Observable.Create
void Start ()
{
var onNext = UnityObservable.EveryUpdate<float>(observer =>
{
Debug.Log("on next call: " + Time.time);
observer.OnNext(Time.time);
});
var select = UnityObservable.EveryUpdate<Unit>(observer => observer.OnNext(Unit.Default))
.Select(_ =>
{
@fversnel
fversnel / SingleAxisDeadzone.cs
Last active August 29, 2015 14:03
Single axis deadzone
public static Func<float, float> SingleAxisDeadzone(float deadzone)
{
var scalingFactor = 1 - deadzone;
return axisState =>
{
if (Mathf.Abs(axisState) < deadzone)
{
return 0f;
}
@fversnel
fversnel / SmartSortable.js
Created December 30, 2014 11:36
React SmartSortable
var cloneWithProps = React.addons.cloneWithProps;
var SmartSortable = React.createClass({
getDefaultProps: function() {
return {component: "ul", childComponent: "li"};
},
render: function() {
var props = jQuery.extend({}, this.props);
@fversnel
fversnel / GameObjectFactory.cs
Created January 29, 2015 11:51
Unity Game Object Factory
using System;
using UnityEngine;
namespace RamjetAnvil.GameObjectFactories
{
public struct ObjectFactory {
private readonly bool _isObjectActive;
private readonly Func<GameObject> _instantiator;
public ObjectFactory(bool isObjectActive, Func<GameObject> instantiator) {
@fversnel
fversnel / FunctionalEntitas.cs
Created June 26, 2015 11:22
First version of a functional API for the Entitas framework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Entitas.Functional {
/// <summary>
/// TODO Naming systems with string instead of Type
using System;
using UnityEngine;
namespace RamjetAnvil.Networking {
public static class Compression {
public static class Rotation {
private const float Minimum = -1.0f / 1.414214f; // note: 1.0f / sqrt(2)
private const float Maximum = +1.0f / 1.414214f;
frank@ui:~/Desktop/RakNet/DependentExtensions/Swig$ ./MakeSwig.sh ../../Source/
Performing Swig build
without SQLiteClientLogger
../../Source/RakNetDefines.h:28: Warning 305: Bad constant value (ignored).
../../Source/RakPeer.h:57: Warning 401: Nothing known about base class 'RNS2EventHandler'. Ignored.
../../Source/NatTypeDetectionClient.h:45: Warning 401: Nothing known about base class 'RNS2EventHandler'. Ignored.
../../Source/NatTypeDetectionServer.h:55: Warning 401: Nothing known about base class 'RNS2EventHandler'. Ignored.
../../Source/RakWString.h:40: Warning 503: Can't wrap 'operator wchar_t*' unless renamed to a valid identifier.
Swig build complete
Removing and replacing the sample cs files with fresh ones