Ejemplo n.º 1
0
 // Copy existing data.
 protected GamePropertyData(GamePropertyData <T> data)
 {
     if (data != null)
     {
         _value         = data.Value;
         _hasLocalValue = data.HasLocalValue;
         Changing       = data.Changing;
         Changed        = data.Changed;
     }
 }
Ejemplo n.º 2
0
        private GamePropertyData <T> GetOrCreateLocalData()
        {
            IGamePropertyData    untypedData = Owner.PropertyData.Get(_metadata.Id);
            GamePropertyData <T> data;

            if (untypedData != null)
            {
                // data found!
                data = (GamePropertyData <T>)untypedData;
            }
            else
            {
                // No data found! Create new data.
                data = new GamePropertyData <T>();
                Owner.PropertyData.Set(_metadata.Id, data);
            }
            return(data);
        }
        public void Add <T>(int id)
        {
            if (Owner.PropertyData.Get(id) != null)
            {
                return;
            }

            if (id < 0 || id >= GameObject.PropertyMetadata.Count)
            {
                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Unknown ID. No game object property with the ID '{0}' and type '{1}' was defined. "
                    + "Game object properties must be defined using GameObject.CreateProperty() before they can be used.",
                    id,
                    typeof(T).FullName);
                throw new ArgumentException(message, "id");
            }

            var data = new GamePropertyData <T>();

            Owner.PropertyData.Set(id, data);
        }
        public AnimatableGamePropertyData(GameObject owner, GamePropertyMetadata <T> metadata, GamePropertyData <T> data)
            : base(data)
        {
            Debug.Assert(owner != null, "owner must not be null.");
            Debug.Assert(metadata != null, "metadata must not be null.");

            _owner    = owner;
            _metadata = metadata;
        }