Exemplo n.º 1
0
        public virtual void RemoveGameAsset(AbstractGameAsset asset)
        {
            if (asset.Type != ChosenGameAssetTemplate.Type)
            {
                throw new Exception(
                          string.Format(
                              "Tried to remove game asset {0} from a buy point which has chosen {1}",
                              asset, ChosenGameAssetTemplate.Type));
            }

            lock (GameAssets)
            {
                if (GameAssets.ContainsKey(asset.Uuid))
                {
                    GameAssets.Remove(asset.Uuid);

                    switch (asset.Type)
                    {
                    case AbstractGameAssetType.Crops:
                        Cropss.Remove((Crops)asset);
                        break;

                    case AbstractGameAssetType.Houses:
                        Housess.Remove((Houses)asset);
                        break;

                    case AbstractGameAssetType.Factory:
                        Factories.Remove((Factory)asset);
                        break;

                    default:
                        throw new Exception(string.Format("Unrecognized asset {0}", asset));
                    }
                }
                else
                {
                    m_log.WarnFormat(
                        "[WATER WARS]: Request to remove asset {0} but it wasn't in buy point {1}", asset, this);
                }

                if (GameAssets.Count == 0)
                {
                    ChosenGameAssetTemplate = AbstractGameAsset.None;
                }

                lock (Game.GameAssets)
                    Game.GameAssets.Remove(asset.Uuid);
            }
        }