diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll
index 3f3203c..9e1a2e1 100644
Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ
diff --git a/1.6/1.6/Defs/JobDefs/ARA_Jobs_Wormhole.xml b/1.6/1.6/Defs/JobDefs/ARA_Jobs_Wormhole.xml
new file mode 100644
index 0000000..be5bd2f
--- /dev/null
+++ b/1.6/1.6/Defs/JobDefs/ARA_Jobs_Wormhole.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ ARA_DeployWormhole
+ ArachnaeSwarm.JobDriver_DeployWormhole
+ deploying wormhole.
+ true
+
+
+
\ No newline at end of file
diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
index 9f760d3..874f0b2 100644
--- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
+++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
@@ -209,6 +209,7 @@
+
diff --git a/Source/ArachnaeSwarm/Wormhole/Building_WormholePortal_A.cs b/Source/ArachnaeSwarm/Wormhole/Building_WormholePortal_A.cs
index a753ca8..ab64112 100644
--- a/Source/ArachnaeSwarm/Wormhole/Building_WormholePortal_A.cs
+++ b/Source/ArachnaeSwarm/Wormhole/Building_WormholePortal_A.cs
@@ -2,6 +2,7 @@ using RimWorld;
using RimWorld.Planet;
using System.Collections.Generic;
using Verse;
+using Verse.AI;
namespace ArachnaeSwarm
{
@@ -136,6 +137,50 @@ namespace ArachnaeSwarm
}
}
+ public override IEnumerable GetFloatMenuOptions(Pawn selPawn)
+ {
+ foreach (var option in base.GetFloatMenuOptions(selPawn))
+ {
+ yield return option;
+ }
+
+ if (status == WormholePortalStatus.Linked)
+ {
+ yield break;
+ }
+
+ if (!selPawn.CanReach(this, PathEndMode.Touch, Danger.Deadly))
+ {
+ yield return new FloatMenuOption("CannotUseNoPath".Translate(), null);
+ yield break;
+ }
+
+ var compLaunchable = this.GetComp();
+ var compRefuelable = this.GetComp();
+
+ if (compRefuelable.Fuel < compLaunchable.Props.fuelNeededToLaunch)
+ {
+ yield return new FloatMenuOption("CommandDeployWormholePortalB_Pilot".Translate() + " (" + "NotEnoughFuel".Translate() + ")", null);
+ yield break;
+ }
+
+ // TODO: Create ARA_DeployWormhole JobDef
+ var jobDef = DefDatabase.GetNamed("ARA_DeployWormhole", false);
+ if (jobDef == null)
+ {
+ yield return new FloatMenuOption("DEV: JobDef ARA_DeployWormhole not found", null);
+ yield break;
+ }
+
+ void action()
+ {
+ var job = JobMaker.MakeJob(jobDef, this);
+ selPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
+ }
+
+ yield return new FloatMenuOption("CommandDeployWormholePortalB_Pilot".Translate(), action);
+ }
+
public override string GetInspectString()
{
string text = base.GetInspectString();
diff --git a/Source/ArachnaeSwarm/Wormhole/CompLaunchableWormhole.cs b/Source/ArachnaeSwarm/Wormhole/CompLaunchableWormhole.cs
index e1e481e..6501727 100644
--- a/Source/ArachnaeSwarm/Wormhole/CompLaunchableWormhole.cs
+++ b/Source/ArachnaeSwarm/Wormhole/CompLaunchableWormhole.cs
@@ -21,45 +21,8 @@ namespace ArachnaeSwarm
public override IEnumerable CompGetGizmosExtra()
{
- if (PortalA?.status == WormholePortalStatus.Linked)
- {
- yield break;
- }
-
- Command_Action launchCommand = new Command_Action();
- launchCommand.defaultLabel = "CommandDeployWormholePortalB_Pilot".Translate();
- launchCommand.defaultDesc = "CommandDeployWormholePortalB_PilotDesc".Translate();
- launchCommand.icon = ContentFinder.Get("UI/Commands/LaunchShip");
-
- if (refuelableComp.Fuel < this.Props.fuelNeededToLaunch)
- {
- launchCommand.Disable("NotEnoughFuel".Translate());
- }
-
- launchCommand.action = delegate
- {
- var targetingParameters = new TargetingParameters
- {
- canTargetPawns = true,
- canTargetBuildings = false,
- mapObjectTargetsMustBeAutoAttackable = false,
- validator = (TargetInfo target) =>
- {
- if (!target.HasThing) return false;
- Pawn p = target.Thing as Pawn;
- return p != null && p.IsColonistPlayerControlled && !p.Downed && !p.IsBurning();
- }
- };
- Find.Targeter.BeginTargeting(targetingParameters, (LocalTargetInfo target) =>
- {
- Pawn pilot = target.Pawn;
- if (pilot != null)
- {
- StartChoosingDestination(pilot);
- }
- });
- };
- yield return launchCommand;
+ // The gizmo is now replaced by a float menu option.
+ yield break;
}
public void StartChoosingDestination(Pawn pilot)
diff --git a/Source/ArachnaeSwarm/Wormhole/JobDriver_DeployWormhole.cs b/Source/ArachnaeSwarm/Wormhole/JobDriver_DeployWormhole.cs
new file mode 100644
index 0000000..fe0b565
--- /dev/null
+++ b/Source/ArachnaeSwarm/Wormhole/JobDriver_DeployWormhole.cs
@@ -0,0 +1,45 @@
+using System.Collections.Generic;
+using Verse;
+using Verse.AI;
+
+namespace ArachnaeSwarm
+{
+ public class JobDriver_DeployWormhole : JobDriver
+ {
+ private Building_WormholePortal_A PortalA => (Building_WormholePortal_A)job.targetA.Thing;
+
+ public override bool TryMakePreToilReservations(bool errorOnFailed)
+ {
+ return pawn.Reserve(job.targetA, job, 1, -1, null, errorOnFailed);
+ }
+
+ protected override IEnumerable MakeNewToils()
+ {
+ this.FailOnDespawnedOrNull(TargetIndex.A);
+ this.FailOn(() => PortalA.status == WormholePortalStatus.Linked);
+
+ // Go to Portal A
+ yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
+
+ // Wait a bit to simulate 'entering'
+ Toil waitToil = Toils_General.Wait(120).WithProgressBarToilDelay(TargetIndex.A);
+ waitToil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
+ yield return waitToil;
+
+ // Start the deployment process
+ Toil deployToil = new Toil();
+ deployToil.initAction = delegate
+ {
+ var comp = PortalA.GetComp();
+ if (comp != null)
+ {
+ // This will open the world map targeting UI
+ // The actual teleportation of the pilot happens inside StartChoosingDestination -> ChoseWorldTarget -> Deploy
+ comp.StartChoosingDestination(pawn);
+ }
+ };
+ deployToil.defaultCompleteMode = ToilCompleteMode.Instant;
+ yield return deployToil;
+ }
+ }
+}
\ No newline at end of file