Пример #1
0
        public void TestCustomSerializationStructsInMap()
        {
            var tester = new UAsset(Path.Combine("TestCustomSerializationStructsInMap", "wtf.uasset"), UE4Version.VER_UE4_25);

            Assert.IsTrue(tester.VerifyBinaryEquality());

            // Get the map property in export 2
            Export exportTwo = FPackageIndex.FromRawIndex(2).ToExport(tester);

            Assert.IsTrue(exportTwo is NormalExport);

            NormalExport exportTwoNormal = (NormalExport)exportTwo;

            var             mapPropertyName = FName.FromString("KekWait");
            MapPropertyData testMap         = exportTwoNormal[mapPropertyName] as MapPropertyData;

            Assert.IsNotNull(testMap);
            Assert.IsTrue(testMap == exportTwoNormal[mapPropertyName.Value.Value]);

            // Get the first entry of the map
            StructPropertyData entryKey   = testMap?.Value?.Keys?.ElementAt(0) as StructPropertyData;
            StructPropertyData entryValue = testMap?.Value?[0] as StructPropertyData;

            Assert.IsNotNull(entryKey?.Value?[0]);
            Assert.IsNotNull(entryValue?.Value?[0]);

            // Check that the properties are correct
            Assert.IsTrue(entryKey.Value[0] is VectorPropertyData);
            Assert.IsTrue(entryValue.Value[0] is LinearColorPropertyData);
        }
Пример #2
0
 public override void FromString(string[] d, UAsset asset)
 {
     if (d[4] != null)
     {
         ArrayType = FName.FromString(d[4]);
     }
 }
Пример #3
0
 FKey GetKey(string name)
 {
     return(new FKey()
     {
         KeyName = FName.FromString(name)
     });
 }
Пример #4
0
 public override void FromString(string[] d, UAsset asset)
 {
     if (d[4] != null)
     {
         StructType = FName.FromString(d[4]);
     }
     if (StructType == null)
     {
         StructType = new FName("Generic");
     }
 }
Пример #5
0
 public override void FromString(string[] d, UAsset asset)
 {
     DisplayName = FName.FromString(d[0]);
     if (ushort.TryParse(d[1], out ushort rawSmartNameID))
     {
         SmartNameID = rawSmartNameID;
     }
     if (Guid.TryParse(d[2], out Guid rawTempGUID))
     {
         TempGUID = rawTempGUID;
     }
 }
        public override void FromString(string[] d, UAsset asset)
        {
            if (asset.EngineVersion < UE4Version.VER_UE4_ADDED_SOFT_OBJECT_PATH)
            {
                Path = FString.FromString(d[0]);
            }
            else
            {
                FName output = FName.FromString(d[0]);
                asset.AddNameReference(output.Value);
                AssetPathName = output;

                if (d.Length > 1)
                {
                    SubPathString = FString.FromString(d[1]);
                }
            }
        }
Пример #7
0
        void Tick(float deltaTime)
        {
            FRotator rot     = pc.GetControlRotation();
            FVector  forward = UKismetMathLibrary.GetForwardVector(new FRotator(0, rot.Yaw, 0));
            FVector  right   = UKismetMathLibrary.GetRightVector(new FRotator(0, rot.Yaw, 0));
            FKey     key     = new FKey();

            key.KeyName = FName.FromString("W");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(forward, 1.0f, false);
            }
            key.KeyName = FName.FromString("S");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(-forward, 1.0f, false);
            }
            key.KeyName = FName.FromString("A");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(-right, 1.0f, false);
            }
            key.KeyName = FName.FromString("D");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(right, 1.0f, false);
            }

            key.KeyName = FName.FromString("J");
            if (pc.IsInputKeyDown(key))
            {
                USkeletalMeshComponent mesh = Cast <USkeletalMeshComponent>(pc.K2_GetPawn().GetComponentByClass(typeof(USkeletalMeshComponent)));
                mesh.GetAnimInstance().Montage_Play(Montage, 1);
            }

            float movex, movey;

            pc.GetInputMouseDelta(out movex, out movey);
            pc.AddYawInput(movex);
            pc.AddPitchInput(movey);
        }
