当前位置: 首页>>代码示例>>C#>>正文


C# Engine.GetClass方法代码示例

本文整理汇总了C#中Engine.GetClass方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.GetClass方法的具体用法?C# Engine.GetClass怎么用?C# Engine.GetClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine的用法示例。


在下文中一共展示了Engine.GetClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Go

        private static void Go(Engine engine)
        {
            var missionDefinitionClass = engine.GetClass("WillowGame.MissionDefinition");
            if (missionDefinitionClass == null)
            {
                throw new InvalidOperationException();
            }

            using (var output = new StreamWriter("Missions.json", false, Encoding.Unicode))
            using (var writer = new JsonTextWriter(output))
            {
                writer.Indentation = 2;
                writer.IndentChar = ' ';
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();

                var missionDefinitions = engine.Objects
                    .Where(o => o.IsA(missionDefinitionClass) &&
                                o.GetName().StartsWith("Default__") ==
                                false)
                    .OrderBy(o => o.GetPath());
                foreach (dynamic missionDefinition in missionDefinitions)
                {
                    writer.WritePropertyName(missionDefinition.GetPath());
                    writer.WriteStartObject();

                    writer.WritePropertyName("number");
                    writer.WriteValue(missionDefinition.MissionNumber);

                    string missionName = missionDefinition.MissionName;
                    if (string.IsNullOrEmpty(missionName) == false)
                    {
                        writer.WritePropertyName("name");
                        writer.WriteValue(missionName);
                    }

                    string missionDescription = missionDefinition.MissionDescription;
                    if (string.IsNullOrEmpty(missionDescription) == false)
                    {
                        writer.WritePropertyName("description");
                        writer.WriteValue(missionDescription);
                    }

                    // TODO: objective info

                    writer.WriteEndObject();
                }

                writer.WriteEndObject();
                writer.Flush();
            }
        }
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:53,代码来源:Program.cs

示例2: Read

        internal override object Read(Engine engine, IntPtr objectAddress)
        {
            var classAddress = engine.ReadPointer(objectAddress + this.Offset);
            if (classAddress == IntPtr.Zero)
            {
                return (UnrealObject)null;
            }

            var uclass = engine.GetClass(classAddress);
            if (uclass == null)
            {
                throw new InvalidOperationException();
            }
            return uclass;
        }
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:15,代码来源:ClassField.cs

示例3: Read

        internal override object Read(Engine engine, IntPtr objectAddress)
        {
            if (this.ArrayCount != 1)
            {
                throw new NotSupportedException();
            }

            if (this.Inner is ByteField)
            {
                var array = engine.Runtime.ReadStructure<UnrealNatives.Array>(objectAddress + this.Offset);
                if (array.Data == IntPtr.Zero)
                {
                    return new byte[0];
                }

                return engine.Runtime.ReadBytes(array.Data, array.Count);
            }

            if (this.Inner is StructField)
            {
                var array = engine.Runtime.ReadStructure<UnrealNatives.Array>(objectAddress + this.Offset);
                if (array.Data == IntPtr.Zero)
                {
                    return new UnrealObject[0];
                }

                var structField = (StructField)this.Inner;

                var item = array.Data;
                var items = new object[array.Count];
                for (int i = 0; i < array.Count; i++)
                {
                    items[i] = structField.Read(engine, item);
                    item += structField.Size;
                }
                return items;
            }

            if (this.Inner is ObjectField)
            {
                var array = engine.ReadPointerArray(objectAddress + this.Offset);

                return array.Select(i =>
                {
                    if (i == IntPtr.Zero)
                    {
                        return null;
                    }

                    var obj = engine.GetObject(i);
                    if (obj == null)
                    {
                        throw new InvalidOperationException();
                    }
                    return obj;
                }).ToArray();
            }

            if (this.Inner is ComponentField)
            {
                return "*** COMPONENT NOT IMPLEMENTED ***";
            }

            if (this.Inner is ClassField)
            {
                var array = engine.ReadPointerArray(objectAddress + this.Offset);

                return array.Select(i =>
                {
                    if (i == IntPtr.Zero)
                    {
                        return null;
                    }

                    var obj = engine.GetClass(i);
                    if (obj == null)
                    {
                        throw new InvalidOperationException();
                    }
                    return obj;
                }).ToArray();
            }

            if (this.Inner is StrField)
            {
                return engine.ReadStringArray(objectAddress + this.Offset);
            }

            if (this.Inner is NameField)
            {
                return engine.ReadNameArray(objectAddress + this.Offset);
            }

            throw new NotSupportedException();
        }
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:95,代码来源:ArrayField.cs


注:本文中的Engine.GetClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。