Exemplo n.º 1
0
        private static Gizmo GetSquadTeleGizmo(Pawn pawn)
        {
            // Log.Warning("YES");
            Command_TargetPlus command_Target = new Command_TargetPlus();

            command_Target.defaultLabel = "ChronoTeleport".Translate();


            TargetingParameters tp = new TargetingParameters();

            tp.canTargetBuildings = false;
            tp.canTargetFires     = false;
            tp.canTargetLocations = true;
            tp.canTargetPawns     = false;
            tp.canTargetSelf      = false;

            command_Target.disabled        = pawn.stances.stunner.Stunned || !pawn.drafter.Drafted;
            command_Target.targetingParams = tp;
            command_Target.hotKey          = KeyBindingDefOf.Misc4;
            command_Target.icon            = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true);

            command_Target.aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true);

            command_Target.action = delegate(LocalTargetInfo target)
            {
                IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                {
                    Pawn pawn3 = x as Pawn;
                    return(pawn3 != null && pawn3.IsColonistPlayerControlled && pawn3.Drafted);
                }).Cast <Pawn>();

                List <Pawn> tmpPawns  = enumerable.ToList <Pawn>();
                List <Pawn> tmpPawns2 = new List <Pawn>();
                foreach (Pawn pawn2 in tmpPawns)
                {
                    {
                        Pawn casterPawn = pawn2;
                        Map  map        = pawn2.Map;

                        IEnumerable <Thing> thi = map.thingGrid.ThingsAt(target.Cell);
                        foreach (Thing th in thi)
                        {
                            if (th is Building)
                            {
                                Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                                return;
                            }
                        }

                        MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1, 1, 1));
                        // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                        // for (int asd = 0; asd < 60; asd++)
                        MoteMaker.ThrowExplosionCell(casterPawn.Position, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1f, 1, 1));
                        double dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) + Math.Pow(casterPawn.Position.z - target.Cell.z, 2));
                        if (dist < 20)
                        {
                            dist = 20;
                        }


                        pawn2.DeSpawn(DestroyMode.Vanish);
                        GenSpawn.Spawn(casterPawn, target.Cell, map, WipeMode.Vanish);

                        casterPawn.drafter.Drafted = true;
                        tmpPawns2.Add(casterPawn);

                        SoundStarter.PlayOneShot(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move", true), casterPawn);
                        SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay", true));
                        DamageInfo dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null, casterPawn.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                        casterPawn.TakeDamage(dinfo);
                    }
                }
                foreach (Pawn pps in tmpPawns2)
                {
                    Find.Selector.SelectedObjects.Add(pps);
                }
            };
            return(command_Target);
        }
        private static Gizmo GetSquadTeleGizmo(Pawn pawn)
        {
            // Log.Warning("YES");
            var command_Target = new Command_TargetPlus {
                defaultLabel = "ChronoTeleport".Translate()
            };


            var tp = new TargetingParameters
            {
                canTargetBuildings = false,
                canTargetFires     = false,
                canTargetLocations = true,
                canTargetPawns     = false,
                canTargetSelf      = false
            };

            command_Target.disabled        = pawn.stances.stunner.Stunned || !pawn.drafter.Drafted;
            command_Target.targetingParams = tp;
            command_Target.hotKey          = KeyBindingDefOf.Misc4;
            command_Target.icon            = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport");

            command_Target.aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport");

            command_Target.action = delegate(LocalTargetInfo target)
            {
                var enumerable = Find.Selector.SelectedObjects.Where(x =>
                                                                     x is Pawn {
                    IsColonistPlayerControlled: true, Drafted: true
                }).Cast <Pawn>();

                var tmpPawns  = enumerable.ToList();
                var tmpPawns2 = new List <Pawn>();
                foreach (var pawn2 in tmpPawns)
                {
                    {
                        var casterPawn = pawn2;
                        var map        = pawn2.Map;

                        var thi = map.thingGrid.ThingsAt(target.Cell);
                        foreach (var th in thi)
                        {
                            if (th is not Building)
                            {
                                continue;
                            }

                            Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }

                        FleckMaker.ThrowExplosionCell(target.Cell, map, FleckDefOf.ExplosionFlash, new Color(1, 1, 1));
                        // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                        // for (int asd = 0; asd < 60; asd++)
                        FleckMaker.ThrowExplosionCell(casterPawn.Position, map, FleckDefOf.ExplosionFlash,
                                                      new Color(1f, 1, 1));
                        var dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) +
                                             Math.Pow(casterPawn.Position.z - target.Cell.z, 2));
                        if (dist < 20)
                        {
                            dist = 20;
                        }


                        pawn2.DeSpawn();
                        GenSpawn.Spawn(casterPawn, target.Cell, map);

                        casterPawn.drafter.Drafted = true;
                        tmpPawns2.Add(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move").PlayOneShot(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay").PlayOneShotOnCamera();

                        var dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null,
                                                   casterPawn.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                        casterPawn.TakeDamage(dinfo);
                    }
                }

                foreach (var pps in tmpPawns2)
                {
                    Find.Selector.SelectedObjects.Add(pps);
                }
            };