Ejemplo n.º 1
0
 public string SetToBlockMover(ModuleBlockMover blockMover)
 {
     blockMover.SetDirty();
     blockMover.SetMinLimit(minValueLimit ?? 0f);
     blockMover.SetMaxLimit(maxValueLimit ?? blockMover.TrueLimitVALUE);
     blockMover.MAXVELOCITY = maxVelocity.HasValue ? velocity.Value : blockMover.MAXVELOCITY;
     if (targetValue.HasValue)
     {
         blockMover.VALUE = targetValue.Value;
     }
     if (velocity.HasValue)
     {
         blockMover.VELOCITY = velocity.Value;
     }
     if (jointStrength.HasValue)
     {
         blockMover.SPRSTR = jointStrength.Value;
     }
     if (jointDampen.HasValue)
     {
         blockMover.SPRDAM = jointDampen.Value;
     }
     if (moverType.HasValue)
     {
         blockMover.moverType = moverType.Value;
     }
     blockMover.CannotBeFreeJoint = blockMover.CannotBeFreeJoint;
     if (lockOffsetParent.HasValue)
     {
         blockMover.LockJointBackPush = lockOffsetParent.Value;
     }
     return(InputOperator.StringArrayToProcessOperations(ToString(), ref blockMover.ProcessOperations));
 }
Ejemplo n.º 2
0
        public static void ConvertSerialToBlockMover(SerialData serialData, ModuleBlockMover blockMover)
        {
            string ProcessList;
            blockMover.SetDirty();
            blockMover.moverType = ModuleBlockMover.MoverType.Static;
            blockMover.LockJointBackPush = true;
            blockMover.LOCALINPUT = serialData.Local;
            blockMover._CENTERLIMIT = serialData.Stretch != 0 ? serialData.Stretch / 2f : blockMover.HalfLimitVALUE;
            blockMover._EXTENTLIMIT = blockMover._CENTERLIMIT;
            blockMover.UseLIMIT = serialData.Stretch != 0 && serialData.Stretch != blockMover.TrueLimitVALUE;
            blockMover.VELOCITY = 0f;
            blockMover.VALUE = serialData.IsOpen ? serialData.Stretch : 0f;
            blockMover.PVALUE = blockMover.VALUE;

            var mode = GetMode(serialData.Toggle, serialData.Invert, serialData.PreferState);
            ProcessList = ModeToProcessFormat[(int)mode];
            ProcessList = ProcessList.Replace("<Input>", serialData.Input.ToString());
            ProcessList = ProcessList.Replace("<Extent>", (serialData.Stretch == 0 ? blockMover.TrueLimitVALUE : serialData.Stretch).ToString());
            ProcessList = ProcessList.Replace("<ToggleState>", serialData.IsOpen ? "1" : "-1");
            InputOperator.StringArrayToProcessOperations(ProcessList, ref blockMover.ProcessOperations);
        }
