예제 #1
0
    public void DropMarker(RoadMarker Mrkr)
    {
        //Recalc the XSecs
        XSecCalculator.CalcXSecs(Mrkr.Index - 1, RoadWidth); //two before the marker
        XSecCalculator.CalcXSecs(Mrkr.Index, RoadWidth);     //before the marker
        XSecCalculator.CalcXSecs(Mrkr.Index + 1, RoadWidth); //after the marker
        XSecCalculator.CalcXSecs(Mrkr.Index + 2, RoadWidth); //two after the marker

        //Add to the build queue

        if ((Mrkr.Index - 2 < Bez.CtrlPts.Count - 4) || (Rd.IsCircular))
        {
            Rd.Sectns[Mrkr.Index - 2].CalcVisibleFenceVerts();
            BuildQueue.Enqueue(Mrkr.Index - 2);
        }
        if ((Mrkr.Index - 1 < Bez.CtrlPts.Count - 4) || (Rd.IsCircular))
        {
            Rd.Sectns[Mrkr.Index - 1].CalcVisibleFenceVerts();
            BuildQueue.Enqueue(Mrkr.Index - 1);
        }
        if ((Mrkr.Index < Bez.CtrlPts.Count - 4) || (Rd.IsCircular))
        {
            Rd.Sectns[Mrkr.Index].CalcVisibleFenceVerts();
            BuildQueue.Enqueue(Mrkr.Index);
        }
        if ((Mrkr.Index + 1 < Bez.CtrlPts.Count - 4) || (Mrkr.Index + 1 <= Bez.CtrlPts.Count - 3 && Rd.IsCircular))
        {
            Rd.Sectns[Mrkr.Index + 1].CalcVisibleFenceVerts();
            BuildQueue.Enqueue(Mrkr.Index + 1);
        }
        //circular road penultimate CtrlPt needs to rebuild Section 1
        if (Mrkr.Index + 1 == Bez.CtrlPts.Count - 3 && Rd.IsCircular)   //doesnt work todo - needs fixing
        {
            Rd.Sectns[1].CalcVisibleFenceVerts();
            BuildQueue.Enqueue(1);
        }
        Mrkr.DroppedPosition = Mrkr.transform.position;
        //Charge for this if they moved the marker more than 1 metre
        if (GameData.current.BezS.CtrlPts == null)
        {
            Rd.Sectns[Mrkr.Index].Chargeable = true;
        }
        else
        {
            if (GameData.current.BezS.CtrlPts[Mrkr.Index] == null)
            {
                Rd.Sectns[Mrkr.Index].Chargeable = true;
            }
            else
            {
                BezCtrlPtSerial bcps          = GameData.current.BezS.CtrlPts[Mrkr.Index];
                Vector3         _oldMarkerPos = bcps.Pos.V3;
                if (Vector3.Distance(Bez.CtrlPts[Mrkr.Index].Pos, _oldMarkerPos) > 1 || Mathf.Abs(bcps.BankAngle - Bez.CtrlPts[Mrkr.Index].BankAngle) > 10)
                {
                    Rd.Sectns[Mrkr.Index].Chargeable = true;
                }
            }
        }
    }
예제 #2
0
    public void Encode(BezierLine Bez)
    {
        Path = new Vector3Serial[Bez.Path.Count];
        for (int Idx = 0; Idx < Bez.Path.Count; Idx++)
        {
            Vector3Serial PS = new Vector3Serial(Bez.Path[Idx]);
            Path.SetValue(PS, Idx);
        }

        CtrlPts = new BezCtrlPtSerial[Bez.CtrlPts.Count];
        for (int Idx = 0; Idx < Bez.CtrlPts.Count; Idx++)
        {
            BezCtrlPtSerial BCPS = new BezCtrlPtSerial();
            BCPS.Encode(Bez.CtrlPts[Idx]);
            CtrlPts.SetValue(BCPS, Idx);
        }
    }