Beispiel #1
0
        public object CreateMacrossObject(RName name, out MacrossDesc desc)
        {
            desc = GetDesc(name);
            //string dllName = "";
            //switch(EngineNS.CIPlatform.Instance.PlatformType)
            //{
            //    case EPlatformType.PLATFORM_WIN:
            //        dllName = "MacrossScript.dll";
            //        break;
            //    case EPlatformType.PLATFORM_DROID:
            //        dllName = "MacrossScript.Android.dll";
            //        break;
            //    default:
            //        throw new InvalidOperationException();
            //}
            var assembly = EngineNS.Rtti.RttiHelper.GetAnalyseAssembly(CIPlatform.Instance.CSType, "Game");
            var ret      = CreateMacrossObject(name, assembly);

            if (desc == null)
            {
                SetVersion(name, GetVersion(name));
                desc = GetDesc(name);
            }
            return(ret);
        }
Beispiel #2
0
        public static MacrossDesc SetVersion(RName name, int ver)
        {
            MacrossDesc desc;

            if (Describes.TryGetValue(name, out desc) == false)
            {
                desc = new MacrossDesc();
                Describes.Add(name, desc);
            }
            desc.Version = ver;
            return(desc);
        }
Beispiel #3
0
        public T Get(bool OnlyForGame = true)
        {
            if (OnlyForGame && CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor)
            {
                return(null);
            }
            if (Name == null || CEngine.Instance.MacrossDataManager.IsValid == false)
            {
                return(null);
            }
            if (mPtr == null || mDesc.Version != mVersion || CEngine.Instance.MacrossDataManager.CollectorVersion != mManagerVersion)
            {
                var newObj = (T)Macross.MacrossFactory.Instance.CreateMacrossObject(Name, out mDesc);
                Rtti.MetaClass.CopyData(mPtr, newObj);
#if DEBUG
                var saved = mPtr;
#endif
                mPtr = newObj;
                if (mPtr == null)
                {
                    Profiler.Log.WriteLine(Profiler.ELogTag.Error, "Macross", $"CreateMacrossObject Type={Name} failed, new a default object");
                    mPtr  = new T();
                    mDesc = new MacrossDesc();
                }
                else
                {
                    if (mPtr.GetType().IsSubclassOf(typeof(T)) == false)
                    {
                        Profiler.Log.WriteLine(Profiler.ELogTag.Error, "Macross", $"CreateMacrossObject Type={Name} is not match as {typeof(T).FullName}");
                        mPtr = null;
                        return(null);
                    }
                }
                mVersion        = mDesc.Version;
                mManagerVersion = CEngine.Instance.MacrossDataManager.CollectorVersion;
                if (mPtr.GetType().GetInterface(typeof(INewMacross).FullName) != null)
                {
                    var nmPtr = mPtr as INewMacross;
                    if (nmPtr != null)
                    {
                        nmPtr.OnNewMacross();
                    }
                }
            }
            return(mPtr);
        }