Skip to content

Instantly share code, notes, and snippets.

View dmitryzenevich's full-sized avatar

Dmitry Zenevich dmitryzenevich

View GitHub Profile
exec
[JetBrains.Annotations.UsedImplicitly]
public sealed class $name$System : Entitas.IExecuteSystem
{
private readonly IGroup<$Context$Entity> _$group$;
public $name$System($Context$Context $context$)
{
_$group$ = $context$.GetGroup($Context$Matcher
using System;
using System.Collections.Generic;
using System.Linq;
using VContainer;
using VContainer.Unity;
namespace Extensions
{
public static class VContainerExtensions
{
@dmitryzenevich
dmitryzenevich / gist:5cd79d4dc991ef6a8e6fc42a41cf1449
Created September 16, 2024 08:17
Entitas buffered entities extension in Unity
public static class Ex
{
public static IEnumerable<TEntity> GetEntitiesBuffered<TEntity>(this IGroup<TEntity> group) where TEntity : class, IEntity
{
using var _ = UnityEngine.Pool.ListPool<TEntity>.Get(out List<TEntity> buffer);
foreach (var entity in group.GetEntities(buffer))
yield return entity;
}
}
public static class LinqExtensions
{
public static IEnumerable<IEnumerable<T>> TakeCount<T>(this IEnumerable<T> source, int count)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), $"{nameof(count)} must be 0 or greater");
if (count > source.Count())
using UnityEngine;
public enum Shape
{
Rock,
Paper,
Scissors
}
public class TuplePatterns : MonoBehaviour