Пример #1
0
        protected static void AssignGround(
            ILandChunk landChunk,
            int i, int j,
            int altitude, int altitudeOffset,
            ILandObject mainLandObject, ILandObject secondLandObject,
            bool onlyGround = false)
        {
            if (mainLandObject != null || secondLandObject != null)
            {
                if (altitudeOffset == 0)
                {
                    landChunk.InitializeLandCase(i, j, altitude);
                    LandCase landCase = landChunk.GetLandCase(i, j, altitude);

                    if (mainLandObject != null)
                    {
                        landCase.AddLandGround(mainLandObject);
                    }

                    if (secondLandObject != null)
                    {
                        landCase.AddLandGround(secondLandObject);
                    }
                }
                else
                {
                    for (int z = 0; z < altitudeOffset; z++)
                    {
                        landChunk.InitializeLandCase(i, j, altitude + z);
                        LandCase landCase = landChunk.GetLandCase(i, j, altitude + z);
                        //if (landCase == null)
                        //{
                        //    throw new Exception("if offset > 0, case must be already initialized thanks to CliffLayerGenerator !");
                        //}

                        if (mainLandObject != null)
                        {
                            ILandObject cloneMainObject = mainLandObject.Clone();
                            cloneMainObject.Altitude = altitude + z;

                            landCase.AddLandGround(cloneMainObject);
                        }

                        if (secondLandObject != null)
                        {
                            ILandObject cloneSecondObject = secondLandObject.Clone();
                            cloneSecondObject.Altitude = altitude + z;

                            landCase.AddLandGround(cloneSecondObject);
                        }

                        if (onlyGround == false && landCase.LandWall != null)
                        {
                            if (mainLandObject != null)
                            {
                                ILandObject cloneMainObject = mainLandObject.Clone(landCase.LandWall.LandTransition);
                                if (cloneMainObject != null)
                                {
                                    cloneMainObject.Altitude = altitude + z;

                                    landCase.AddLandGroundOverWall(cloneMainObject);
                                }
                            }

                            if (secondLandObject != null)
                            {
                                ILandObject cloneSecondObject = secondLandObject.Clone(landCase.LandWall.LandTransition);
                                if (cloneSecondObject != null)
                                {
                                    cloneSecondObject.Altitude = altitude + z;

                                    landCase.AddLandGroundOverWall(cloneSecondObject);
                                }
                            }
                        }
                    }
                }
            }
        }