Exemplo n.º 1
0
        public override void ApplyAfterConnections(Graph graph)
        {
            var visited = PoolHashSet <Node> .Spawn();

            foreach (var pos in this.bounds.allPositionsWithin)
            {
                var tile = this.tilemap.GetTile(pos);
                for (int i = 0; i < this.items.Length; ++i)
                {
                    var item = this.items[i];
                    if (item.requiredTile == tile)
                    {
                        var worldPos = this.tilemap.CellToWorld(pos);
                        var node     = graph.GetNearest(this.GetPosition(worldPos));
                        if (visited.Contains(node) == false)
                        {
                            visited.Add(node);
                            if (item.modifyWalkability == true)
                            {
                                node.walkable = item.walkable;
                            }
                        }
                    }
                }
            }
            PoolHashSet <Node> .Recycle(ref visited);
        }
Exemplo n.º 2
0
 partial void BeginRestoreEntitiesPlugin5()
 {
     if (this.debugSettings.createGameObjectsRepresentation == true)
     {
         this.used = PoolHashSet <Entity> .Spawn(100);
     }
 }
Exemplo n.º 3
0
        void IModuleBase.OnConstruct()
        {
            this.localOrderIndex = 0;
            this.rpcId           = 0;
            this.ping            = 0d;

            this.registry = PoolDictionary <int, System.Reflection.MethodInfo> .Spawn(100);

            this.objectToKey = PoolDictionary <object, Key> .Spawn(100);

            this.keyToObjects = PoolDictionary <long, object> .Spawn(100);

            this.runLocalOnly = PoolHashSet <int> .Spawn(100);

            this.currentObjectRegistryId = 1000;

            this.statesHistoryModule = this.world.GetModule <StatesHistory.IStatesHistoryModule <TState> >();
            this.statesHistoryModule.SetEventRunner(this);

            this.world.SetNetworkModule(this);

            this.RegisterRPC(NetworkModule <TState> .CANCEL_EVENT_RPC_ID, new System.Action <byte[]>(this.CancelEvent_RPC).Method);
            this.RegisterRPC(NetworkModule <TState> .PING_RPC_ID, new System.Action <double, bool>(this.Ping_RPC).Method);
            this.RegisterRPC(NetworkModule <TState> .SYNC_RPC_ID, new System.Action <Tick, int>(this.Sync_RPC).Method);
            this.RegisterObject(this, -1, -1);

            this.OnInitialize();
        }
Exemplo n.º 4
0
        void IModuleBase.OnDeconstruct()
        {
            this.OnDeInitialize();

            this.replayMode = default;
            this.asyncMode  = default;

            this.localOrderIndex = default;
            this.rpcId           = default;
            this.ping            = default;

            this.pingTime     = default;
            this.syncTime     = default;
            this.syncedTick   = default;
            this.syncHash     = default;
            this.syncTickSent = default;
            this.revertingTo  = default;
            this.isReverting  = default;

            this.currentObjectRegistryId = default;

            this.world.SetNetworkModule(null);
            this.statesHistoryModule = null;

            this.UnRegisterObject(this, -1);
            this.currentObjectRegistryId = 1000;

            PoolHashSet <int> .Recycle(ref this.runLocalOnly);

            PoolDictionary <long, object> .Recycle(ref this.keyToObjects);

            PoolDictionary <object, Key> .Recycle(ref this.objectToKey);

            PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry);
        }
Exemplo n.º 5
0
        void IModuleBase.OnDeconstruct()
        {
            this.OnDeInitialize();

            this.UnRegisterObject(this, -1);

            PoolHashSet <int> .Recycle(ref this.runLocalOnly);

            PoolDictionary <long, object> .Recycle(ref this.keyToObjects);

            PoolDictionary <object, Key> .Recycle(ref this.objectToKey);

            PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry);
        }
