Azmyth.Assets.AssetStore.CreateAsset C# (CSharp) 메소드

CreateAsset() 공개 메소드

public CreateAsset ( Type assetType ) : VectorID
assetType System.Type
리턴 VectorID
        public virtual VectorID CreateAsset(Type assetType)
        {
            long vectorID;
            long assetID;
            Asset asset;

            asset = null;

            VectorID id = null;

            if(assetType.IsSubclassOf(typeof(Asset)))
            {
                if(!_typeIndexList.ContainsKey(assetType))
                {
                    _typeIndexList.Add(assetType, _maxIndex);

                    while (_currentIDList.ContainsKey(_maxIndex))
                    {
                        _maxIndex++;
                    }
                }

                vectorID = _typeIndexList[assetType];

                if(!_currentIDList.ContainsKey(vectorID))
                {
                    _currentIDList.Add(vectorID, 1);
                }

                try
                {
                     assetID = _currentIDList[vectorID];
                    id = new VectorID(vectorID, assetID);
                    _currentIDList[vectorID]++;
                    asset = Activator.CreateInstance(assetType, id) as Asset;
                    _assetList.Add(id, asset);
                }
                catch
                {
                    _currentIDList[vectorID]--;
                    throw new InvalidCastException("unable to create inststance of " + assetType.FullName);
                }

            }
            else
            {
                throw new InvalidCastException("entityType does not derive from Entity.");
            }

            return id;
        }

Same methods

AssetStore::CreateAsset ( long vector ) : VectorID