Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Asset.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.ComponentModel;
5 using System.IO;
6 using SiliconStudio.Core;
7 
8 namespace SiliconStudio.Assets
9 {
10  /// <summary>
11  /// Base class for Asset.
12  /// </summary>
13  [DataContract(Inherited = true)]
14  public abstract class Asset
15  {
16  private Guid id;
17 
18  /// <summary>
19  /// Locks the unique identifier for further changes.
20  /// </summary>
21  internal bool IsIdLocked;
22 
23  /// <summary>
24  /// Initializes a new instance of the <see cref="Asset"/> class.
25  /// </summary>
26  protected Asset()
27  {
28  Id = Guid.NewGuid();
29  Tags = new TagCollection();
30  }
31 
32  /// <summary>
33  /// Gets or sets the unique identifier of this asset.
34  /// </summary>
35  /// <value>The identifier.</value>
36  /// <exception cref="System.InvalidOperationException">Cannot change an Asset Object Id once it is locked</exception>
37  [DataMember(-2000)]
38  [Browsable(false)]
39  public Guid Id
40  {
41  get
42  {
43  return id;
44  }
45  set
46  {
47  if (value != id && IsIdLocked)
48  throw new InvalidOperationException("Cannot change an Asset Object Id once it is locked by a package");
49 
50  id = value;
51  }
52  }
53 
54  /// <summary>
55  /// Gets or sets the version number for this asset, used internally when migrating assets.
56  /// </summary>
57  /// <value>The version.</value>
58  [DataMember(-1000)]
59  [Browsable(false)]
60  [DefaultValue(0)]
61  public int SerializedVersion { get; set; }
62 
63  /// <summary>
64  /// Gets or sets the base.
65  /// </summary>
66  /// <value>The base.</value>
67  [DataMember("~Base"), DefaultValue(null)]
68  [Browsable(false)]
69  public AssetBase Base { get; set; }
70 
71  /// <summary>
72  /// Gets or sets the build order for this asset.
73  /// </summary>
74  /// <value>The build order.</value>
75  [DataMember(-980)]
76  [DefaultValue(0)]
77  [Browsable(false)]
78  public int BuildOrder { get; set; }
79 
80  /// <summary>
81  /// Gets the tags for this asset.
82  /// </summary>
83  /// <value>
84  /// The tags for this asset.
85  /// </value>
86  [DataMember(-900)]
87  [Browsable(false)]
88  public TagCollection Tags { get; private set; }
89 
90  /// <summary>
91  /// Sets the defaults values for this instance
92  /// </summary>
93  public virtual void SetDefaults()
94  {
95  }
96 
97  public override string ToString()
98  {
99  return Id.ToString();
100  }
101  }
102 }
virtual void SetDefaults()
Sets the defaults values for this instance
Definition: Asset.cs:93
Base class for Asset.
Definition: Asset.cs:14
An asset item part of a Package accessible through Package.Assets.
Definition: AssetBase.cs:16
Asset()
Initializes a new instance of the Asset class.
Definition: Asset.cs:26
override string ToString()
Definition: Asset.cs:97