Пример #1
0
        public FloorPlanner(Func <double> random, INamedDataCollection metadata, Func <KeyValuePair <string, string>[], Type[], ScriptReference> finder, float wallThickness, WallGrowthParameters wallGrowthParameters, MergingParameters mergeParameters, CorridorParameters corridorParameters)
        {
            Contract.Requires(random != null);
            Contract.Requires(metadata != null);
            Contract.Requires(finder != null);
            Contract.Requires(wallGrowthParameters != null);

            _random               = random;
            _metadata             = metadata;
            _finder               = finder;
            _wallThickness        = wallThickness;
            _wallGrowthParameters = wallGrowthParameters;
            _mergeParameters      = mergeParameters;
            _corridorParameters   = corridorParameters;
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outline">Polygon outline of this map (clockwise wound, potentially concave)</param>
        /// <param name="internalRooms">Set of rooms which must be included unchanged in this map</param>
        /// <param name="random">PRNG (0-1)</param>
        /// <param name="metadata">Metadata used in random generation</param>
        /// <param name="parameters"></param>
        public GrowthMap(IReadOnlyList <Vector2> outline, IReadOnlyList <IReadOnlyList <Vector2> > internalRooms, Func <double> random, INamedDataCollection metadata, WallGrowthParameters parameters)
        {
            Contract.Requires(outline != null);
            Contract.Requires(internalRooms != null);
            Contract.Requires(random != null);
            Contract.Requires(metadata != null);
            Contract.Requires(parameters != null);

            _outline       = outline;
            _internalRooms = internalRooms;
            _random        = random;
            _metadata      = metadata;

            _seedDistance                   = parameters.SeedDistance;
            _seedChance                     = parameters.SeedChance;
            _parallelLengthMultiplier       = parameters.ParallelLengthMultiplier;
            _parallelCheckWidth             = parameters.ParallelCheckWidth;
            _cosineParallelAngleThreshold   = parameters.ParallelAngleThreshold.Transform(a => (float)Math.Cos(a));
            _intersectionContinuationChance = parameters.IntersectionContinuationChance;

            var bounds = BoundingRectangle.CreateFromPoints(outline).Inflate(0.2f);

            _mesh = new Mesh <FloorplanVertexTag, FloorplanHalfEdgeTag, FloorplanFaceTag>(bounds);
        }