123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #region File Description
- //-----------------------------------------------------------------------------
- // WeightedContentEntry.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- using System;
- using Microsoft.Xna.Framework.Content;
- #endregion
- namespace RolePlayingGameData
- {
- /// <summary>
- /// A description of a piece of content, quantity and weight for various purposes.
- /// </summary>
- public class WeightedContentEntry<T> : ContentEntry<T> where T : ContentObject
- {
- /// <summary>
- /// The weight of this content within the group, for statistical distribution.
- /// </summary>
- private int weight;
- /// <summary>
- /// The weight of this content within the group, for statistical distribution.
- /// </summary>
- public int Weight
- {
- get { return weight; }
- set { weight = value; }
- }
- #region Content Type Reader
- /// <summary>
- /// Reads a WeightedContentEntry object from the content pipeline.
- /// </summary>
- public class WeightedContentEntryReader :
- ContentTypeReader<WeightedContentEntry<T>>
- {
- /// <summary>
- /// Reads a WeightedContentEntry object from the content pipeline.
- /// </summary>
- protected override WeightedContentEntry<T> Read(ContentReader input,
- WeightedContentEntry<T> existingInstance)
- {
- WeightedContentEntry<T> entry = existingInstance;
- if (entry == null)
- {
- entry = new WeightedContentEntry<T>();
- }
- input.ReadRawObject<ContentEntry<T>>(entry as ContentEntry<T>);
- entry.Weight = input.ReadInt32();
- return entry;
- }
- }
- #endregion
- }
- }
|