예제 #1
0
        /// <summary>
        /// Decrease the amount of blocks (in general and of particular type) this player has built
        /// </summary>
        public void DecreaseBlocksBuilt(string type, MyCubeGrid grid)
        {
            BlocksBuilt--;
            if (type != null)
            {
                if (BlockTypeBuilt.ContainsKey(type))
                {
                    BlockTypeBuilt[type]--;
                }
                else
                {
                    Debug.Fail("Trying to remove a block of type this player doesn't own.");
                }
            }

            if (grid != null)
            {
                if (BlocksBuiltByGrid.ContainsKey(grid))
                {
                    BlocksBuiltByGrid[grid]--;
                    if (BlocksBuiltByGrid[grid] == 0)
                    {
                        using (LockBlocksBuiltByGrid.AcquireExclusiveUsing())
                        {
                            BlocksBuiltByGrid.Remove(grid);
                        }
                    }
                }
                else
                {
                    Debug.Fail("Trying to remove a block in a grid this player doesn't own.");
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Increase the amount of blocks (in general and of particular type) this player has built
        /// </summary>
        public void IncreaseBlocksBuilt(string type, MyCubeGrid grid)
        {
            BlocksBuilt++;
            if (type != null)
            {
                if (BlockTypeBuilt.ContainsKey(type))
                {
                    BlockTypeBuilt[type]++;
                }
                else
                {
                    BlockTypeBuilt.Add(type, 1);
                }
            }

            if (grid != null)
            {
                if (BlocksBuiltByGrid.ContainsKey(grid))
                {
                    BlocksBuiltByGrid[grid]++;
                }
                else
                {
                    using (LockBlocksBuiltByGrid.AcquireExclusiveUsing())
                    {
                        BlocksBuiltByGrid.Add(grid, 1);
                    }
                }
            }
        }