Exemplo n.º 6
0
        void IModuleBase.OnConstruct()
        {
            this.isRequestsDirty = false;
            this.list            = PoolArray <Views> .Spawn(ViewsModule.VIEWS_CAPACITY);

            this.rendering = PoolHashSet <ViewInfo> .Spawn(ViewsModule.VIEWS_CAPACITY);

            this.registryPrefabToId = PoolDictionary <IView, ViewId> .Spawn(ViewsModule.REGISTRY_CAPACITY);

            this.registryIdToPrefab = PoolDictionary <ViewId, IView> .Spawn(ViewsModule.REGISTRY_CAPACITY);

            this.registryPrefabToProvider = PoolDictionary <ViewId, IViewsProvider> .Spawn(ViewsModule.REGISTRY_PROVIDERS_CAPACITY);

            this.registryPrefabToProviderInitializer = PoolDictionary <ViewId, IViewsProviderInitializerBase> .Spawn(ViewsModule.REGISTRY_PROVIDERS_CAPACITY);
        }
        public override void ApplyAfterConnections(Graph graph)
        {
            var visited = PoolHashSet <Node> .Spawn();

            {
                var gridGraph = (GridGraph)graph;
                var result    = PoolListCopyable <Node> .Spawn(1);

                graph.GetNodesInBounds(result, new Bounds(graph.graphCenter, (Vector3)gridGraph.size * gridGraph.nodeSize), Constraint.Empty);
                {
                    foreach (var node in result)
                    {
                        var worldPos = node.worldPosition;
                        var cellPos  = this.tilemap.layoutGrid.WorldToCell(worldPos);
                        var tile     = this.tilemap.GetTile(cellPos);
                        for (int i = 0; i < this.items.Length; ++i)
                        {
                            var item = this.items[i];
                            if (item.modifyWalkability == false)
                            {
                                continue;
                            }

                            if (item.requiredTile == null || item.requiredTile == tile)
                            {
                                if (item.checkSprite == true)
                                {
                                    var idx = System.Array.IndexOf(item.spriteOneOf, this.tilemap.GetSprite(cellPos));
                                    if (idx < 0)
                                    {
                                        continue;
                                    }
                                }

                                if (visited.Contains(node) == false)
                                {
                                    visited.Add(node);
                                    node.walkable = item.walkable;
                                }
                            }
                        }
                    }
                }
                PoolListCopyable <Node> .Recycle(ref result);
            }
            PoolHashSet <Node> .Recycle(ref visited);
        }
Exemplo n.º 8
0
        public override void ApplyAfterConnections(Graph graph)
        {
            var halfOffset = new Vector3(this.tilemap.cellSize.x, 0f, this.tilemap.cellSize.z) * 0.5f;

            var visited = PoolHashSet <Node> .Spawn();

            foreach (var pos in this.bounds.allPositionsWithin)
            {
                var worldPos = pos + halfOffset;
                var cellPos  = this.tilemap.layoutGrid.WorldToCell(worldPos);
                var tile     = this.tilemap.GetTile(cellPos);
                for (int i = 0; i < this.items.Length; ++i)
                {
                    var item = this.items[i];
                    if (item.modifyWalkability == false)
                    {
                        continue;
                    }

                    if (item.requiredTile == null || item.requiredTile == tile)
                    {
                        if (item.checkSprite == true)
                        {
                            var idx = System.Array.IndexOf(item.spriteOneOf, this.tilemap.GetSprite(cellPos));
                            if (idx < 0)
                            {
                                continue;
                            }
                        }

                        var result = PoolListCopyable <Node> .Spawn(1);

                        graph.GetNodesInBounds(result, new Bounds(worldPos, this.tilemap.cellSize * 0.5f));
                        foreach (var node in result)
                        {
                            if (visited.Contains(node) == false)
                            {
                                visited.Add(node);
                                node.walkable = item.walkable;
                            }
                        }
                        PoolListCopyable <Node> .Recycle(ref result);
                    }
                }
            }
            PoolHashSet <Node> .Recycle(ref visited);
        }
