public override void Tick() { base.Tick(); Vector3 exactPosition = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); return; } Position = ExactPosition.ToIntVec3(); if (ticksToImpact <= 0) { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); return; } }
public override void Tick() { base.Tick(); if (ticksToImpact >= 0) { var effectRadial = GenRadial.RadialCellsAround(ExactPosition.ToIntVec3(), 2, true); DrawEffects(effectRadial); DoEffects(effectRadial); lastRadial = effectRadial; } ticksToImpact--; Position = ExactPosition.ToIntVec3(); if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Destroy(); } else { if (ticksToImpact > 0) { return; } if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } }
/// <summary> /// set pieces at destinationation cell and clear source cell /// </summary> /// <param name="game"></param> /// <returns></returns> public bool Complete(Game game) { DestinationCell.SetPiece(Piece); //destination cell is set with the piece SourceCell.SetPiece(null); game.Movements.Push(this); // add to movement stack in the game to keep track of all the movements return(true); }
//Unmodified public override void Tick() { base.Tick(); if (landed) { return; } Vector3 exactPosition = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(base.Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(DestroyMode.Vanish); return; } Vector3 exactPosition2 = ExactPosition; if (!def.projectile.flyOverhead && canFreeIntercept && CheckForFreeInterceptBetween(exactPosition, exactPosition2)) { return; } Position = ExactPosition.ToIntVec3(); if (ticksToImpact == 60f && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal && def.projectile.soundImpactAnticipate != null) { def.projectile.soundImpactAnticipate.PlayOneShot(this); } if (ticksToImpact <= 0) { if (DestinationCell.InBounds(base.Map)) { Position = DestinationCell; } ImpactSomething(); return; } if (ambientSustainer != null) { ambientSustainer.Maintain(); } // attack shooting expression if (this.launcher is Building_TurretGunCR == false) { if (Rand.Value > 0.7 && this.launcher.def.race.Humanlike && !robotBodyList.Contains(this.launcher.def.race.body.defName) && Gen.IsHashIntervalTick(launcher, Rand.Range(280, 700))) { AGAIN : string rndswear = RulePackDef.Named("AttackMote").Rules.RandomElement().Generate(); if (rndswear == "[swear]" || rndswear == "" || rndswear == " ") { goto AGAIN; } MoteMaker.ThrowText(launcher.Position.ToVector3Shifted(), this.launcher.Map, rndswear); } } }
private bool CheckSimpleLoop(DestinationCell d) { List <DestinationCell> cellsToCheck = new List <DestinationCell>(); cellsToCheck.AddRange(WinningDestinations); cellsToCheck.Add(d); foreach (DestinationCell dc in cellsToCheck) { int originalX = dc.X; int originalY = dc.Y; Dictionary <CellWalls, List <Direction> > loops = new Dictionary <CellWalls, List <Direction> >() { { CellWalls.DownAndLeft, new List <Direction>() { Direction.Up, Direction.Right, Direction.Down, Direction.Left, Direction.Right, Direction.Up, Direction.Left, Direction.Down } }, { CellWalls.LeftAndUp, new List <Direction>() { Direction.Down, Direction.Right, Direction.Up, Direction.Left, Direction.Right, Direction.Down, Direction.Left, Direction.Up } }, { CellWalls.UpAndRight, new List <Direction>() { Direction.Left, Direction.Down, Direction.Right, Direction.Up, Direction.Down, Direction.Left, Direction.Up, Direction.Right } }, { CellWalls.RightAndDown, new List <Direction>() { Direction.Up, Direction.Left, Direction.Down, Direction.Right, Direction.Left, Direction.Up, Direction.Right, Direction.Down } } }; int i = 0; for (int y = 0; y < 2; y++) { this.UpdateRobotPosition(0, this.RobotCurrentLocations[0], dc); this.MoveRobot(0, loops[dc.Walls][i++]); if (this.MoveRobot(0, loops[dc.Walls][i++]).Count == 0) { continue; } if (this.MoveRobot(0, loops[dc.Walls][i++]).Count == 0) { continue; } this.MoveRobot(0, loops[dc.Walls][i++]); if (this.RobotCurrentLocations[0].X == originalX && this.RobotCurrentLocations[0].Y == originalY) { return(true); } } } return(false); }
//Unmodified public void ForceInstantImpact() { if (!DestinationCell.InBounds(base.Map)) { Destroy(DestroyMode.Vanish); return; } ticksToImpact = 0; Position = DestinationCell; ImpactSomething(); }
public override void Tick() { if (AllComps != null) { int i = 0; int count = AllComps.Count; while (i < count) { AllComps[i].CompTick(); i++; } } if (landed) { return; } Vector3 exactPosition = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(DestroyMode.Vanish); return; } Vector3 exactPosition2 = ExactPosition; if (CheckForFreeInterceptBetween(exactPosition, exactPosition2)) { return; } Position = ExactPosition.ToIntVec3(); if (ticksToImpact == 60 && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal && this.def.projectile.soundImpactAnticipate != null) { def.projectile.soundImpactAnticipate.PlayOneShot(this); } if (ticksToImpact <= 0) { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); return; } if (ambientSustainer != null) { ambientSustainer.Maintain(); } }
public override void Tick() { base.Tick(); var unused = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else { Position = ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % rotationRate == 0) { rotation++; if (rotation >= 4) { rotation = 0; } EffectMaker.MakeEffect(WizardryDefOf.Mote_Sparks, DrawPos, Map, Rand.Range(.3f, .5f), (rotation * 90) + Rand.Range(-45, 45), Rand.Range(2, 3), Rand.Range(100, 200)); } if (ticksToImpact > 0) { return; } if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } if (midPoint) { ImpactSomething(); } else { ChangeDirection(); if (!rainStarted) { StartWeatherEffects(); } } } }
public override void Tick() { base.Tick(); age++; var unused = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else if (!ExactPosition.ToIntVec3().Walkable(Map)) { impactForce = (DestinationCell - ExactPosition.ToIntVec3()).LengthHorizontal + (speed * .2f); ImpactSomething(); } else { Position = ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % 3 == 0) { EffectMaker.MakeEffect(WizardryDefOf.Mote_RecedingFlame, ExactPosition, Map, .8f, (Quaternion.AngleAxis(90, Vector3.up) * flyingDirection).ToAngleFlat(), 2f, 0); rotation++; if (rotation >= 4) { rotation = 0; } } if (Find.TickManager.TicksGame % 12 == 0) { DoFlyingObjectDamage(); } if (ticksToImpact > 0) { return; } if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } }
public void CreateWinningDestination(int x, int y, int robotId, bool currentWinningCell, params Direction[] directions) { DestinationCell dc = new DestinationCell(this.Board[x, y]); dc.WinningRobotId = robotId; dc.CurrentWinningCell = currentWinningCell; if (currentWinningCell) { this.CurrentWinningDestination = dc; } this.WinningDestinations.Add(dc); this.CreateCellWall(this.Board[x, y], directions); }
public override void Tick() { base.Tick(); age++; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else if (!ExactPosition.ToIntVec3().Walkable(Map)) { earlyImpact = true; impactForce = (DestinationCell - ExactPosition.ToIntVec3()).LengthHorizontal + (speed * .2f); ImpactSomething(); } else { Position = ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % 3 == 0) { FleckMaker.ThrowDustPuff(Position, Map, Rand.Range(0.6f, .8f)); rotation++; if (rotation >= 4) { rotation = 0; } } if (Find.TickManager.TicksGame % 12 == 0) { DoFlyingObjectDamage(); } if (ticksToImpact > 0) { return; } if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } }
/// <summary> /// set piece back to source cell and clear destination cell /// draw an killed piece back /// if king was made during last move make it normal /// </summary> /// <param name="game"></param> /// <returns></returns> public bool Undo(Game game) { SourceCell.SetPiece(Piece); DestinationCell.SetPiece(null); game.UndoMovements.Push(this); if (KilledPiece != null) { game.board.content[KilledPiece.Y, KilledPiece.X].SetPiece(KilledPiece); game.board.content[KilledPiece.Y, KilledPiece.X].UnSelect(); } if (isKing) { Piece.MakeNormal(); } return(true); }
// Verse.Projectile public override void Tick() { //Log.Message("Tick"); if (landed) { return; } ticksToImpact--; if (ticksToImpact <= 0) { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); return; } ticksToImpact++; base.Tick(); }
public override void Tick() { base.Tick(); if (landed) { return; } Vector3 exactPosition = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(base.Map)) { ticksToImpact++; base.Position = ExactPosition.ToIntVec3(); Destroy(); return; } Vector3 exactPosition2 = ExactPosition; if (CheckForFreeInterceptBetween(exactPosition, exactPosition2)) { return; } base.Position = ExactPosition.ToIntVec3(); if (ticksToImpact == 60 && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal && def.projectile.soundImpactAnticipate != null) { def.projectile.soundImpactAnticipate.PlayOneShot(this); } if (ticksToImpact <= 0) { if (DestinationCell.InBounds(base.Map)) { base.Position = DestinationCell; } ImpactSomething(); } else if (ambientSustainer != null) { ambientSustainer.Maintain(); } }
public List <RobotMove> FindSolution() { NodeData nodeData = new NodeData(null, new Dictionary <int, Cell>(_model.RobotCurrentLocations)); Node root = new Node(nodeData, 0, null); _tree.Add(root.GetIndex(), root); _winningDestination = _model.CurrentWinningDestination.Copy(); for (int i = 0; i < _model.RobotCurrentLocations.Count; i++) { _robotsByPriority.Add(i); } _robotsByPriority = _robotsByPriority.OrderBy(r => r == _model.CurrentWinningDestination.WinningRobotId ? 0 : 1).ToList(); Recursive(0); if (_winningNode == null) { return(new List <RobotMove>()); } Node n = _winningNode; //Traverse up the tree, adding the moves made to get to the winning position. List <RobotMove> movesToWin = new List <RobotMove>(); while (n.Previous != null) { movesToWin.Add(n.Data.Move); n = n.Previous; } //This list is backwards, so we need to reverse it. movesToWin.Reverse(); Console.WriteLine(String.Format("Number of nodes evaluated: {0}", _numberOfNodesEvaluated)); Console.WriteLine(String.Format("Number of Nodes: {0}", _tree.Count)); return(movesToWin); }
public void UpdateRobotPosition(int robotId, Cell initialLoc, Cell newLoc) { Cell initialLocToUpdate = this.Board[initialLoc.X, initialLoc.Y]; Cell newLocToUpdate = this.Board[newLoc.X, newLoc.Y]; initialLocToUpdate.RobotID = -1; newLocToUpdate.RobotID = robotId; DestinationCell dc = this.WinningDestinations.FirstOrDefault(wd => wd.X == initialLoc.X && wd.Y == initialLoc.Y); if (dc != null) { dc.RobotID = -1; } dc = this.WinningDestinations.FirstOrDefault(wd => wd.X == newLoc.X && wd.Y == newLoc.Y); if (dc != null) { dc.RobotID = robotId; } this.RobotCurrentLocations[robotId] = newLocToUpdate; }
private void CreateWinningDestinations(int destinations, int robots, ref List <Cell> possibleWinningDestinations) { Random rand = new Random(); int xLength = this.Board.GetLength(0); int yLength = this.Board.GetLength(1); int r; Cell c; List <List <int> > quadrants = new List <List <int> >() { new List <int> { 0, 1, 2, 3 }, new List <int> { 0, 1, 2, 3 }, new List <int> { 0, 1, 2, 3 }, new List <int> { 0, 1, 2, 3 } }; for (int i = 0; i < destinations; i++) { if (possibleWinningDestinations.Count == 0) { break; } bool destinationAssigned = false; while (!destinationAssigned) { if (possibleWinningDestinations.Count == 0) { break; } c = possibleWinningDestinations[rand.Next(possibleWinningDestinations.Count)]; DestinationCell dc = new DestinationCell(c); //Create L shaped wall, but not an L shape that causes the following 1 space gap with an edge wall. // _ _ // | | // // |_ _| // List <int> triedWalls = new List <int> { 0, 1, 2, 3 }; //While (we have more walls to try) && (we haven't assigned walls to the destination) while (triedWalls.Count > 0 && dc.Walls == CellWalls.None) { r = rand.Next(4); switch (r) { case 0: if (((dc.Y + 2 <= yLength - 1 && dc.Y - 2 >= 0) && (this.Board[dc.X, dc.Y + 2].Walls.HasFlag(CellWalls.Up) || this.Board[dc.X, dc.Y - 2].Walls.HasFlag(CellWalls.Up))) || ((dc.X + 2 <= xLength - 1 && dc.X - 2 >= 0) && (this.Board[dc.X + 2, dc.Y].Walls.HasFlag(CellWalls.Right) || this.Board[dc.X - 2, dc.Y].Walls.HasFlag(CellWalls.Right))) || !quadrants[dc.GetQuadrant()].Contains(0)) { if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } CreateCellWall(dc, Direction.Up, Direction.Right); if (this.CheckForLoops(dc)) { RemoveCellWall(dc, Direction.Up, Direction.Right); if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } else { CreateCellWall(dc, Direction.Up, Direction.Right); quadrants[dc.GetQuadrant()].Remove(0); } break; case 1: if (((dc.Y + 2 <= yLength - 1 && dc.Y - 2 >= 0) && (this.Board[dc.X, dc.Y + 2].Walls.HasFlag(CellWalls.Down) || this.Board[dc.X, dc.Y - 2].Walls.HasFlag(CellWalls.Down))) || ((dc.X + 2 <= xLength - 1 && dc.X - 2 >= 0) && (this.Board[dc.X + 2, dc.Y].Walls.HasFlag(CellWalls.Right) || this.Board[dc.X - 2, dc.Y].Walls.HasFlag(CellWalls.Right))) || !quadrants[dc.GetQuadrant()].Contains(1)) { if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } CreateCellWall(dc, Direction.Right, Direction.Down); if (this.CheckForLoops(dc)) { RemoveCellWall(dc, Direction.Right, Direction.Down); if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } else { CreateCellWall(dc, Direction.Right, Direction.Down); quadrants[dc.GetQuadrant()].Remove(1); } break; case 2: if (((dc.Y + 2 <= yLength - 1 && dc.Y - 2 >= 0) && (this.Board[dc.X, dc.Y + 2].Walls.HasFlag(CellWalls.Down) || this.Board[dc.X, dc.Y - 2].Walls.HasFlag(CellWalls.Down))) || ((dc.X + 2 <= xLength - 1 && dc.X - 2 >= 0) && (this.Board[dc.X + 2, dc.Y].Walls.HasFlag(CellWalls.Left) || this.Board[dc.X - 2, dc.Y].Walls.HasFlag(CellWalls.Left))) || !quadrants[dc.GetQuadrant()].Contains(2)) { if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } CreateCellWall(dc, Direction.Down, Direction.Left); if (this.CheckForLoops(dc)) { RemoveCellWall(dc, Direction.Down, Direction.Left); if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } else { CreateCellWall(dc, Direction.Down, Direction.Left); quadrants[dc.GetQuadrant()].Remove(2); } break; case 3: if (((dc.Y + 2 <= yLength - 1 && dc.Y - 2 >= 0) && (this.Board[dc.X, dc.Y + 2].Walls.HasFlag(CellWalls.Up) || this.Board[dc.X, dc.Y - 2].Walls.HasFlag(CellWalls.Up))) || ((dc.X + 2 <= xLength - 1 && dc.X - 2 >= 0) && (this.Board[dc.X + 2, dc.Y].Walls.HasFlag(CellWalls.Left) || this.Board[dc.X - 2, dc.Y].Walls.HasFlag(CellWalls.Left))) || !quadrants[dc.GetQuadrant()].Contains(3)) { if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } CreateCellWall(dc, Direction.Left, Direction.Up); if (this.CheckForLoops(dc)) { RemoveCellWall(dc, Direction.Left, Direction.Up); if (triedWalls.Contains(r)) { triedWalls.Remove(r); } break; } else { CreateCellWall(dc, Direction.Left, Direction.Up); quadrants[dc.GetQuadrant()].Remove(3); } break; } } //None of the 4 L walls work for this position. Remove it, and try another cell. if (dc.Walls == CellWalls.None) { possibleWinningDestinations.Remove(dc); } else { int q = dc.GetQuadrant(); if (quadrants[q].Count == 0) { List <Cell> cellsToRemove = new List <Cell>(); foreach (Cell d in possibleWinningDestinations) { if (d.GetQuadrant() == q) { cellsToRemove.Add(d); } } foreach (Cell d in cellsToRemove) { possibleWinningDestinations.Remove(d); } } this.Board[c.X, c.Y] = dc; dc.WinningRobotId = rand.Next(robots); RemoveCells(c, true, ref possibleWinningDestinations); destinationAssigned = true; //Checking for loops actually adds to the history... just clear it for now i guess. dc.MoveHistory.Clear(); dc.PoppedHistory.Clear(); dc.CurrentWinningCell = false; this.WinningDestinations.Add(dc); } } } CurrentWinningDestination = WinningDestinations[0]; CurrentWinningDestination.CurrentWinningCell = true; }
public override void Tick() { base.Tick(); var exactPosition = ExactPosition; if (ticksToImpact >= 0 && moteDef != null && Find.TickManager.TicksGame % moteFrequency == 0) { DrawEffects(exactPosition); } if (isCircling && attackFrequency != 0 && Find.TickManager.TicksGame % attackFrequency == 0) { if (pawn.Destroyed || pawn.Dead) { age = duration; } else { DoFlyingObjectDamage(); if (assignedTargetPawn.Dead) { age = duration; } } } ticksToImpact--; age++; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else if (!ExactPosition.ToIntVec3().Walkable(Map) && !isCircling) { earlyImpact = true; impactForce = (DestinationCell - ExactPosition.ToIntVec3()).LengthHorizontal + (speed * .2f); ImpactSomething(); } else { Position = ExactPosition.ToIntVec3(); if (ticksToImpact <= 0) { if (curveVariance > 0) { if (curvePoints.Count - 1 > destinationCurvePoint) { origin = curvePoints[destinationCurvePoint]; destinationCurvePoint++; destination = curvePoints[destinationCurvePoint]; ticksToImpact = StartingTicksToImpact; } else { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } isCircling = true; variancePoints = 10; curveVariance = 60; speed = 10; moteFrequency = 4; NewSemiCircle(); } } else { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } } } if (age > duration) { Destroy(); } }
private bool CheckForFreeIntercept(IntVec3 c) { if (destination.ToIntVec3() == c) { return(false); } float num = VerbUtility.InterceptChanceFactorFromDistance(origin, c); if (num <= 0f) { return(false); } bool flag = false; List <Thing> thingList = c.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (!CanHit(thing)) { continue; } bool flag2 = false; if (thing.def.Fillage == FillCategory.Full) { Building_Door building_Door = thing as Building_Door; if (building_Door == null || !building_Door.Open) { ThrowDebugText("int-wall", c); Impact(thing); return(true); } flag2 = true; } float num2 = 0f; Pawn pawn = thing as Pawn; if (pawn != null) { num2 = 0.4f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != 0) { num2 *= 0.1f; } if (launcher != null && pawn.Faction != null && launcher.Faction != null && !pawn.Faction.HostileTo(launcher.Faction)) { num2 *= Find.Storyteller.difficultyValues.friendlyFireChanceFactor; } } else if (thing.def.fillPercent > 0.2f) { num2 = (flag2 ? 0.05f : ((!DestinationCell.AdjacentTo8Way(c)) ? (thing.def.fillPercent * 0.15f) : (thing.def.fillPercent * 1f))); } num2 *= num; if (num2 > 1E-05f) { if (Rand.Chance(num2)) { ThrowDebugText("int-" + num2.ToStringPercent(), c); Impact(thing); return(true); } flag = true; ThrowDebugText(num2.ToStringPercent(), c); } } if (!flag) { ThrowDebugText("o", c); } return(false); }
public override void Tick() { base.Tick(); age++; var unused = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else if (!ExactPosition.ToIntVec3().Walkable(Map)) { earlyImpact = true; impactForce = (DestinationCell - ExactPosition.ToIntVec3()).LengthHorizontal + (speed * .2f); ImpactSomething(); } else { Position = ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % 3 == 0) { FleckMaker.ThrowDustPuff(Position, Map, Rand.Range(0.8f, 1f)); rotation++; if (rotation >= 4) { rotation = 0; } var comp = pawn.GetComp <CompWizardry>(); if (comp.SecondTarget != null && !secondTarget) { origin = ExactPosition; if (comp.SecondTarget.Thing != null) { destination = comp.SecondTarget.Thing.Position.ToVector3Shifted(); assignedTarget = comp.SecondTarget.Thing; } else { destination = comp.SecondTarget.CenterVector3; } speed = 22f; ticksToImpact = StartingTicksToImpact; flyingDirection = GetVector(origin.ToIntVec3(), destination.ToIntVec3()); comp.SecondTarget = null; secondTarget = true; } } if (Find.TickManager.TicksGame % 12 == 0 && secondTarget) { DoFlyingObjectDamage(); } if (ticksToImpact > 0) { return; } if (age > duration || secondTarget) { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } else { origin = destination; speed = 5f; if (floatDir == 0) { destination.x += -.25f; destination.z += .25f; } else if (floatDir == 1) { destination.x += .25f; destination.z += .25f; } else if (floatDir == 2) { destination.x += .25f; destination.z += -.25f; } else { destination.x += -.25f; destination.z += -.25f; } floatDir++; if (floatDir > 3) { floatDir = 0; } ticksToImpact = StartingTicksToImpact; } } }
private bool CheckForFreeIntercept(IntVec3 c) { if (destination.ToIntVec3() == c) { return(false); } float num = VerbUtility.InterceptChanceFactorFromDistance(origin, c); if (num <= 0f) { return(false); } bool flag = false; List <Thing> thingList = c.GetThingList(Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (CanHit(thing)) { bool flag2 = false; if (thing.def.Fillage == FillCategory.Full) { if (!(thing is Building_Door building_Door) || !building_Door.Open) { ThrowDebugText("int-wall", c); Impact(thing); return(true); } flag2 = true; } float num2 = 0f; if (thing is Pawn pawn) { num2 = 0.4f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != PawnPosture.Standing) { num2 *= 0.1f; } if (launcher != null && pawn.Faction != null && launcher.Faction != null && !pawn.Faction.HostileTo(launcher.Faction)) { num2 *= 0.4f; } } else if (thing.def.fillPercent > 0.2f) { if (flag2) { num2 = 0.05f; } else if (DestinationCell.AdjacentTo8Way(c)) { num2 = thing.def.fillPercent * 1f; } else { num2 = thing.def.fillPercent * 0.15f; } } num2 *= num; if (num2 > 1E-05f) { if (Rand.Chance(num2)) { ThrowDebugText("int-" + num2.ToStringPercent(), c); Impact(thing); return(true); } flag = true; ThrowDebugText(num2.ToStringPercent(), c); } } } if (!flag) { ThrowDebugText("o", c); } return(false); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //Draw solid box in the middle if (_cell.Walls.HasFlag(CellWalls.Up) && _cell.Walls.HasFlag(CellWalls.Down) && _cell.Walls.HasFlag(CellWalls.Right) && _cell.Walls.HasFlag(CellWalls.Left)) { e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 32, 32)); return; } // - x // y if (_cell.Walls.HasFlag(CellWalls.Up)) //Up = left wall { e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 3, 32)); } if (_cell.Walls.HasFlag(CellWalls.Down)) //Down = right wall { e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(29, 0, 3, 32)); } if (_cell.Walls.HasFlag(CellWalls.Right)) //Right = down wall { e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 29, 32, 3)); } if (_cell.Walls.HasFlag(CellWalls.Left)) //Left = Up wall { e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 32, 3)); } if (_cell.RobotID != -1) { e.Graphics.FillEllipse(new SolidBrush(_settings.RobotColors[_cell.RobotID]), 6, 6, 20, 20); } DestinationCell dc = _cell as DestinationCell; if (dc != null && dc.CurrentWinningCell) { //This is the same SalesPad Promotions star character i believe. using (Font f = new Font("Tahoma", 16, FontStyle.Regular)) using (Brush b = new SolidBrush(_settings.RobotColors[dc.WinningRobotId])) e.Graphics.DrawString("★", f, b, 3, 3); } //Draw Solved Path onto the board. //Solved Path Lines.png - interesections are separated by a pixel, so they don't overlap on top of each other. // For some reason, the pixels seem to be 1 off when drawing onto the buttons? Not sure. Adding 1 cause them to line up. if (_settings.ShowSolvedPath) { int tempRobotPath = _cell.RobotPath; for (int i = 0; i < 4; i++) { int xyCord = 12 + (i * 2); int leftLength = xyCord + 1; int upLength = xyCord + 1; int rightLength = 32 - leftLength + 1; int downLength = 32 - upLength + 1; if ((tempRobotPath & 0x1) == 0x1) //Up = left { e.Graphics.FillRectangle(new SolidBrush(_settings.RobotColors[i]), new Rectangle(0, xyCord, leftLength, 1)); } tempRobotPath = tempRobotPath >> 1; if ((tempRobotPath & 0x1) == 0x1) //Down = right { e.Graphics.FillRectangle(new SolidBrush(_settings.RobotColors[i]), new Rectangle(xyCord, xyCord, rightLength, 1)); } tempRobotPath = tempRobotPath >> 1; if ((tempRobotPath & 0x1) == 0x1) //Right = down { e.Graphics.FillRectangle(new SolidBrush(_settings.RobotColors[i]), new Rectangle(xyCord, xyCord, 1, downLength)); } tempRobotPath = tempRobotPath >> 1; if ((tempRobotPath & 0x1) == 0x1) //Left = up { e.Graphics.FillRectangle(new SolidBrush(_settings.RobotColors[i]), new Rectangle(xyCord, 0, 1, upLength)); } tempRobotPath = tempRobotPath >> 1; } } if (_cell.Deflector != null) { switch (_cell.Deflector.DeflectorType) { case DeflectorType.Backward: e.Graphics.DrawLine(new Pen(_settings.RobotColors[_cell.Deflector.RobotID]), 0, 0, 32, 32); break; case DeflectorType.Forward: e.Graphics.DrawLine(new Pen(_settings.RobotColors[_cell.Deflector.RobotID]), 0, 32, 32, 0); break; } } if (_cell.Portal != null) { e.Graphics.DrawEllipse(new Pen(_settings.RobotColors[_cell.Portal.RobotID]), new Rectangle(12, 0, 8, 32)); } }
private bool CheckForLoops(DestinationCell d) { return(CheckBoardTraversal()); //return CheckSimpleLoop(d); }