コード例 #1
0
        private static bool TryGetStateBranch(UpperString text, out ActorStateBranch branchType)
        {
            switch (text.String)
            {
            case "FAIL":
                branchType = ActorStateBranch.Fail;
                return(true);

            case "GOTO":
                branchType = ActorStateBranch.Goto;
                return(true);

            case "LOOP":
                branchType = ActorStateBranch.Loop;
                return(true);

            case "STOP":
                branchType = ActorStateBranch.Stop;
                return(true);

            case "WAIT":
                branchType = ActorStateBranch.Wait;
                return(true);
            }

            branchType = ActorStateBranch.None;
            return(false);
        }
コード例 #2
0
        private int?LabelToOffset(ActorFrame frame)
        {
            ActorFlowControl flowControl = frame.FlowControl;
            ActorStateBranch type        = flowControl.FlowType;

            Debug.Assert(type == ActorStateBranch.Goto || type == ActorStateBranch.Loop, "Expected Goto or Loop label here only");

            int?        index;
            UpperString label = flowControl.Label.Value;

            if (type == ActorStateBranch.Goto && flowControl.Parent)
            {
                UpperString parent = flowControl.Parent.Value;
                index = GetSuperOrParent(parent, label);

                if (index == null)
                {
                    Log.Error($"Unable to find label: {parent}::{label}");
                    return(null);
                }
            }
            else
            {
                index = Labels[label];
                if (index == null)
                {
                    Log.Error($"Unable to find label: {label}");
                    return(null);
                }
            }

            // The offset to the label is the delta from our current position,
            // plus any extra offset that the flow control will have provided.
            return(index.Value - frame.FrameIndex + flowControl.Offset);
        }
コード例 #3
0
 public ActorFlowControl(ActorFlowControl other)
 {
     FlowType = other.FlowType;
     Label    = new Optional <UpperString>(other.Label.Value);
     Parent   = new Optional <UpperString>(other.Parent.Value);
     Offset   = other.Offset;
 }
コード例 #4
0
        public ActorFlowControl(ActorStateBranch branchType, UpperString label)
        {
            Debug.Assert(branchType == ActorStateBranch.Loop, $"Using wrong branch type constructor ({branchType} should be only Loop)");

            FlowType = branchType;
            Label    = label;
        }
コード例 #5
0
 public ActorFlowControl(ActorStateBranch branchType, Optional <UpperString> parent,
                         Optional <UpperString> label, int offset)
 {
     FlowType = branchType;
     Label    = label;
     Parent   = parent;
     Offset   = offset;
 }
コード例 #6
0
        public ActorFlowControl(ActorStateBranch branchType)
        {
            Debug.Assert(branchType != ActorStateBranch.Goto && branchType != ActorStateBranch.Loop, $"Using wrong branch type constructor ({branchType} should be not be Goto or Loop)");

            FlowType = branchType;
        }