42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace RPGCore.GlobalModules.ProfileManagerGlobalModule
|
|
{
|
|
[Serializable]
|
|
public sealed class Profile<T> : Profile where T : class
|
|
{
|
|
public new T data
|
|
{
|
|
set => base.data = value;
|
|
get => base.data as T;
|
|
}
|
|
|
|
public Profile() : this(Environment.MachineName)
|
|
{
|
|
}
|
|
|
|
public Profile(string profileName)
|
|
{
|
|
name = profileName;
|
|
}
|
|
}
|
|
|
|
public abstract class Profile
|
|
{
|
|
private protected Profile()
|
|
{
|
|
|
|
}
|
|
|
|
public readonly string guid = Guid.NewGuid().ToString();
|
|
public readonly string version = Application.version;
|
|
public string name;
|
|
public object data;
|
|
|
|
public static bool operator ==(Profile obj1, Profile obj2) => obj1?.guid == obj2?.guid;
|
|
public static bool operator !=(Profile obj1, Profile obj2) => !(obj1 == obj2);
|
|
public override bool Equals(object obj) => obj is Profile other && guid == other.guid;
|
|
public override int GetHashCode() => guid.GetHashCode();
|
|
}
|
|
} |