Exemplo n.º 9
0
        public override void ApplyBeforeConnections(Graph graph)
        {
            var visited = PoolHashSet <Node> .Spawn();

            foreach (var pos in this.bounds.allPositionsWithin)
            {
                var tile = this.tilemap.GetTile(pos);
                for (int i = 0; i < this.items.Length; ++i)
                {
                    var item = this.items[i];
                    if (item.requiredTile == tile)
                    {
                        var worldPos = this.tilemap.CellToWorld(pos);
                        var result   = PoolList <Node> .Spawn(1);

                        graph.GetNodesInBounds(result, new Bounds(worldPos + new Vector3(this.tilemap.cellSize.x, 0f, this.tilemap.cellSize.z) * 0.5f, this.tilemap.cellSize));
                        foreach (var node in result)
                        {
                            if (visited.Contains(node) == false)
                            {
                                visited.Add(node);
                                var dt = item.penaltyDelta;
                                if (dt < 0)
                                {
                                    node.penalty -= (uint)(-item.penaltyDelta);
                                }
                                else
                                {
                                    node.penalty += (uint)item.penaltyDelta;
                                }

                                node.tag = item.tag;
                            }
                        }
                        PoolList <Node> .Recycle(ref result);
                    }
                }
            }
            PoolHashSet <Node> .Recycle(ref visited);
        }
Exemplo n.º 10
0
        void IModuleBase.OnDeconstruct()
        {
            this.isRequestsDirty = true;
            this.UpdateRequests();

            var temp = PoolList <IView> .Spawn(this.registryPrefabToId.Count);

            foreach (var prefab in this.registryIdToPrefab)
            {
                temp.Add(prefab.Value);
            }

            foreach (var prefab in temp)
            {
                this.UnRegisterViewSource(prefab);
            }
            PoolList <IView> .Recycle(ref temp);

            PoolDictionary <ViewId, IViewsProvider> .Recycle(ref this.registryPrefabToProvider);

            PoolDictionary <ViewId, IViewsProviderInitializerBase> .Recycle(ref this.registryPrefabToProviderInitializer);

            PoolDictionary <ViewId, IView> .Recycle(ref this.registryIdToPrefab);

            PoolDictionary <IView, ViewId> .Recycle(ref this.registryPrefabToId);

            PoolHashSet <ViewInfo> .Recycle(ref this.rendering);

            for (int i = 0; i < this.list.Length; ++i)
            {
                var views = this.list.arr[i];
                if (views.otherViews != null)
                {
                    PoolList <IView> .Recycle(views.otherViews);
                }
            }
            //PoolDictionary<int, List<IView<TEntity>>>.Recycle(ref this.list);
            PoolArray <Views> .Recycle(ref this.list);
        }
Exemplo n.º 11
0
        partial void EndRestoreEntitiesPlugin5()
        {
            if (this.debugSettings.createGameObjectsRepresentation == true)
            {
                var unused = PoolListCopyable <Entity> .Spawn(100);

                foreach (var entKv in this.debugEntities)
                {
                    if (this.used.Contains(entKv.Key) == false)
                    {
                        unused.Add(entKv.Key);
                    }
                }

                for (int i = 0; i < unused.Count; ++i)
                {
                    this.DestroyEntityPlugin5(unused[i]);
                }

                PoolListCopyable <Entity> .Recycle(ref unused);

                PoolHashSet <Entity> .Recycle(ref this.used);
            }
        }
Exemplo n.º 12
0
        public override void ApplyBeforeConnections(Graph graph)
        {
            var halfOffset = new Vector3(this.tilemap.cellSize.x, 0f, this.tilemap.cellSize.z) * 0.5f;

            var visited = PoolHashSet <Node> .Spawn();

            foreach (var pos in this.bounds.allPositionsWithin)
            {
                var worldPos = pos + halfOffset;
                var cellPos  = this.tilemap.layoutGrid.WorldToCell(worldPos);
                var tile     = this.tilemap.GetTile(cellPos);
                for (int i = 0; i < this.items.Length; ++i)
                {
                    var item = this.items[i];
                    if (item.requiredTile == tile)
                    {
                        var result = PoolList <Node> .Spawn(1);

                        graph.GetNodesInBounds(result, new Bounds(worldPos, this.tilemap.cellSize * 0.5f));
                        foreach (var node in result)
                        {
                            if (visited.Contains(node) == false)
                            {
                                visited.Add(node);

                                node.penalty += item.penaltyDelta;
                                node.height  += item.heightDelta;
                                node.tag      = item.tag;
                            }
                        }
                        PoolList <Node> .Recycle(ref result);
                    }
                }
            }
            PoolHashSet <Node> .Recycle(ref visited);
        }