Skip to content

Instantly share code, notes, and snippets.

@DCFApixels
DCFApixels / DesignMode.cs
Last active June 16, 2024 16:55
A mini-script to simplify the work of designers in a project on Unity.
using System.Runtime.CompilerServices;
using UnityEngine;
namespace DCFApixels
{
public static class DesignMode
{
internal static bool _isOn = false;
public static bool ON
{
@DCFApixels
DCFApixels / JsonIterator.cs
Last active June 5, 2024 05:26
Iterator for parsing json strings. iterated by {[]} characters, keys and values.
//string json = /* ... */;
//fixed(char* ptr = json)
//{
// JsonIterator it = new JsonIterator(ptr, json.length);
// while(it.Next())
// {
// JsonNode node = it.Current;
// }
//}
using static DCFApixels.DragonECS.EcsOneFrameComponentConsts;
namespace DCFApixels.DragonECS
{
[MetaTags(MetaTags.HIDDEN)]
[MetaColor(MetaColor.Grey)]
public class DeleteOneFrameComponentSystem<TComponent> : IEcsRun, IEcsInject<EcsWorld>
where TComponent : struct, IEcsComponent
{
private sealed class Aspect : EcsAspect
@DCFApixels
DCFApixels / layout.wlt
Created January 7, 2024 13:53
My Unity Editor Layout
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 52
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
@DCFApixels
DCFApixels / BitsUtility.cs
Last active January 5, 2024 13:28
C# Utility methods for working with bits.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using static DCFApixels.BitsUtility;
namespace DCFApixels
{
public unsafe static class BitsUtility
@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;
@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;

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;

Семантика

version.major.minor

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

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

  • version: глобальные обновления. После увеличения сбрасываются major и minor;
  • major: увеличивается при больших обновлениях, нарушающих обратную совместимость. После увеличения сбрасываются minor;
  • minor: увеличивается при небольших обновлениях или багфиксах, не нарушающих обратную совместимость;
@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;