public override void DrawAt(Vector3 drawLoc, bool flip = false) { if (this.innerContainer.Any) { foreach (var item in innerContainer) { ActiveFlyer flyer = item as ActiveFlyer; if (flyer != null) { if (flyer.GetThingForGraphic() != null) { Pawn p = flyer.GetThingForGraphic() as Pawn; if (p != null) { // p.rotationTracker.Face(base.Position.ToVector3()); float angle = (base.Position.ToVector3() - drawLoc).AngleFlat(); p.Rotation = Pawn_RotationTracker.RotFromAngleBiased(angle); p.Drawer.DrawAt(drawLoc); return; } } } } } base.DrawAt(drawLoc, flip); }
public static Toil PlaceCarriedThingInCellFacing(TargetIndex facingTargetInd) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; if (actor.carryTracker.CarriedThing == null) { Log.Error(actor + " tried to place hauled thing in facing cell but is not hauling anything."); } else { LocalTargetInfo target = actor.CurJob.GetTarget(facingTargetInd); IntVec3 b = (!target.HasThing) ? target.Cell : target.Thing.OccupiedRect().ClosestCellTo(actor.Position); IntVec3 dropLoc = actor.Position + Pawn_RotationTracker.RotFromAngleBiased((actor.Position - b).AngleFlat).FacingCell; Thing thing = default(Thing); if (!actor.carryTracker.TryDropCarriedThing(dropLoc, ThingPlaceMode.Direct, out thing, (Action <Thing, int>)null)) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); } } }; return(toil); }
/// <summary> /// Use own Vehicle rotation to disallow moving rotation for various tasks such as Drafted /// </summary> /// <param name="__instance"></param> /// <returns></returns> public static bool UpdateVehicleRotation(Pawn_RotationTracker __instance, Pawn ___pawn) { if (___pawn is VehiclePawn vehicle) { if (vehicle.Destroyed || vehicle.jobs.HandlingFacing) { return(false); } if (vehicle.vPather.Moving) { if (vehicle.vPather.curPath == null || vehicle.vPather.curPath.NodesLeftCount < 1) { return(false); } vehicle.UpdateRotationAndAngle(); } else { //Stance busy code here if (vehicle.jobs.curJob != null) { //LocalTargetInfo target = shipPawn.CurJob.GetTarget(shipPawn.jobs.curDriver.rotateToFace); //Face Target here } if (vehicle.Drafted) { //Ship Pawn Rotation stays the same } } return(false); } return(true); }
public static bool UpdateRotation(Pawn_RotationTracker __instance) { Pawn pawn = pawnField(__instance); if (pawn.Destroyed || pawn.jobs.HandlingFacing) { return(false); } if (pawn.pather.Moving) { if (pawn.pather.curPath != null && pawn.pather.curPath.NodesLeftCount >= 1) { FaceAdjacentCell2(pawn, pawn.pather.nextCell); } return(false); } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } return(false); } Job job = pawn.CurJob; //ADDED if (job != null) //CHANGED { Pawn_JobTracker jobs = pawn.jobs; if (jobs != null) { JobDriver jobDriver = jobs.curDriver; if (jobDriver != null) { LocalTargetInfo target = job.GetTarget(jobDriver.rotateToFace); //CHANGED __instance.FaceTarget(target); } } } if (pawn.Drafted) { pawn.Rotation = Rot4.South; } return(false); }
static bool Prefix(ref Pawn_RotationTracker __instance, ref Pawn ___pawn) { if (!___pawn.Destroyed && ___pawn.jobs.curDriver is JobDriver_Mounted jobDriver) { ___pawn.Rotation = jobDriver.Rider.Rotation; return(false); //Log.Message("changing rotation for mech"); //__instance.Face(jobDriver.Rider.Rotation.FacingCell.ToVector3()); //return false; } return(true); }
static bool Prefix(ref Pawn_RotationTracker __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!pawn.Destroyed && pawn.jobs.curDriver is JobDriver_Mounted jobDriver) { pawn.Rotation = jobDriver.Rider.Rotation; return(false); //Log.Message("changing rotation for mech"); //__instance.Face(jobDriver.Rider.Rotation.FacingCell.ToVector3()); //return false; } return(true); }
static void Postfix(Pawn_RotationTracker __instance, ref Pawn ___pawn) { Stance_Busy stance_Busy = ___pawn.GetStancesOffHand().curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid && !___pawn.pather.Moving) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } } }
static void Postfix(Pawn_RotationTracker __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); Stance_Busy stance_Busy = pawn.GetStancesOffHand().curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid && !pawn.pather.Moving) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } } }
private RotationDirection GetRotDiretion() { float angle = (target.Position - pawn.Position).ToVector3().AngleFlat(); Rot4 rot = Pawn_RotationTracker.RotFromAngleBiased(angle); if (rot != pawn.Rotation.Opposite) { switch (pawn.Rotation.AsInt - rot.AsInt) { case 0: return(RotationDirection.None); case -1: return(RotationDirection.Clockwise); case 1: return(RotationDirection.Counterclockwise); } } return(RotationDirection.None); }
static bool Prefix(Pawn_RotationTracker __instance, IntVec3 c) { Pawn p = getter(__instance); IntVec3 pos = p.Position; int dx = pos.x - c.x; int dz = pos.z - c.z; if (dx != 0 || dz != 0) { if (Math.Abs(dx) > Math.Abs(dz)) { if (dx > 0) { p.Rotation = constRot4West; } else { p.Rotation = constRot4East; } } else { if (dz > 0) { p.Rotation = constRot4South; } else { p.Rotation = constRot4North; } } } return(false); }
static bool Prefix(Pawn_RotationTracker __instance, Vector3 p) { Pawn pawn = getter(__instance); Vector3 pos = pawn.DrawPos; float dx = pos.x - p.x; float dz = pos.z - p.z; if (Math.Abs(dx) > 9.99999944E-11f || Math.Abs(dz) > 9.99999944E-11f) { if (Math.Abs(dx) > Math.Abs(dz)) { if (dx > 0) { pawn.Rotation = constRot4West; } else { pawn.Rotation = constRot4East; } } else { if (dz > 0) { pawn.Rotation = constRot4South; } else { pawn.Rotation = constRot4North; } } } return(false); }
public static bool UpdateRotation(Pawn_RotationTracker __0) { var stances = GetStancesOffHand.DynamicInvoke(Traverse.Create(__0).Field("pawn").GetValue <Pawn>()); return(stances != null); }
public override void PassingParameters(ResolveParams rp) { //string defLogo = "AgencySymbolFloorPainting"; var defTable = "TableLong"; var defChair = "DiningChair"; var defLamp = "Jecrell_GasLamp"; var map = BaseGen.globalSettings.map; var rot = Rot4.North; var deskOffset = 1; //ThingDef logoDef = ThingDef.Named(defLogo); var thingDef = ThingDef.Named(defTable); var chairDef = ThingDef.Named(defChair); var lampDef = Utility.IsIndustrialAgeLoaded() ? ThingDef.Named(defLamp) : ThingDefOf.TorchLamp; var lampStuffDef = Utility.IsIndustrialAgeLoaded() ? ThingDefOf.Steel : null; var locationCenter = rp.rect.CenterCell; for (var i = 0; i < deskOffset; i++) { locationCenter -= GenAdj.AdjacentCells[rot.AsInt]; } var receptionCenter = rp.rect.CenterCell; for (var i = 0; i < deskOffset; i++) { receptionCenter += GenAdj.AdjacentCells[rot.AsInt]; } //Center logo //ThingDef stuff = null; //Thing logo = ThingMaker.MakeThing(logoDef, stuff); //logo.SetFaction(rp.faction, null); //GenSpawn.Spawn(logo, locationCenter, map, rot); //Reception table ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = ThingDefOf.WoodLog; } var thing = ThingMaker.MakeThing(thingDef, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, receptionCenter, map, rot); //Adjacent lamps var loc1 = Utility.GetCornerPos(thing.OccupiedRect(), 0) + GenAdj.AdjacentCells[Rot4.West.AsInt] + GenAdj.AdjacentCells[Rot4.West.AsInt]; var thing3 = ThingMaker.MakeThing(lampDef, lampStuffDef); GenSpawn.Spawn(thing3, loc1, map); var loc2 = Utility.GetCornerPos(thing.OccupiedRect(), 1) + GenAdj.AdjacentCells[Rot4.East.AsInt] + GenAdj.AdjacentCells[Rot4.East.AsInt]; var thing4 = ThingMaker.MakeThing(lampDef, lampStuffDef); GenSpawn.Spawn(thing4, loc2, map); if (thing.Spawned && thing.Position.InBounds(map)) { var rectToEdit = thing.OccupiedRect().ExpandedBy(1); var poss = new List <IntVec3>(); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.North)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.South)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.East)); poss.AddRange(rectToEdit.GetEdgeCells(Rot4.West)); poss.Remove(Utility.GetCornerPos(rectToEdit, 0)); poss.Remove(Utility.GetCornerPos(rectToEdit, 1)); poss.Remove(Utility.GetCornerPos(rectToEdit, 2)); poss.Remove(Utility.GetCornerPos(rectToEdit, 3)); foreach (var currentPos in poss.InRandomOrder()) { //CHAIR var angle = (currentPos - thing.Position).ToVector3().AngleFlat(); var newRot = Pawn_RotationTracker.RotFromAngleBiased(angle).Opposite; var thing2 = ThingMaker.MakeThing(chairDef, stuff); thing2.SetFaction(rp.faction); GenSpawn.Spawn(thing2, currentPos, map, newRot); } } //Four corners, four gas lamps. for (var i = 0; i < 1; i++) { var thing5 = ThingMaker.MakeThing(lampDef, lampStuffDef); var loc = Utility.GetCornerPos(rp.rect.ContractedBy(1), i); GenSpawn.Spawn(thing5, loc, map); } //Bring in MERF var singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(rp.faction, new LordJob_DefendBase(rp.faction, rp.rect.CenterCell), map); var resolveParams = rp; resolveParams.rect = rp.rect.ExpandedBy(1); resolveParams.faction = rp.faction; resolveParams.singlePawnLord = singlePawnLord; resolveParams.pawnGroupKindDef = PawnGroupKindDefOf.Combat; //CthulhuFactionsDefOf.ROM_AgencyMERF; float points = 10000; resolveParams.pawnGroupMakerParams = new PawnGroupMakerParms { tile = map.Tile, faction = rp.faction, points = points }; BaseGen.symbolStack.Push("pawnGroup", resolveParams); }