public Data(PlayerAsset playerAsset) { Guid = playerAsset.Guid; Type = playerAsset.Type; Author = playerAsset.Author; UtcCreationTime = playerAsset.UtcCreationTime; AssetData = playerAsset.Serialize(); }
public static Type AssetTypeFromEnum(PlayerAssetType playerAssetType) { switch (playerAssetType) { default: case PlayerAssetType.Invalid: throw new ArgumentOutOfRangeException(nameof(playerAssetType)); case PlayerAssetType.Doodle: return(typeof(PlayerDoodleAsset)); } }
/// <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); }
protected PlayerAsset(Guid guid, PlayerAssetType type) { Guid = guid; Type = type; }
/// <summary> /// Create a brand new asset /// </summary> public PlayerAsset CreateAsset(PlayerAssetType type) { return(CreateAsset(AssetTypeFromEnum(type))); }