/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2018-10-31
 * 时间: 13:32
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
#if Server
using System;

namespace GameData
{
	/// <summary>
	/// 模块单元 所有字段只读
	/// </summary>
	public class ModuleUtile : ServerNode{
		
		/// <summary>
		/// 模块版本_大的版本
		/// </summary>
		public int ver;
		
		/// <summary>
		/// 模块名称
		/// </summary>
		public string name;
		
        /// <summary>
        /// 唯一id 重启将不一样
        /// </summary>
        public string onlyId;

		public ModuleUtile(){}
		
		/// <summary>
		/// 构造器
		/// </summary>
		/// <param name="id">模块id</param>
		/// <param name="nodeNum">模块集群的中的id</param>
		/// <param name="name">模块名称</param>
		/// <param name="ver">模块版本</param>
		public ModuleUtile(byte id,byte nodeNum,string name,int ver){
			this.id = id;
			this.nodeNum = nodeNum;
			this.name = name;
			this.ver = ver;
            this.onlyId = Guid.NewGuid().ToString();
		}
		
        /// <summary>
		/// 构造器
		/// </summary>
		/// <param name="id">模块id</param>
		/// <param name="nodeNum">模块集群的中的id</param>
		/// <param name="name">模块名称</param>
		/// <param name="ver">模块版本</param>
		/// <param name="moduleSty">模块的类型</param>
		private ModuleUtile(byte id,byte nodeNum,string name,int ver,string onlyId){
			this.id = id;
			this.nodeNum = nodeNum;
			this.name = name;
			this.ver = ver;
            this.onlyId = onlyId;
		}
        
		public override string ToString()
		{
			return string.Format("[ModuleUtile Id={0}, nodeNum={1}, Ver={2}, Name={3}]", id, nodeNum, ver, name);
		}

		
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
        
		/// <summary>
		/// json字符串转ModuleUtile
		/// </summary>
		/// <param name="moduleTag"></param>
		/// <returns></returns>
		public static ModuleUtile Parse(string moduleTag){
			if(string.IsNullOrEmpty(moduleTag))
				return null;
			return JsonPack.GetData<ModuleUtile>(moduleTag);
		}
		
	}
}
#endif
