public void PortalInstruction_OffMapEndpointFromString_IsCorrect()
        {
            var portal = PortalInstruction.FromString("Portal-Door: (1,1,1); End1=(1,2,0); End2=(OffMap)");

            Assert.AreEqual("Door", portal.Type);
            Assert.AreEqual(XYZOrientation.FromString("1,1,1,U"), portal.Location);
            Assert.AreEqual(new XYZ(1, 2, 0), portal.Endpoint1);
            Assert.AreEqual(SpecialLocation.OffOfMap, portal.Endpoint2);
        }
Beispiel #2
0
        public static PortalInstruction FromString(string arg)
        {
            if (!arg.Contains("Portal-") || !arg.Contains("End1") || !arg.Contains("End2"))
            {
                throw new ArgumentException($"Invalid Portal Instruction: {arg}");
            }

            var sections  = arg.CleanAndSplit(':');
            var type      = sections[0].Replace("Portal-", "");
            var props     = sections[1].Split(';');
            var location  = XYZOrientation.FromString(props[0]);
            var endpoint1 = GetXYZ(props.GetValue("End1"));
            var endpoint2 = GetXYZ(props.GetValue("End2"));

            return(new PortalInstruction(type, location, endpoint1, endpoint2));
        }