示例#1
0
 public Data(PlayerAsset playerAsset)
 {
     Guid            = playerAsset.Guid;
     Type            = playerAsset.Type;
     Author          = playerAsset.Author;
     UtcCreationTime = playerAsset.UtcCreationTime;
     AssetData       = playerAsset.Serialize();
 }
示例#2
0
    public static Type AssetTypeFromEnum(PlayerAssetType playerAssetType)
    {
        switch (playerAssetType)
        {
        default:
        case PlayerAssetType.Invalid:
            throw new ArgumentOutOfRangeException(nameof(playerAssetType));

        case PlayerAssetType.Doodle:
            return(typeof(PlayerDoodleAsset));
        }
    }
示例#3
0
    /// <summary>
    /// Create an asset using an existing meta data set (Can be useful when an online player shares an asset he/she has created before)
    /// </summary>
    protected PlayerAsset CreateAssetInternal(Guid guid, PlayerAssetType assetType)
    {
        if (assetType == PlayerAssetType.Invalid)
        {
            throw new Exception($"Unsupported asset type.");
        }

        PlayerAsset asset = (PlayerAsset)Activator.CreateInstance(AssetTypeFromEnum(assetType), guid);

        _assetMap.Add(asset.Guid, asset);

        AssetCreated?.InvokeCatchException(asset);

        return(asset);
    }
示例#4
0
 protected PlayerAsset(Guid guid, PlayerAssetType type)
 {
     Guid = guid;
     Type = type;
 }
示例#5
0
 /// <summary>
 /// Create a brand new asset
 /// </summary>
 public PlayerAsset CreateAsset(PlayerAssetType type)
 {
     return(CreateAsset(AssetTypeFromEnum(type)));
 }