Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions RimWorldOfMagic/RimWorldOfMagic/Building_LightningTrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Building_LightningTrap : Building_ExplosiveProximityTrap
public bool extendedTrap = false;
public bool iceTrap = false;

private FlyingObject_LightningTrap flyingObject; // Used to prevent duplicate eye spawning only. Not saved.

public override void ExposeData()
{
base.ExposeData();
Expand All @@ -24,25 +26,24 @@ public override void ExposeData()

public override void Spring(Pawn p)
{
if (flyingObject != null) return; // Prevent duplicate lightning eyes from spawning. Very op.
base.Spring(p);
IntVec3 targetPos = this.Position;
IntVec3 targetPos = Position;
targetPos.z += 2;
LocalTargetInfo t = targetPos;
float speed = .8f;
if(extendedTrap)
{
speed = .6f;
}
if (t.Cell != default(IntVec3))
if (t.Cell != default)
{
Thing eyeThing = new Thing();
eyeThing.def = TorannMagicDefOf.FlyingObject_LightningTrap;
FlyingObject_LightningTrap flyingObject = (FlyingObject_LightningTrap)GenSpawn.Spawn(TorannMagicDefOf.FlyingObject_LightningTrap, this.Position, this.Map);
flyingObject.Launch(p, this.Position.ToVector3Shifted(), t.Cell, eyeThing, this.Faction, null, speed);
flyingObject = (FlyingObject_LightningTrap)GenSpawn.Spawn(TorannMagicDefOf.FlyingObject_LightningTrap, Position, Map);
flyingObject.Launch(p, Position.ToVector3Shifted(), t.Cell, Faction, speed);
}
if(iceTrap)
{
AddSnowRadial(this.Position, this.Map, 6, 1.1f);
AddSnowRadial(Position, Map, 6, 1.1f);
}
}

Expand Down Expand Up @@ -73,4 +74,4 @@ public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
}
}
}
}
}
Loading