虫洞
This commit is contained in:
@@ -62,6 +62,10 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
options.Add(new FloatMenuOption(p.LabelCap, pilotAction));
|
||||
}
|
||||
|
||||
// Add force launch option
|
||||
options.Add(new FloatMenuOption("ForceLaunch".Translate(), () => StartChoosingDestination(null)));
|
||||
|
||||
Find.WindowStack.Add(new FloatMenu(options));
|
||||
};
|
||||
|
||||
@@ -100,24 +104,47 @@ namespace ArachnaeSwarm
|
||||
return false;
|
||||
}
|
||||
|
||||
var mapParent = Find.WorldObjects.MapParentAt(t.Tile);
|
||||
|
||||
if (mapParent != null && mapParent.HasMap)
|
||||
{
|
||||
// Has map, let player choose local destination
|
||||
StartChoosingLocalDestination(mapParent.Map, pilot, t.Tile, distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No map, deploy to center
|
||||
Launch(t.Tile, pilot, distance, IntVec3.Invalid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StartChoosingLocalDestination(Map map, Pawn pilot, int tile, int distance)
|
||||
{
|
||||
CameraJumper.TryJump(new GlobalTargetInfo(map.Center, map));
|
||||
Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), localTarget =>
|
||||
{
|
||||
Launch(tile, pilot, distance, localTarget.Cell);
|
||||
});
|
||||
}
|
||||
|
||||
private void Launch(int destinationTile, Pawn pilot, int distance, IntVec3 arrivalCell)
|
||||
{
|
||||
float fuelCost = distance * Props.fuelPerTile;
|
||||
refuelableComp.ConsumeFuel(fuelCost);
|
||||
|
||||
// Despawn pilot from the source map
|
||||
pilot.DeSpawn();
|
||||
if(pilot != null) pilot.DeSpawn();
|
||||
|
||||
EffecterDefOf.Skip_Entry.Spawn(this.parent.Position, this.parent.Map);
|
||||
|
||||
// Create the traveling object
|
||||
var travelingWormhole = (TravelingWormhole)WorldObjectMaker.MakeWorldObject(DefDatabase<WorldObjectDef>.GetNamed("ARA_TravelingWormhole"));
|
||||
travelingWormhole.sourcePortal = this.PortalA;
|
||||
travelingWormhole.StartMove(parent.Map.Tile, t.Tile, pilot);
|
||||
travelingWormhole.StartMove(parent.Map.Tile, destinationTile, pilot, arrivalCell);
|
||||
|
||||
Find.WorldObjects.Add(travelingWormhole);
|
||||
|
||||
PortalA.status = WormholePortalStatus.Deploying;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace ArachnaeSwarm
|
||||
|
||||
private ThingOwner contents;
|
||||
|
||||
public IntVec3 specificArrivalCell = IntVec3.Invalid;
|
||||
|
||||
public override Material Material => def.Material;
|
||||
|
||||
public override Vector3 DrawPos => Vector3.Slerp(
|
||||
@@ -38,15 +40,17 @@ namespace ArachnaeSwarm
|
||||
Scribe_Values.Look(ref initialTile, "initialTile", 0);
|
||||
Scribe_Values.Look(ref traveledPct, "traveledPct", 0f);
|
||||
Scribe_Deep.Look(ref contents, "contents", this);
|
||||
Scribe_Values.Look(ref specificArrivalCell, "specificArrivalCell", IntVec3.Invalid);
|
||||
}
|
||||
|
||||
public void StartMove(int startTile, int destTile, Pawn pilot)
|
||||
|
||||
public void StartMove(int startTile, int destTile, Pawn pilot, IntVec3 arrivalCell)
|
||||
{
|
||||
initialTile = startTile;
|
||||
destinationTile = destTile;
|
||||
|
||||
this.Tile = startTile;
|
||||
contents.TryAdd(pilot, true);
|
||||
this.specificArrivalCell = arrivalCell;
|
||||
if (pilot != null) contents.TryAdd(pilot, true);
|
||||
}
|
||||
|
||||
protected override void Tick()
|
||||
@@ -63,31 +67,27 @@ namespace ArachnaeSwarm
|
||||
|
||||
private void Arrived()
|
||||
{
|
||||
if (contents.Any)
|
||||
Map targetMap = GetOrGenerateMapUtility.GetOrGenerateMap(destinationTile, WorldObjectDefOf.Camp);
|
||||
IntVec3 cell = specificArrivalCell.IsValid ? specificArrivalCell : DropCellFinder.RandomDropSpot(targetMap);
|
||||
Building_WormholePortal_B portalB = (Building_WormholePortal_B)ThingMaker.MakeThing(ThingDef.Named("ARA_WormholePortal_B"));
|
||||
GenSpawn.Spawn(portalB, cell, targetMap, WipeMode.Vanish);
|
||||
|
||||
Pawn pilot = contents.FirstOrDefault() as Pawn;
|
||||
if (pilot != null)
|
||||
{
|
||||
Pawn pilot = contents.First() as Pawn;
|
||||
if (pilot != null)
|
||||
{
|
||||
Map targetMap = GetOrGenerateMapUtility.GetOrGenerateMap(destinationTile, WorldObjectDefOf.Camp);
|
||||
|
||||
Building_WormholePortal_B portalB = (Building_WormholePortal_B)ThingMaker.MakeThing(ThingDef.Named("ARA_WormholePortal_B"));
|
||||
IntVec3 cell = DropCellFinder.RandomDropSpot(targetMap);
|
||||
GenSpawn.Spawn(portalB, cell, targetMap, WipeMode.Vanish);
|
||||
|
||||
IntVec3 pilotSpawnCell = CellFinder.RandomClosewalkCellNear(portalB.Position, targetMap, 5);
|
||||
GenSpawn.Spawn(pilot, pilotSpawnCell, targetMap, WipeMode.Vanish);
|
||||
|
||||
contents.Remove(pilot);
|
||||
|
||||
EffecterDefOf.Skip_Exit.Spawn(cell, targetMap);
|
||||
|
||||
if (sourcePortal != null && !sourcePortal.Destroyed)
|
||||
{
|
||||
sourcePortal.SetLinkedPortal(portalB); // This sets status to Linked
|
||||
portalB.SetLinkedPortal(sourcePortal);
|
||||
}
|
||||
}
|
||||
IntVec3 pilotSpawnCell = CellFinder.RandomClosewalkCellNear(portalB.Position, targetMap, 5);
|
||||
GenSpawn.Spawn(pilot, pilotSpawnCell, targetMap, WipeMode.Vanish);
|
||||
contents.Remove(pilot);
|
||||
}
|
||||
|
||||
EffecterDefOf.Skip_Exit.Spawn(cell, targetMap);
|
||||
|
||||
if (sourcePortal != null && !sourcePortal.Destroyed)
|
||||
{
|
||||
sourcePortal.SetLinkedPortal(portalB);
|
||||
portalB.SetLinkedPortal(sourcePortal);
|
||||
}
|
||||
|
||||
Find.WorldObjects.Remove(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user