public override void PreDeployTweaks(ThemeElementSpec spec) { // Normal GridDirection walkableDir; GridLocation offsetLocation; if (spec.GenGrid.AlternatesSides(spec.DeployX, spec.DeployY, Draw.IsType <GenSpace>(GridType.Wall), out walkableDir)) { bool neg = spec.Random.NextBool(); if (walkableDir == GridDirection.HORIZ) { spec.GenDeploy.Rotate(spec.Random.NextFlip()); } else { spec.GenDeploy.Rotate(spec.Random.NextClockwise()); } } // Diagonal door else if (spec.GenGrid.AlternatesCorners(spec.DeployX, spec.DeployY, Draw.Walkable(), out walkableDir)) { spec.GenDeploy.YRotation = walkableDir == GridDirection.DIAGTLBR ? -45 : 45; } // Offset alternates else if (spec.GenGrid.AlternateSidesOffset(spec.DeployX, spec.DeployY, Draw.Not(Draw.Walkable()), out offsetLocation)) { PlaceFlush(spec.GenDeploy, offsetLocation); } PlaceFloors(spec); }
private void HandleDoodad(ThemeElementSpec spec, bool centerB, bool rotateB) { Vector2 center = spec.Bounding.GetRealCenter(); if (centerB && (spec.GenDeploy.Element.GridLength > 1 || spec.GenDeploy.Element.GridWidth > 1)) { center.x -= spec.DeployX; center.y -= spec.DeployY; spec.GenDeploy.X += center.x; spec.GenDeploy.Z += center.y; } if (rotateB) { Rotation rot; if (spec.GenDeploy.Element.GridLength == spec.GenDeploy.Element.GridWidth) { // Rotate randomly rot = spec.Random.NextRotation(); } else if (center.y > center.x) { rot = spec.Random.NextBool() ? Rotation.ClockWise : Rotation.CounterClockWise; } else { rot = spec.Random.NextBool() ? Rotation.OneEighty : Rotation.None; } spec.GenDeploy.Rotate(rot); } }
public override void PreDeployTweaks(ThemeElementSpec spec) { Value2D <GenSpace> val; if (spec.GenGrid.GetPointAround(spec.DeployX, spec.DeployY, false, Draw.IsType <GenSpace>(GridType.StairPlace), out val)) { val.x -= spec.DeployX; val.y -= spec.DeployY; if (val.x == 1) { spec.GenDeploy.YRotation = 90; } else if (val.x == -1) { spec.GenDeploy.YRotation = -90; } else if (val.y == -1) { spec.GenDeploy.YRotation = 180; } } if (spec.Type == GridType.StairDown) { spec.GenDeploy.Y = -1; spec.GenDeploy.YRotation += 180; } }
public override void PreDeployTweaks(ThemeElementSpec spec) { if (PlaceFloor) { PlaceFloors(spec); } }
public MultiMap <List <GenDeploy> > PlaceFloors(ThemeElementSpec spec) { var ret = new MultiMap <List <GenDeploy> >(); foreach (var space in spec) { spec.AddAdditional(new GenDeploy(spec.Theme.Floor.SmartElement.Get(spec.Random)), space.x, space.y); } return(ret); }
public override void PreDeployTweaks(ThemeElementSpec spec) { GridLocation loc = spec.GenGrid.FindEdges(spec.Bounding.Expand(1), Draw.IsType <GenSpace>(GridType.StairPlace), false, true).First(); CenterDoodad(spec); spec.GenDeploy.RotateToPoint(loc); if (spec.Type == GridType.StairDown) { spec.GenDeploy.Y -= StairHeight; spec.GenDeploy.YRotation += 180; } }
public override void PreDeployTweaks(ThemeElementSpec spec) { GridLocation wall; if (spec.GenGrid.GetRandomLocationAround(spec.DeployX, spec.DeployY, false, spec.Random, Draw.WallType <GenSpace>(), out wall)) { // If wall around, make it flush PlaceFlush(spec.GenDeploy, wall, _chestBuffer); } else { // Place randomly in the middle PlaceRandomlyInside(spec.Random, spec.GenDeploy, _chestBuffer); } PlaceFloors(spec); }
public Container2D <GridSpace> GeneratePrototypes(LevelLayout layout) { MultiMap <GridSpace> ret = new MultiMap <GridSpace>(); ThemeElementSpec spec = new ThemeElementSpec() { GenGrid = layout.Grids, Random = layout.Random, Grid = ret }; foreach (Value2D <GenSpace> gen in spec.GenGrid) { if (gen.val.Deploys == null) { HandleEmptyDeploy(gen.val, spec.Random); } GridSpace space; if (!ret.TryGetValue(gen, out space)) { space = new GridSpace(gen.val.Type, gen.x, gen.y) { Theme = gen.val.Theme }; space.Deploys = new List <GridDeploy>(gen.val.Deploys.Count); ret[gen] = space; } spec.GenSpace = gen.val; spec.Space = space; spec.Theme = gen.val.Theme; spec.Type = gen.val.Type; spec.DeployX = gen.x; spec.DeployY = gen.y; List <GenDeploy> tmp = new List <GenDeploy>(gen.val.MainDeploys); foreach (GenDeploy genDeploy in tmp) { spec.GenDeploy = genDeploy; Deploy(spec); } } return(ret); }
protected void Deploy(ThemeElementSpec spec) { if (spec.GenDeploy.Deployed) { return; } spec.GenDeploy.Deployed = true; spec.Reset(); spec.GenDeploy.Element.PreDeployTweaks(spec); GridDeploy deploy = new GridDeploy(spec.GenDeploy); spec.Space.Deploys.Add(deploy); if (spec.Additional.Count == 0) { return; } foreach (var d in spec.Additional.ToList()) { spec.DeployX = d.x; spec.DeployY = d.y; GridSpace space; if (!spec.Grid.TryGetValue(d, out space)) { space = new GridSpace(spec.Type, spec.DeployX, spec.DeployY) { Theme = spec.Theme }; space.Deploys = new List <GridDeploy>(); spec.Grid[d] = space; } spec.Space = space; foreach (GenDeploy d2 in d.val) { spec.GenDeploy = d2; Deploy(spec); } } }
public override void PreDeployTweaks(ThemeElementSpec spec) { GridLocationResults results = spec.GenGrid.DrawLocationsAroundResults(spec.DeployX, spec.DeployY, true, _test); GridDirection dir; GridLocation loc; bool placeFloor = PlaceFloor; if (spec.GenGrid.AlternatesSides(results, out dir)) { spec.GenDeploy.Element = ThinWall.Get(spec.Random); spec.GenDeploy.RotateToPoint(dir, spec.Random); } else if (spec.GenGrid.Cornered(results, out loc, false)) { //if (results[loc.Clockwise90()] || results[loc.CounterClockwise90()]) //{ // spec.GenDeploy.Element = DiagonalWall.Get(spec.Random); //} //else if (results[loc]) { spec.GenDeploy.Element = CornerWallFilled.Get(spec.Random); } else { spec.GenDeploy.Element = CornerWall.Get(spec.Random); } spec.GenDeploy.RotateToPoint(loc.Clockwise()); } else if (spec.GenGrid.TShape(results, out loc)) { if (results[loc.Clockwise()] && results[loc.CounterClockwise()]) { spec.GenDeploy.Element = EdgeWall.Get(spec.Random); } else if (results[loc.Clockwise()] || results[loc.CounterClockwise()]) { spec.GenDeploy.Element = PWall.Get(spec.Random); if (results[loc.Clockwise()]) { spec.GenDeploy.XScale *= -1; } } else { spec.GenDeploy.Element = TWall.Get(spec.Random); } spec.GenDeploy.RotateToPoint(loc); } else { Counter numCorners = new Counter(); spec.GenGrid.DrawCorners(spec.DeployX, spec.DeployY, _test.IfThen(Draw.Count <GenSpace>(numCorners))); switch (numCorners) { case 0: spec.GenDeploy.Element = QuadWall.Get(spec.Random); spec.GenDeploy.Rotate(spec.Random.NextRotation()); break; case 1: spec.GenGrid.GetCorner(results, out loc); spec.GenDeploy.Element = TriWall.Get(spec.Random); spec.GenDeploy.RotateToPoint(loc.Clockwise()); break; case 2: spec.GenGrid.GetCorner(results, out loc); results[loc] = false; GridLocation loc2; spec.GenGrid.GetCorner(results, out loc2); loc2 = loc2.Merge(loc); if (loc2 == GridLocation.CENTER) { spec.GenDeploy.Element = DualInverseCornerWall.Get(spec.Random); spec.GenDeploy.RotateToPoint(loc.Clockwise(), spec.Random); } else { spec.GenDeploy.Element = TEdgeWall.Get(spec.Random); spec.GenDeploy.RotateToPoint(loc2.Opposite()); } break; case 3: spec.GenGrid.GetCorner(!results, out loc); spec.GenDeploy.Element = InverseCornerWall.Get(spec.Random); spec.GenDeploy.RotateToPoint(loc.Clockwise()); break; case 4: spec.GenDeploy.Rotate(spec.Random.NextRotation()); placeFloor = false; break; } } if (placeFloor) { PlaceFloors(spec); } }
public override void PreDeployTweaks(ThemeElementSpec spec) { CenterAndRotateDoodad(spec); PlaceFloors(spec); }
public override void PreDeployTweaks(ThemeElementSpec spec) { base.PreDeployTweaks(spec); TombTopElement top = TombTop.Random(spec.Random); GenDeploy tombTop = new GenDeploy(top); }
protected void RotateDoodad(ThemeElementSpec spec) { HandleDoodad(spec, false, true); }
protected void CenterDoodad(ThemeElementSpec spec) { HandleDoodad(spec, true, false); }
protected void CenterAndRotateDoodad(ThemeElementSpec spec) { HandleDoodad(spec, true, true); }
public virtual void PreDeployTweaks(ThemeElementSpec spec) { }