Skip to content

Instantly share code, notes, and snippets.

@DCFApixels
DCFApixels / RangeValues.cs
Last active January 4, 2023 13:29
Range value type for Unity. It has a custom property drawer.
using System;
using UnityEngine;
using Random = UnityEngine.Random;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DCFApixels
{
static class RangeValueUtils
@DCFApixels
DCFApixels / Config.cs
Last active August 17, 2022 03:24
ScriptableObject Singleton for Unity. Can be used to create global game configurations.
using UnityEditor;
using UnityEngine;
namespace DCFApixels
{
public abstract class Config<TSelf> : ScriptableObject where TSelf : ScriptableObject
{
private static object _lock = new object();
private static TSelf _instance;
public static TSelf Instance
@DCFApixels
DCFApixels / SerializableNullable.cs
Last active November 12, 2022 13:06
analog of the standard Nullable<T> that is displayed in the Unity inspector
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using UnityEngine;
namespace DCFApixels
{
[Serializable]
public struct SerializableNullable<T> where T : struct
{
@DCFApixels
DCFApixels / InterfaceReference.cs
Last active November 8, 2023 05:32
Serializable reference to a UnityObject with an interface for Unity
// README
//There are two ways to use this script:
//
//[InterfaceReference(typeof(IInterface))]
//public MonoBehaviour someObject;
//
//[InterfaceReference(typeof(IInterface))]
//public InterfaceReference<IInterface> someObject;
//
//The InterfaceReference attribute auto validates the reference, if the object does not contain a suitable interface, it will remove the reference.
@DCFApixels
DCFApixels / SparseArray.cs
Last active November 8, 2023 05:32
C# SparseArray. Analogous to Dictionary<int, T>, but faster.
//SparseArray. Analogous to Dictionary<int, T>, but faster.
//Benchmark result of indexer.get speed test with 300 elements:
//[Dictinary: 5.786us] [SparseArray: 2.047us].
// author: DCFApixels
// license: MIT
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
@DCFApixels
DCFApixels / SparseArray64.cs
Last active November 8, 2023 05:30
C# SparseArray64. Analogous to Dictionary<long, T>, but faster.
//SparseArray64. Analogous to Dictionary<long, T>, but faster.
//Benchmark result of indexer.get speed test with 300 elements:
//[Dictinary: 6.705us] [SparseArray64: 2.512us].
// author: DCFApixels
// license: MIT
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;

Семантика

version.major.minor

Релизные версии

Минимальная релизная версия -1.0.0.

  • version: глобальные обновления. После увеличения сбрасываются major и minor;
  • major: увеличивается при больших обновлениях, нарушающих обратную совместимость. После увеличения сбрасываются minor;
  • minor: увеличивается при небольших обновлениях или багфиксах, не нарушающих обратную совместимость;

Semantics

version.major.minor

Release versions

The minimum release version is 1.0.0.

  • version: global updates. The major and minor are reset after increasing;
  • major: is incremented for large updates that break backward compatibility. After increasing, minor are reset;
  • minor: increases with small updates or bugfixes that do not break backward compatibility;
@DCFApixels
DCFApixels / IdDispenser.cs
Last active November 8, 2023 05:31
ID dispenser for C#, with the ability to reserve IDs. + Version for Unity.
// Sparse Set based ID dispenser, with the ability to reserve IDs.
// Warning! Release version omits error exceptions, incorrect use may lead to unstable state.
// author: DCFApixels
// license: MIT
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
@DCFApixels
DCFApixels / Service.cs
Last active May 2, 2024 10:01
Service-Locator c#
// README https://gist.github.com/DCFApixels/c0dd6ba4ee6d4fa641a158108d1b82c8#file-service-md
// inspired by https://github.com/Leopotam/globals/blob/master/src/Service.cs
// author: DCFApixels
// license: MIT
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;