Пример #8
0
        public void TestNameConstruction()
        {
            FName test = FName.FromString("HelloWorld_0");

            Assert.IsTrue(test.Value.Value == "HelloWorld" && test.Number == 1);
            Assert.IsTrue(test.ToString() == "HelloWorld_0");

            test = FName.FromString("5_72");
            Assert.IsTrue(test.Value.Value == "5" && test.Number == 73);
            Assert.IsTrue(test.ToString() == "5_72");

            test = FName.FromString("_3");
            Assert.IsTrue(test.Value.Value == "_3" && test.Number == 0);
            Assert.IsTrue(test.ToString() == "_3");

            test = FName.FromString("hi_");
            Assert.IsTrue(test.Value.Value == "hi_" && test.Number == 0);
            Assert.IsTrue(test.ToString() == "hi_");

            test = FName.FromString("hi_01");
            Assert.IsTrue(test.Value.Value == "hi_01" && test.Number == 0);
            Assert.IsTrue(test.ToString() == "hi_01");

            test = FName.FromString("hi_10");
            Assert.IsTrue(test.Value.Value == "hi" && test.Number == 11);
            Assert.IsTrue(test.ToString() == "hi_10");

            test = FName.FromString("blah");
            Assert.IsTrue(test.Value.Value == "blah" && test.Number == 0);
            Assert.IsTrue(test.ToString() == "blah");

            test = new FName("HelloWorld", 2);
            Assert.IsTrue(test.ToString() == "HelloWorld_1");

            test = new FName("HelloWorld", 0);
            Assert.IsTrue(test.ToString() == "HelloWorld");
        }
Пример #9
0
        void BeginPlay()
        {
            LogWarning("Hello World!");

            LogInfo(string.Format("int {0}", testData));
            LogInfo(string.Format("testFloat {0}", testFloat));
            LogInfo(string.Format("testString {0}", testString));

            LogInfo("Class " + this.GetName());
            if (this.GetOuter() == null)
            {
                LogInfo("Class Out Is Null");
            }
            else
            {
                LogInfo("Class " + this.GetOuter().GetName());
            }

            //FTransform trans = GetOwner().GetTransform();
            //trans.Scale3D.X = 3.0f;
            //trans.Scale3D.Y = 3.0f;
            //trans.Scale3D.Z = 3.0f;
            //LogInfo("more methods:" + string.Format("Actor Name {0}, Pos {1},{2},{3}",
            //    this.GetOwner().GetName(),
            //    trans.Translation.X,
            //    trans.Translation.Y,
            //    trans.Translation.Z));

            LogInfo("Tick Group " + this.PrimaryComponentTick.TickGroup);

            LogInfo(string.Format("array num {0}", intArray2.Length));
            for (int i = 0; i < intArray2.Length; i++)
            {
                LogInfo(string.Format("intArray index {0} , value {1}", i, intArray2[i]));
            }
            for (int i = 0; i < strArray.Length; i++)
            {
                LogInfo(string.Format("strArray index {0} , value {1}", i, strArray[i]));
            }
            for (int i = 0; i < boolArray.Length; i++)
            {
                LogInfo(string.Format("boolArray index {0} , value {1}", i, boolArray[i]));
            }
            if (actorArray2 != null)
            {
                for (int i = 0; i < actorArray2.Length; i++)
                {
                    LogInfo(string.Format("actorArray2 index {0} , value {1}", i, actorArray2[i].GetName()));
                }
            }
            else
            {
                LogInfo(string.Format("actorArray2 is null"));
            }

            LogInfo(string.Format("check state {0}", checkState));

            AActor Owner = this.GetOwner();

            TStructArray <FName> tags = this.ComponentTags;

            tags.Add(FName.FromString("Tag0_Modify"));
            tags.Add(FName.FromString("Tag1"));
            this.ComponentTags = tags;
            int num = this.ComponentTags.Num();

            LogInfo("Tags Num:" + num);
            for (int i = 0; i < num; i++)
            {
                LogInfo(string.Format("com name {0}", this.ComponentTags[i].ToString()));
            }
            LogInfo(string.Format("GetComponentsByClass"));
            TSubclassOf <UActorComponent> Class = typeof(UActorComponent);

            LogInfo(string.Format("GetComponentsByClass1"));
            UActorComponent[] coms = this.GetOwner().GetComponentsByClass(Class);
            LogInfo(string.Format("GetComponentsByClass2"));
            LogInfo(string.Format("coms num {0}", coms.Length));
            for (int i = 0; i < coms.Length; i++)
            {
                LogInfo(string.Format("coms index {0} , value {1}", i, coms[i].GetName()));
            }
        }