Skip to content

Instantly share code, notes, and snippets.

View bddckr's full-sized avatar

Christopher-Marcel Esser bddckr

View GitHub Profile
@bddckr
bddckr / alfred.txt
Last active December 15, 2015 08:49
Custom Alfred OpenGL ES Documentation search for gl{query}. Copy and paste into browser to open in Alfred.
alfred://customsearch/OpenGL%20ES%20Documentation%20for%20gl%7Bquery%7D/opengl/utf8/noplus/http://www.khronos.org/opengles/sdk/docs/man/xhtml/gl{query}.xml
@bddckr
bddckr / Assertions.h
Last active December 19, 2015 07:59
Assertion macro that works exactly like NSAssert(), with the modification that a code block will be run if the condition is not met. Helps a lot to prevent repetitions when handling the condition a second time for release code (NSAssert will be stripped by default.) Thanks to @ merowing_ for https://gist.github.com/krzysztofzablocki/5921645 !
// See http://stackoverflow.com/a/257424/283482
// Normally a "do {…} while (0)" is used to prevent the problem described in the linked answer,
// but this would prevent us from using "continue" or "break" in the block parameter.
// The problem is fixed thanks to the "if (1) {…}", doing the same as the "do {…} while (0)".
#define AssertTrueOrRunBlock(condition, block, description, ...)\
if (1) {\
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS\
BOOL check = !!(condition);\
NSCAssert(check, (description), ##__VA_ARGS__);\
@bddckr
bddckr / DestroySystem.cs
Last active February 15, 2017 19:12
A system to destroy entities in Entitas, for all pools
using System;
using System.Collections.Generic;
using System.Linq;
using Entitas;
public sealed class DestroySystem : ISetPools, IGroupObserverSystem
{
public GroupObserver groupObserver
{
get
@bddckr
bddckr / SteamUGC-KeyValueTagsQuery.cs
Last active January 30, 2017 17:19
Example to show how to use a query to get the key value tags for the user's subscribed items using Steamworks.NET.
/*
Keys can map to multiple different values (1-to-many relationship).
Key names are restricted to alpha-numeric characters and the '_' character.
Both keys and values cannot exceed 255 characters in length.
Key-value tags are searchable by exact match only.
Taken from https://partner.steamgames.com/documentation/ugc
*/
@bddckr
bddckr / DetailedCollector.cs
Created February 8, 2017 13:10
A more detailed collector and reactive system for Entitas.
namespace Entitas
{
using System.Collections.Generic;
using System.Text;
using Serialization;
/// An Collector can observe one or more groups and collects
/// changed entities based on the specified groupEvent.
public sealed class DetailedCollector
{
@bddckr
bddckr / PhotonRealtimeLimits.md
Last active April 16, 2019 03:16
Infos on the messages/second per room limit in Photon Realtime.

Besides the CCU limit in Photon which you can easily increase by paying more there is a messages/second per room limit in Photon Realtime.

Dunno about latency, but the official Photon limit is 500 messages/second per room. Let's say s is your sendrate (s messages per second) and n is the maximum number of players allowed in a room.

So it's 500 = s * n^2 if you do the easy synchronization where every player sends their position etc. to all the other players. Photon counts that as: 1 sent message + n-1 received messages = n messages.

This results in n = 7 for a sendrate s = 10.

@bddckr
bddckr / DestroySystem.cs
Last active July 13, 2021 20:40
A small example on how to use the same kind of system for multiple contexts in Entitas 0.37.0(+).
using System.Collections.Generic;
using Components.Miscellaneous;
using Entitas;
using EntitasHelpers;
using JetBrains.Annotations;
public sealed class DestroySystem<TEntity> : ReactiveSystem<TEntity> where TEntity : class, IEntity, new()
{
private readonly Context<TEntity> _context;
private IMatcher<TEntity> _triggerMatcher;
@bddckr
bddckr / DetailedCollector.cs
Last active February 16, 2017 14:04
A more detailed collector and reactive system for Entitas 0.37.0(+).
namespace Entitas
{
using System.Collections.Generic;
using System.Text;
using Entitas;
/// An Collector can observe one or more groups and collects
/// changed entities based on the specified groupEvent.
public sealed class DetailedCollector<TEntity> where TEntity : class, IEntity, new()
{
using System;
using UnityEngine;
using VRTK;
[RequireComponent(typeof(VRTK_InteractGrab))]
public class InteractableObjectGrabHook : MonoBehaviour
{
[Tooltip("How long a complete move of the interactable object should take (in either direction).")]
public float Duration;
@bddckr
bddckr / CleanUpGameObjectSystem.cs
Created February 22, 2017 14:40
Example of a generic system for multiple typed entities. (Entitas 0.37.0(+))
using System.Collections.Generic;
using Components.GameObjects;
using Components.Miscellaneous;
using Entitas;
using Entitas.Unity.VisualDebugging;
using EntitasHelpers;
using JetBrains.Annotations;
public sealed class CleanUpGameObjectSystem<TEntity> : ReactiveSystem<TEntity> where TEntity : class, IEntity, new()
{