Ejemplo n.º 3
0
        public static void ConvertSerialToBlockMover(SerialData serialData, ModuleBlockMover blockMover)
        {
            string ProcessList;

            blockMover.SetDirty();
            blockMover.moverType         = ModuleBlockMover.MoverType.Static;
            blockMover.LockJointBackPush = true;
            blockMover.LOCALINPUT        = serialData.Local;
            blockMover._CENTERLIMIT      = serialData.minRestrict;
            blockMover._EXTENTLIMIT      = serialData.rangeRestrict;// / 2f;
            blockMover.UseLIMIT          = serialData.Restrict && serialData.rangeRestrict != 0f;
            blockMover.VELOCITY          = 0f;
            blockMover.VALUE             = serialData.Angle;
            blockMover.PVALUE            = serialData.Angle;
            blockMover.MAXVELOCITY       = serialData.Speed;
            switch (serialData.mode)
            {
            case Mode.Positional:
                if (serialData.StartDelay != 0f)
                {
                    ProcessList = PositionalDelay;
                }
                else
                {
                    ProcessList = Positional;
                }
                break;

            case Mode.Directional:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.CWDelay + serialData.CCWDelay != 0f)
                {
                    ProcessList = DirectionalDelay;
                }
                else
                {
                    ProcessList = Directional;
                }
                break;

            case Mode.Speed:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.StartDelay != 0f)
                {
                    ProcessList = SpeedDelay;
                }
                else
                {
                    ProcessList = Speed;
                }
                break;

            case Mode.OnOff:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.Restrict)
                {
                    if (serialData.CWDelay + serialData.CCWDelay != 0f)
                    {
                        ProcessList = OnOffLimitDelay;
                    }
                    else
                    {
                        ProcessList = OnOffLimit;
                    }
                }
                else
                {
                    if (serialData.StartDelay != 0f)
                    {
                        ProcessList = OnOffDelay;
                    }
                    else
                    {
                        ProcessList = OnOff;
                    }
                }
                break;

            case Mode.Aim:
                if (serialData.StartDelay != 0f)
                {
                    ProcessList = TargetDelay;
                }
                else
                {
                    ProcessList = Target;
                }
                break;

            case Mode.Turning:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.Restrict)
                {
                    if (serialData.StartDelay != 0f)
                    {
                        ProcessList = TurningLimitDelay;
                    }
                    else
                    {
                        ProcessList = TurningLimit;
                    }
                }
                else
                {
                    if (serialData.StartDelay != 0f)
                    {
                        ProcessList = TurningDelay;
                    }
                    else
                    {
                        ProcessList = Turning;
                    }
                }
                break;

            case Mode.AimAtPlayer:
                ProcessList = AimAtPlayer;
                break;

            case Mode.Throttle:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.StartDelay != 0f)
                {
                    ProcessList = ThrottleDelay;
                }
                else
                {
                    ProcessList = Throttle;
                }
                break;

            case Mode.AimAtVelocity:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                ProcessList         = AimAtVelocity;
                break;

            case Mode.Cycle:
                blockMover.VELOCITY = serialData.Direction * serialData.Speed;
                if (serialData.Restrict)
                {
                    if (serialData.StartDelay != 0f || serialData.CCWDelay != 0f || serialData.CWDelay != 0f)
                    {
                        ProcessList = CycleLimitDelay;
                    }
                    else
                    {
                        ProcessList = CycleLimit;
                    }
                }
                else
                {
                    if (serialData.StartDelay != 0f || serialData.CCWDelay != 0f || serialData.CWDelay != 0f)
                    {
                        ProcessList = CycleDelay;
                    }
                    else
                    {
                        ProcessList = Cycle;
                    }
                }
                break;

            default:
                Console.WriteLine("ModuleSwivel.ConvertSerialToBlockMover() : Cannot deserialize " + serialData.mode.ToString() + ", missing conversion!");
                ProcessList = "";
                break;
            }
            ProcessList = ProcessList.Replace("<KeyR>", serialData.Input1.ToString());
            ProcessList = ProcessList.Replace("<KeyL>", serialData.Input2.ToString());
            ProcessList = ProcessList.Replace("<SD>", ((serialData.StartDelay / serialData.Speed) * Time.fixedDeltaTime).ToString());
            ProcessList = ProcessList.Replace("<CWD>", ((serialData.CWDelay / serialData.Speed) * Time.fixedDeltaTime).ToString());
            ProcessList = ProcessList.Replace("<CCWD>", ((serialData.CCWDelay / serialData.Speed) * Time.fixedDeltaTime).ToString());
            ProcessList = ProcessList.Replace("<Speed>", serialData.Speed.ToString());
            ProcessList = ProcessList.Replace("<Smooth>", (serialData.Speed * 0.025f).ToString()); // Position += (Direction +- 0.025f) * Speed
            ProcessList = ProcessList.Replace("<Smooth2>", (serialData.Speed * 0.05f).ToString());
            ProcessList = ProcessList.Replace("<LimitC>", blockMover._CENTERLIMIT.ToString());
            ProcessList = ProcessList.Replace("<LimitL>", (((blockMover.MINVALUELIMIT + 900) % 360) - 180).ToString());
            ProcessList = ProcessList.Replace("<LimitR>", (((blockMover.MAXVALUELIMIT + 900) % 360) - 180).ToString());
            InputOperator.StringArrayToProcessOperations(ProcessList, ref blockMover.ProcessOperations);
        }