private Toil Toils_TryToAttachToWeaponBase(Pawn actor, TargetIndex thingInd, TargetIndex cellInd) { IntVec3 targetCell = pawn.jobs.curJob.GetTarget(cellInd).Cell; Thing weapon = pawn.jobs.curJob.GetTarget(thingInd).Thing; IEnumerable <Building_TurretWeaponBase> foundBuildings = Map.listerBuildings.AllBuildingsColonistOfClass <Building_TurretWeaponBase>(); if (foundBuildings == null) { return(null); } Building_TurretWeaponBase weaponBase = foundBuildings.Where(b => b.Position == targetCell).FirstOrDefault(); if (weapon == null || weaponBase == null) { return(null); } Toil toil = new Toil(); toil.initAction = () => { weaponBase.TryToInstallWeapon(weapon); // TEST Enabled -> Look at target, install weapon //IntVec3 lookAtCell = PawnRotator.RotFromAngleBiased((actor.Position - targetCell).AngleFlat).FacingCell; if (actor.carryTracker.TryDropCarriedThing(targetCell, ThingPlaceMode.Direct, out weapon)) { weapon.DeSpawn(); } }; toil.defaultCompleteMode = ToilCompleteMode.Instant; toil.defaultDuration = 0; return(toil); }
public TurretTop_TurretWeaponBase(Building_TurretWeaponBase ParentTurret) { parentTurret = ParentTurret; }