public static EntityAction <TComponent> Create(World world) { var instance = PoolClass <EntityAction <TComponent> > .Spawn(); world.RegisterEntityAction(instance); return(instance); }
public static TState CreateState <TState>() where TState : class, IStateBase, new() { var state = PoolClass <TState> .Spawn(); state.entityId = default; state.tick = default; return(state); }
public void Copy(Node from, ref Node to) { if (to == null) { to = PoolClass <GridNode> .Spawn(); } to.CopyFrom(from); }
public virtual T AddNode <T>() where T : Node, new() { var node = PoolClass <T> .Spawn(); node.graph = this; node.index = this.nodes.Count; this.nodes.Add(node); return(node); }
public static void CreateWorld <TState>(ref World <TState> worldRef, float tickTime, int forcedWorldId = 0) where TState : class, IState <TState>, new() { if (worldRef != null) { WorldUtilities.ReleaseWorld(ref worldRef); } worldRef = PoolClass <World <TState> > .Spawn(); worldRef.SetId(forcedWorldId); ((IWorldBase)worldRef).SetTickTime(tickTime); Worlds <TState> .Register(worldRef); }
/// <summary> /// Initializes the contents of the stack from an existing collection. /// </summary> /// <param name="collection">A collection from which to copy elements.</param> private void InitializeFromCollection(IEnumerable <T> collection) { // We just copy the contents of the collection to our stack. Node lastNode = null; foreach (T element in collection) { Node newNode = (this.usePool == true ? PoolClass <Node> .Spawn() : new Node()); newNode.m_value = element; newNode.m_next = lastNode; lastNode = newNode; } m_head = lastNode; }
public static string UnpackDirect(Packer packer) { var length = Int32Serializer.UnpackDirect(packer); var sb = PoolClass <System.Text.StringBuilder> .Spawn(); sb.Clear(); sb.Capacity = length; for (int i = 0; i < length; ++i) { sb.Append(CharSerializer.UnpackDirect(packer)); } var res = sb.ToString(); PoolClass <System.Text.StringBuilder> .Recycle(ref sb); return(res); }
/// <summary> /// Inserts an object at the top of the <see cref="ConcurrentStack{T}"/>. /// </summary> /// <param name="item">The object to push onto the <see cref="ConcurrentStack{T}"/>. The value can be /// a null reference (Nothing in Visual Basic) for reference types. /// </param> public void Push(T item) { // Pushes a node onto the front of the stack thread-safely. Internally, this simply // swaps the current head pointer using a (thread safe) CAS operation to accomplish // lock freedom. If the CAS fails, we add some back off to statistically decrease // contention at the head, and then go back around and retry. Node newNode = (this.usePool == true ? PoolClass <Node> .Spawn() : new Node()); newNode.m_value = item; newNode.m_next = m_head; if (Interlocked.CompareExchange(ref m_head, newNode, newNode.m_next) == newNode.m_next) { return; } // If we failed, go to the slow path and loop around until we succeed. PushCore(newNode, newNode); }
public static void CreateWorld <TState>(ref World worldRef, float tickTime, int forcedWorldId = 0, uint seed = 1u) where TState : State, new() { if (seed <= 0u) { seed = 1u; } if (worldRef != null) { WorldUtilities.ReleaseWorld <TState>(ref worldRef); } worldRef = PoolClass <World> .Spawn(); worldRef.SetId(forcedWorldId); var worldInt = worldRef; worldInt.SetSeed(seed); worldInt.SetTickTime(tickTime); Worlds.Register(worldRef); }
public IViewsProvider <TEntity> Create() { return(PoolClass <UnityGameObjectProvider <TEntity> > .Spawn()); }
public IViewsProvider Create() { return(PoolClass <NoViewProvider> .Spawn()); }
public override State CreateState() { return(PoolClass <RectState> .Spawn()); }
public IViewsProvider <TEntity> Create() { return(PoolClass <NoViewProvider <TEntity> > .Spawn()); }