Esempio n. 1
0
 internal bool IsSegmentInList(ModuleBMSegment segment)
 {
     return(m_Segments.Contains(segment));
 }
Esempio n. 2
0
        internal override bool CanStartGetBlocks(BlockManager blockMan)
        {
            ClearSegmentList();          // Remove pointers to this block

            foreach (var m in posCurves) // Clear position animation
            {
                m.keys = new Keyframe[1] {
                    new Keyframe(0f, 0f, 0f, 0f, 0f, 0f)
                }
            }
            ;
            foreach (var m in rotCurves) // Clear rotation animation
            {
                m.keys = new Keyframe[1] {
                    new Keyframe(0f, 0f, 0f, 0f, 0f, 0f)
                }
            }
            ;

            Quaternion TravelQuat = Quaternion.identity;
            //Vector3 TravelRot = Vector3.zero;
            OrthoRotation OriginalRot        = block.cachedLocalRotation;
            float         Length             = starterAnim.AddToAnimCurves(OrthoRotation.identity, this, 0f, ref TravelQuat, starterAnim, 0f);//, ref TravelQuat);//, ref TravelRot);
            float         prevTrueLimitVALUE = TrueLimitVALUE;

            TrueLimitVALUE = 0f;

            TankBlock   LastBlock = block;
            AttachPoint LastAP    = starterAnim; //For grabbing the block at the next position

            TankBlock Segment = LastAP.GetBlockAtPos(LastBlock, blockMan);

            while (Segment != null)
            {
                Print(">> Found block " + Segment.cachedLocalPosition);
                ModuleBMSegment component = Segment.GetComponent <ModuleBMSegment>();
                if (component == null) // Not a rail segment
                {
                    Print("   Not a segment");
                    ModuleBMRail opposer = Segment.GetComponent <ModuleBMRail>();
                    if (opposer == null || !LastAP.CanConnect(LastBlock, Segment, opposer.starterAnim)) // Not an opposing rail, or not sharing
                    {
                        break;
                    }
                    // Cut shared rail in half to prevent overlap
                    Print("   Is another head!");
                    CutSegmentListInHalf();
                    TrueLimitVALUE = HalfLimitVALUE - 0.5f; // Move back .5 for block-room on the AP
                    break;
                }

                if (component.blockMoverHeadType != m_thisHeadType)//component.blockMoverHeadType.Contains(m_thisHeadType))
                {
                    Print("   Wrong rail type!");
                    break; // A different rail system
                }

                var _Segment = Segment;
                Segment = null; // Nullify this, if not re-set it will break the loop

                for (int i = 0; i < 2; i++)
                {
                    if (LastAP.CanConnect(LastBlock, _Segment, component.APs[i]))
                    {
                        m_Segments.Add(component);
                        LastBlock = _Segment;
                        LastAP    = component.APs[1 - i];

                        Length  = component.APs[i].AddToAnimCurves(Quaternion.Inverse(OriginalRot) * _Segment.cachedLocalRotation, this, Length, ref TravelQuat, LastAP, component.AnimWeight); //, ref TravelQuat);//, ref TravelRot);
                        Segment = LastAP.GetBlockAtPos(_Segment, blockMan);                                                                                                                     // Set the new segment, continue

                        Print("   Connected!");
                        break; // Exit the foreach
                    }
                }
                if (Segment == null)
                {
                    Print(">> No more blocks");
                }
            }

            //if (TrueLimitVALUE == 0f) TrueLimitVALUE = 0.25f;
            ValidateSegmentList(out bool DisableFreeJoint);

            CannotBeFreeJoint = true;//DisableFreeJoint;

            if (MAXVALUELIMIT >= TrueLimitVALUE)
            {
                SetMaxLimit(TrueLimitVALUE);
                if (PVALUE > TrueLimitVALUE)
                {
                    PVALUE = TrueLimitVALUE;
                }
                if (VALUE > TrueLimitVALUE)
                {
                    VALUE = TrueLimitVALUE;
                }
            }
            else if (prevTrueLimitVALUE == 0f || MAXVALUELIMIT == prevTrueLimitVALUE || !UseLIMIT)
            {
                SetMaxLimit(TrueLimitVALUE);
            }

            return(true);
        }
Esempio n. 3
0
 public bool CheckSegment(ModuleBMSegment segment)
 {
     return(segment.blockMoverHeadType == m_thisHeadType);
 }