/*
* RefinerBuilding.cs
* Authors: Bradley Blankenship
* Copyright (c) 2007-2008 Cornell University
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content;
namespace BuildingSharedContent
{
///
/// Takes resouces that are gathered by Gatherer buildings and
/// refines them into their final form for use. They are then
/// sent to the closest, non-full storage building.
///
public class RefinerBuilding : Building
{
#region Fields
// The string of the resources that are refinable and their rates
string mRefinableString;
// The map of resources and rates for refining them
Dictionary mRefinableResources;
#endregion
#region Properties
///
/// Allows access to the string value for the initialization
/// of the possible resources that can be refined.
///
public string RefinableResources
{
get { return mRefinableString; }
set { mRefinableString = value; }
}
///
/// Allows access to use the dictionary of refinable resources and the
/// rates for refining each.
///
[ContentSerializerIgnore]
public Dictionary ResourcesAndRates
{
get { return mRefinableResources; }
}
#endregion
#region Constructs
///
/// Base constructor
///
public RefinerBuilding()
{
// Initialize the gatherable resource / rate map
mRefinableResources = new Dictionary();
}
#endregion
#region Initialization
///
/// Initialize the building.
///
public override void Initialize()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
///
/// The reader for reading in resource refining buildings from file.
///
public class RefinerBuildingContentReader : ContentTypeReader
{
///
/// Reads in the given resource refining building.
///
/// The content reader.
/// The existing instance, if needed.
/// The resource refining building
protected override RefinerBuilding Read(
ContentReader input,
RefinerBuilding existingInstance)
{
// The return value
RefinerBuilding retVal;
// If the existing instance isn't null
if (existingInstance != null)
{
// Make the retVal us
retVal = existingInstance;
}
else
{
// Make a new one
retVal = new RefinerBuilding();
// Get the basic building values
retVal.Name = input.ReadString();
retVal.ModelName = input.ReadString();
retVal.FootPrintSize = input.ReadInt32();
retVal.Costs = input.ReadString();
retVal.RequiredUnskilledWorkers = input.ReadInt32();
retVal.RequiredSkilledWorkers = input.ReadInt32();
retVal.Upkeep = input.ReadString();
retVal.Upgrade = input.ReadString();
// Get the resource gathering specific values
retVal.RefinableResources = input.ReadString();
}
// Return the new resource gathering building
return retVal;
}
}
}