private static SymbolDef CreateSymbolDef(ThingDef thing, Rot4 rot) { SymbolDef symbolDef = new SymbolDef { defName = $"{thing.defName}_{rot.ToStringHuman()}", thingDef = thing, rotation = rot, }; sCreated++; return(symbolDef); }
public void GenerateQuad(IntVec3 CenterCell, Rot4 rot, List <IntVec3> QuadCells, float entranceChance, float radius, int minCaves) { Map map = BaseGen.globalSettings.map; List <IntVec3> nodes = new List <IntVec3>(); nodes.Add(CenterCell); // Log.Message("Generatirng " + rot.ToStringHuman().CapitalizeFirst() + " Quad Small Chambers"); Rand.PushState(); float dist2 = Rand.RangeInclusive(7, 10); Rand.PopState(); IntVec3 BigCaveCenter = cellforbigcave.Where(x => !bigCaveCenters.Any(y => x.DistanceTo(y) < 20)).RandomElement(); nodes.Add(BigCaveCenter); bigCaveCenters.Add(BigCaveCenter); List <IntVec3> BigCavecells = GenRadial.RadialCellsAround(BigCaveCenter, dist2, true).ToList(); cavecells.AddRange(BigCavecells); // Log.Message("Generatirng "+rot.ToStringHuman().CapitalizeFirst()+ " Quad Small Chambers"); Rand.PushState(); int cavecountSmall = Rand.RangeInclusive(minCaves, (int)radius / 10); Rand.PopState(); for (int i2 = 0; i2 < cavecountSmall; i2++) { Rand.PushState(); float dist = Rand.RangeInclusive(3, 6); Rand.PopState(); IntVec3 cell = cellforlittlecave.Where(x => !smallCaveCenters.Any(y => y.DistanceTo(x) < dist)).RandomElement(); nodes.Add(cell); smallCaveCenters.Add(cell); List <IntVec3> ccells = GenRadial.RadialCellsAround(cell, dist, true).ToList(); cavecells.AddRange(ccells); } Rand.PushState(); if (Rand.Chance(entranceChance)) { // Log.Message("Generatirng " + rot.ToStringHuman().CapitalizeFirst() + " Quad Entrance"); entranceChance -= 0.0f; float dist = Rand.RangeInclusive(3, 10); List <IntVec3> ecells = new List <IntVec3>(); ecells.AddRange(cells.Where(x => InQuad(x, CenterCell, rot) && GenRadial.RadialCellsAround(x, dist, true).Any(z => map.reachability.CanReachMapEdge(z, TraverseParms.For(TraverseMode.ByPawn))) && GenRadial.RadialCellsAround(x, dist, true).Any(z => QuadCells.Contains(z)))); IntVec3 cell = ecells.NullOrEmpty() ? IntVec3.Invalid : ecells.RandomElement(); if (cell != IntVec3.Invalid) { // nodes.Add(cell); List <IntVec3> ccells = GenRadial.RadialCellsAround(cell, dist, true).ToList(); cavecells.AddRange(ccells); entranceCaveCenters.Add(cell); List <IntVec3> tcells = nodes; /* * List<IntVec3> tcells = new List<IntVec3>(); * tcells.AddRange(smallCaveCenters); * tcells.AddRange(bigCaveCenters); */ List <IntVec3> ncells = new List <IntVec3>(); // ncells = tcells.Where(x => x.DistanceTo(CenterCell) < radius - 5 && !cell.WithinRegions(x, map, 10, TraverseParms.For(TraverseMode.ByPawn), RegionType.Set_Passable)).OrderBy(x => x.DistanceTo(cell)).ToList(); // Log.Message("Generatirng " + rot.ToStringHuman().CapitalizeFirst() + " Quad path " + ncells.Count + " Nodes located"); IntVec3 prevnode = cell; nodes.OrderByDescending(x => x.DistanceTo(prevnode)); for (int i = 0; i < nodes.Count; i++) { IntVec3 node = nodes[i]; IntVec3 offset = prevnode - node; float num = 0f; if ((prevnode.ToVector3() - node.ToVector3()).MagnitudeHorizontalSquared() > 0.001f) { num = (prevnode.ToVector3() - node.ToVector3()).AngleFlat(); } num += 90f; int trX = prevnode.x < node.x ? prevnode.x : node.x; int trY = prevnode.z < node.z ? prevnode.z : node.z; CellRect rect = new CellRect(trX, trY, (int)node.DistanceTo(prevnode), (int)node.DistanceTo(prevnode)); // Log.Message((i == 0 ? "Entrance at " : "Prevous node at ") + prevnode + " next node at " + node + " distance: " + node.DistanceTo(prevnode) + " Angele: " + num + " Bottom Left: " + rect.BottomLeft + " Top Right: " + rect.TopRight); Dig(prevnode, num, 3, rect.ToList(), map, closed: false); prevnode = node; } } else { Log.Warning("Generatirng " + rot.ToStringHuman().CapitalizeFirst() + " Quad Entrance, no suitable cell found out of " + ecells.Count + " potential targets"); } } Rand.PopState(); cellforlittlecave.RemoveAll(x => QuadCells.Contains(x)); cellforbigcave.RemoveAll(x => QuadCells.Contains(x)); }
public void DrawImplant() {// this.Pawn bool selected = Find.Selector.SelectedObjects.Contains(this.Pawn); HediffComp_DrawImplant comp = this; string direction = ""; float angle = 0f; float offset = 0f; float yvalue = Pawn.Drawer.DrawPos.y; Vector3 drawPos = Pawn.Drawer.DrawPos; drawPos.y = Altitudes.AltitudeFor((AltitudeLayer)17); Vector3 s = new Vector3(1.5f, 1.5f, 1.5f); PawnRenderer pawnRenderer = this.Pawn.Drawer.renderer; Rot4 rot = LayingFacing(); if (Pawn.CarriedBy != null) { #if DEBUG if (selected) { Log.Message(string.Format("{0} carried by {1} drawpos {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, drawPos, Pawn.CarriedBy.DrawPos)); } #endif drawPos.z = Pawn.CarriedBy.DrawPos.z; drawPos.x = Pawn.CarriedBy.DrawPos.x; } if (Pawn.InBed()) { if (Pawn.CurrentBed().Rotation == Rot4.South) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.South); } else if (Pawn.CurrentBed().Rotation == Rot4.North) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.North); } else if (Pawn.CurrentBed().Rotation == Rot4.East) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos.x += 0.3f; } else if (Pawn.CurrentBed().Rotation == Rot4.West) { #if DEBUG if (selected) { Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman())); } #endif drawPos.x -= 0.3f; } drawPos.y = yvalue; #if DEBUG if (selected) { Log.Message(string.Format("{0} in bed {1} drawpos modified to {2}", Pawn.Name, Pawn.InBed(), drawPos)); } #endif } if (offset < 0) { drawPos.y -= offset; } else { drawPos.y += offset; } if (Pawn.Downed) { angle = pawnRenderer.wiggler.downedAngle; if (Pawn.CarriedBy != null) { #if DEBUG if (selected) { Log.Message(string.Format("{0} carried by {1} angle {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, angle, Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle)); } #endif angle = Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle; } if (Pawn.InBed()) { if (Pawn.CurrentBed().Rotation == Rot4.South) { angle = 0f; } else if (Pawn.CurrentBed().Rotation == Rot4.North) { angle = 180f; } else if (Pawn.CurrentBed().Rotation == Rot4.East) { angle = 270; } else if (Pawn.CurrentBed().Rotation == Rot4.West) { angle = 90; } // angle = Pawn.CurrentBed().Rotation.AsAngle; } if (Pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja) { s = new Vector3(2f, 1.5f, 2f); if (rot.ToStringHuman() == "West" || rot == Rot4.West) { //drawPos.z -= 0.15f; // drawPos.x += 0.25f; } else { // drawPos.x += 0.25f; } } } #if DEBUG if (selected) { Log.Message(string.Format("{0}'s {1}, Rot:{2}, offset:{3}, x:{4}, z:{5}", Pawn.Label, this.parent.def.label, rot, offset, drawPos.x, drawPos.z)); Log.Message(string.Format("Rot ToStringHuman:{1}, FacingCell:{2}, AsVector2:{3}, AsByte:{4}, AsAngle:{5}", rot, rot.ToStringHuman(), rot.FacingCell, rot.AsVector2, rot.AsByte, rot.AsAngle)); } #endif Material matSingle = comp.ImplantMaterial(Pawn, rot); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s); Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0); }