Пример #1
0
 private void _GetValueType(ref StructValue goalValue, ref StructValue effectValue, ref StructValue precondValue, ref StructValue stateValue,
                            out StructValue.EValueType valueType,
                            out StructValue protoValue)
 {
     if (goalValue.Inited)
     {
         valueType  = goalValue.tp;
         protoValue = goalValue;
     }
     else if (effectValue.Inited)
     {
         valueType  = effectValue.tp;
         protoValue = effectValue;
     }
     else if (precondValue.Inited)
     {
         valueType  = precondValue.tp;
         protoValue = precondValue;
     }
     else if (stateValue.Inited)
     {
         valueType  = stateValue.tp;
         protoValue = stateValue;
     }
     else
     {
         UnityEngine.Debug.LogError("ReGoapNode._GetValueType: failed to find inited value");
         valueType  = StructValue.EValueType.Other;
         protoValue = StructValue.Create(null);
     }
 }
Пример #2
0
        public void StructTest()
        {
            Guid        id = Guid.NewGuid();
            StructValue s  = StructValue.Create(id, "Name1");
            StructValue s1 = new StructValue().PopulateWith(s);

            Assert.AreEqual(Guid.Empty, s1.Id);
            Assert.AreEqual(null, s1.Name);
            var nameProperty = s1.GetType().GetProperty("Name");

            nameProperty.SetValue(s1, "Name1");
            Assert.AreEqual(null, s1.Name);
            s1.Name = "Name1";
            Assert.AreEqual("Name1", s1.Name);
        }