예제 #1
0
        protected PathfindingNode(int idx, float x, float y, IMEPackage p, PathingGraphEditor grapheditor)
        {
            try
            {
                pcc              = p;
                g                = grapheditor;
                index            = idx;
                export           = pcc.getUExport(index);
                comment          = new SText(GetComment(), commentColor, false);
                comment.X        = 0;
                comment.Y        = 65 - comment.Height;
                comment.Pickable = false;

                var volsArray = export.GetProperty <ArrayProperty <StructProperty> >("Volumes");
                if (volsArray != null)
                {
                    foreach (var volumestruct in volsArray)
                    {
                        Volumes.Add(new Volume(volumestruct));
                    }
                }

                this.AddChild(comment);
                this.Pickable = true;
            }
            catch (Exception e)
            {
                Debugger.Break();
            }

            Bounds = new RectangleF(0, 0, 50, 50);
            SetShape();
            TranslateBy(x, y);
        }
        public static PropertyCollection getDefaultStructValue(string className, bool stripTransients)
        {
            bool isImmutable = UnrealObjectInfo.IsImmutable(className, Mod.MEGame.ME2);

            if (Structs.ContainsKey(className))
            {
                ClassInfo info = Structs[className];
                try
                {
                    PropertyCollection structProps = new PropertyCollection();
                    ClassInfo          tempInfo    = info;
                    while (tempInfo != null)
                    {
                        foreach ((string propName, PropertyInfo propInfo) in tempInfo.properties)
                        {
                            if (stripTransients && propInfo.Transient)
                            {
                                continue;
                            }
                            if (getDefaultProperty(propName, propInfo, stripTransients, isImmutable) is UProperty uProp)
                            {
                                structProps.Add(uProp);
                            }
                        }
                        if (!Structs.TryGetValue(tempInfo.baseClass, out tempInfo))
                        {
                            tempInfo = null;
                        }
                    }
                    structProps.Add(new NoneProperty());

                    string filepath = Path.Combine(ME2Directory.gamePath, "BioGame", info.pccPath);
                    if (File.Exists(info.pccPath))
                    {
                        filepath = info.pccPath; //Used for dynamic lookup
                    }
                    if (File.Exists(filepath))
                    {
                        IMEPackage importPCC = MEPackageHandler.OpenMEPackage(filepath);

                        var                exportToRead = importPCC.getUExport(info.exportIndex);
                        byte[]             buff         = exportToRead.Data.Skip(0x30).ToArray();
                        PropertyCollection defaults     = PropertyCollection.ReadProps(exportToRead, new MemoryStream(buff), className);
                        foreach (var prop in defaults)
                        {
                            structProps.TryReplaceProp(prop);
                        }
                    }
                    return(structProps);
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
예제 #3
0
 public StructProperty GetCollisionMeshProperty(IMEPackage pcc)
 {
     if (pcc.isUExport(BodySetup))
     {
         ExportEntry rb_BodySetup = pcc.getUExport(BodySetup);
         return(rb_BodySetup.GetProperty <StructProperty>("AggGeom"));
     }
     return(null);
 }
예제 #4
0
 public static string FollowLink(this IMEPackage pcc, int uIndex)
 {
     if (pcc.isUExport(uIndex))
     {
         ExportEntry parent = pcc.getUExport(uIndex);
         return(pcc.FollowLink(parent.idxLink) + parent.ObjectName + ".");
     }
     if (pcc.isImport(uIndex))
     {
         ImportEntry parent = pcc.getImport(uIndex);
         return(pcc.FollowLink(parent.idxLink) + parent.ObjectName + ".");
     }
     return("");
 }
예제 #5
0
 protected SplineNode(int idx, IMEPackage p, PathingGraphEditor grapheditor)
 {
     Tag              = new ArrayList(); //outbound reachspec edges.
     pcc              = p;
     g                = grapheditor;
     index            = idx;
     export           = pcc.getUExport(index);
     comment          = new SText(GetComment(), commentColor, false);
     comment.X        = 0;
     comment.Y        = 52 + comment.Height;
     comment.Pickable = false;
     this.AddChild(comment);
     this.Pickable = true;
 }
예제 #6
0
        protected SplineNode(int idx, IMEPackage p)
        {
            pcc   = p;
            index = idx;
            if (idx >= 0)
            {
                export  = pcc.getUExport(index);
                comment = new SText(GetComment(), commentColor, false);
            }

            comment.X        = 0;
            comment.Y        = 0 - comment.Height;
            comment.Pickable = false;
            this.AddChild(comment);
            this.Pickable = true;
        }
        public static ClassInfo generateClassInfo(ExportEntry export, bool isStruct = false)
        {
            IMEPackage pcc  = export.FileRef;
            ClassInfo  info = new ClassInfo
            {
                baseClass   = export.SuperClassName,
                exportIndex = export.UIndex
            };

            if (pcc.FilePath.Contains("BioGame"))
            {
                info.pccPath = new string(pcc.FilePath.Skip(pcc.FilePath.LastIndexOf("BioGame") + 8).ToArray());
            }
            else
            {
                info.pccPath = pcc.FilePath; //used for dynamic resolution of files outside the game directory.
            }

            int nextExport = BitConverter.ToInt32(export.Data, isStruct ? 0x18 : 0x10);

            while (nextExport > 0)
            {
                var entry = pcc.getUExport(nextExport);
                if (entry.ClassName != "ScriptStruct" && entry.ClassName != "Enum" &&
                    entry.ClassName != "Function" && entry.ClassName != "Const" && entry.ClassName != "State")
                {
                    if (!info.properties.ContainsKey(entry.ObjectName))
                    {
                        PropertyInfo p = getProperty(entry);
                        if (p != null)
                        {
                            info.properties.Add(entry.ObjectName, p);
                        }
                    }
                }
                nextExport = BitConverter.ToInt32(entry.Data, 0x10);
            }
            return(info);
        }
예제 #8
0
        protected ActorNode(int idx, float x, float y, IMEPackage p, PathingGraphEditor grapheditor, bool drawAsPolygon = false, bool drawRotationLine = false)
        {
            pcc     = p;
            g       = grapheditor;
            index   = idx;
            export  = pcc.getUExport(index);
            comment = new SText(GetComment(), commentColor, false)
            {
                X = 0
            };
            comment.Y        = 52 + comment.Height;
            comment.Pickable = false;

            if (drawRotationLine)
            {
                if (export.GetProperty <StructProperty>("Rotation") is StructProperty rotation)
                {
                    var   theta    = rotation.GetProp <IntProperty>("Yaw").Value.ToDegrees();
                    float circleX1 = (float)(25 + 20 * Math.Cos((theta + 5) * Math.PI / 180));
                    float circleY1 = (float)(25 + 20 * Math.Sin((theta + 5) * Math.PI / 180));
                    float circleX2 = (float)(25 + 20 * Math.Cos((theta - 5) * Math.PI / 180));
                    float circleY2 = (float)(25 + 20 * Math.Sin((theta - 5) * Math.PI / 180));

                    float circleTipX     = (float)(25 + 25 * Math.Cos(theta * Math.PI / 180));
                    float circleTipY     = (float)(25 + 25 * Math.Sin(theta * Math.PI / 180));
                    PPath directionShape = PPath.CreatePolygon(new[] { new PointF(25, 25), new PointF(circleX1, circleY1), new PointF(circleTipX, circleTipY), new PointF(circleX2, circleY2) });
                    directionShape.Pen      = Pens.BlanchedAlmond;
                    directionShape.Brush    = directionBrush;
                    directionShape.Pickable = false;
                    AddChild(directionShape);
                }
            }
            this.AddChild(comment);
            this.Pickable = true;
            Bounds        = new RectangleF(0, 0, 50, 50);
            SetShape(drawAsPolygon);
            TranslateBy(x, y);
        }
        private static PropertyInfo getProperty(ExportEntry entry)
        {
            IMEPackage pcc = entry.FileRef;

            string       reference = null;
            PropertyType type;

            switch (entry.ClassName)
            {
            case "IntProperty":
                type = PropertyType.IntProperty;
                break;

            case "StringRefProperty":
                type = PropertyType.StringRefProperty;
                break;

            case "FloatProperty":
                type = PropertyType.FloatProperty;
                break;

            case "BoolProperty":
                type = PropertyType.BoolProperty;
                break;

            case "StrProperty":
                type = PropertyType.StrProperty;
                break;

            case "NameProperty":
                type = PropertyType.NameProperty;
                break;

            case "DelegateProperty":
                type = PropertyType.DelegateProperty;
                break;

            case "ClassProperty":
            case "ObjectProperty":
            case "ComponentProperty":
                type      = PropertyType.ObjectProperty;
                reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                break;

            case "StructProperty":
                type      = PropertyType.StructProperty;
                reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                break;

            case "BioMask4Property":
            case "ByteProperty":
                type      = PropertyType.ByteProperty;
                reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                break;

            case "ArrayProperty":
                type = PropertyType.ArrayProperty;
                PropertyInfo arrayTypeProp = getProperty(pcc.getUExport(BitConverter.ToInt32(entry.Data, 44)));
                if (arrayTypeProp != null)
                {
                    switch (arrayTypeProp.Type)
                    {
                    case PropertyType.ObjectProperty:
                    case PropertyType.StructProperty:
                    case PropertyType.ArrayProperty:
                        reference = arrayTypeProp.Reference;
                        break;

                    case PropertyType.ByteProperty:
                        //if (arrayTypeProp.reference == "")
                        if (arrayTypeProp.Reference == "Class")
                        {
                            reference = arrayTypeProp.Type.ToString();
                        }
                        else
                        {
                            reference = arrayTypeProp.Reference;
                        }
                        break;

                    case PropertyType.IntProperty:
                    case PropertyType.FloatProperty:
                    case PropertyType.NameProperty:
                    case PropertyType.BoolProperty:
                    case PropertyType.StrProperty:
                    case PropertyType.StringRefProperty:
                    case PropertyType.DelegateProperty:
                        reference = arrayTypeProp.Type.ToString();
                        break;

                    case PropertyType.None:
                    case PropertyType.Unknown:
                    default:
                        Debugger.Break();
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
                break;

            case "InterfaceProperty":
            default:
                return(null);
            }

            bool transient = ((UnrealFlags.EPropertyFlags)BitConverter.ToUInt64(entry.Data, 24)).HasFlag(UnrealFlags.EPropertyFlags.Transient);

            return(new PropertyInfo(type, reference, transient));
        }