Esempio n. 1
0
 // Token: 0x06000027 RID: 39 RVA: 0x00002B44 File Offset: 0x00000D44
 public void UseJetPack(Pawn pilot, Thing JP, IntVec3 targCell)
 {
     if (!this.JPComposMentis(pilot, JP, out string Reason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.CantDo", pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!this.FlightChecksOK(pilot, JP, out string ChecksReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.ChecksReason", GenText.CapitalizeFirst(pilot.LabelShort), ChecksReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (JPUtility.ChkForDissallowed(pilot, out string DAllowReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.DAllowReason", GenText.CapitalizeFirst(pilot.LabelShort), DAllowReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!this.FlightCellCheck(pilot, targCell, this.JPFuelAmount, this.JPFuelRate, this.JPJumpRangeMin, this.JPJumpRangeMax, out string JumpReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.JumpReason", JumpReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!JPInjury.CheckForExplosion(this))
     {
         this.DoJumpJet(pilot, targCell);
         return;
     }
     JPInjury.DoJPExplosion(pilot, this.JPFuelAmount, this.JPFuelItem);
     this.JPFuelAmount = 0;
 }
Esempio n. 2
0
        // Token: 0x0600000B RID: 11 RVA: 0x000022A8 File Offset: 0x000004A8
        public static Command CampCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "Set-Up Camp";
            command_Action.defaultDesc  = "Set-Up Camp";
            command_Action.icon         = SetUpCampTextures.CampCommandTex;
            command_Action.action       = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_High, null);
                Camp(caravan);
            };
            bool flag = false;
            List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects;

            for (int i = 0; i < allWorldObjects.Count; i++)
            {
                WorldObject worldObject = allWorldObjects[i];
                bool        flag2       = worldObject.Tile == caravan.Tile && worldObject != caravan;
                if (flag2)
                {
                    flag = true;
                    break;
                }
            }
            bool flag3 = flag;

            if (flag3)
            {
                command_Action.Disable(Translator.Translate("CommandSettleFailOtherWorldObjectsHere"));
            }
            return(command_Action);
        }
Esempio n. 3
0
        public void UseShard()
        {
            SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
            Job job = new Job(YautjaDefOf.RRY_Yautja_HealthShard);

            base.Wearer.jobs.TryTakeOrderedJob(job, 0);
        }
Esempio n. 4
0
        // Token: 0x0600000C RID: 12 RVA: 0x00002204 File Offset: 0x00000404

        public void TendSelf()
        {
            SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
            Job job = new Job(YautjaDefOf.RRY_Yautja_TendSelf);

            base.Wearer.jobs.TryTakeOrderedJob(job, 0);
        }
Esempio n. 5
0
        // Token: 0x0600002C RID: 44 RVA: 0x000031D8 File Offset: 0x000013D8
        public void RefuelJP(Pawn pilot, Thing JP, bool Using)
        {
            if (Using)
            {
                if (this.JPComposMentis(pilot, JP, out string Reason))
                {
                    if (this.JPFuelAmount >= this.JPFuelMax)
                    {
                        Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.FullyFueled", GenText.CapitalizeFirst(JP.Label)), pilot, MessageTypeDefOf.NeutralEvent, false);
                        SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
                        return;
                    }
                    JobDef JPRefuel = DefDatabase <JobDef> .GetNamed("JPRefuel", true);

                    this.FindBestJPFuel(pilot, out Thing targ);
                    if (targ != null)
                    {
                        Job job = new Job(JPRefuel, targ);
                        pilot.jobs.TryTakeOrderedJob(job, 0);
                        return;
                    }
                    Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.NoFuelFound", GenText.CapitalizeFirst(this.JPFuelItem.label)), pilot, MessageTypeDefOf.NeutralEvent, false);
                    SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
                    return;
                }
                else
                {
                    Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.CantDo", pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent, false);
                    SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
                }
            }
        }
Esempio n. 6
0
        /*
         * Remove Construction Site
         */
        public static Command RemoveConstructionSite(int tile)
        {
            // TO DO : Refactor this so we find the site first, to pass it to Deleteconstructionsite directly, or even get rid of that function all together
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "RoadsOfTheRimRemoveConstructionSite".Translate();
            command_Action.defaultDesc  = "RoadsOfTheRimRemoveConstructionSiteDescription".Translate();
            command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/RemoveConstructionSite", true);

            command_Action.action = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.CancelMode, null);
                DeleteConstructionSite(tile);
            };
            // Test when the RemoveConstructionSite action should be disabled (i.e. there's no construction site here)
            bool ConstructionSiteAlreadyHere = false;

            try
            {
                ConstructionSiteAlreadyHere = Find.WorldObjects.AnyWorldObjectOfDefAt(DefDatabase <WorldObjectDef> .GetNamed("RoadConstructionSite", true), tile);
            }
            catch
            {
            }
            if (!ConstructionSiteAlreadyHere)
            {
                command_Action.Disable("RoadsOfTheRimBuildConstructionSiteNotAlreadyHere".Translate());
            }
            return(command_Action);
        }
Esempio n. 7
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f - 17f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.TryAccept())
                {
                    SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_High, null);
                    this.Close(false);
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            if (this.ShowCancelButton)
            {
                Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
                {
                    this.Close(true);
                }
            }
        }
Esempio n. 8
0
        private void trainPawnDone(String def)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed(def, true), Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null);
            Pawn item            = PawnGenerator.GeneratePawn(request);
            Pawn_StoryTracker ps = item.story;

            ps.childhood        = null;
            ps.adulthood        = null;
            ps.traits.allTraits = new List <Trait>();
            ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier", true)));
            ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath));


            Pawn_WorkSettings pws = item.workSettings;

            pws.DisableAll();
            Pawn_PlayerSettings pps = item.playerSettings;

            pps.hostilityResponse = HostilityResponseMode.Attack;

            NameTriple triple = NameTriple.FromString(item.kindDef.label.Replace(" ", ""));

            item.Name = triple;
            item.inventory.DestroyAll();


            YuriSoldierMakeUp.tryMakeUp(item);



            SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed(this.parent.def.defName + "_UnitReady", true));


            IntVec3 loc = CellFinder.RandomClosewalkCellNear(this.parent.Position, this.parent.Map, 3, null);

            Pawn pp;

            if (this.trainPawns[0] != "ra2_AlliedTanya")
            {
                pp = (Pawn)(GenSpawn.Spawn(item, loc, this.parent.Map, WipeMode.Vanish));
            }
            else
            {
                // bool flag = true;
                if (getAllTanya().Count > 0)
                {
                    foreach (Pawn tanya in getAllTanya())
                    {
                        tanya.Destroy(DestroyMode.Vanish);
                    }
                }
                pp = (Pawn)(GenSpawn.Spawn(getTanya(), loc, this.parent.Map, WipeMode.Vanish));
            }


            this.trainPawns.Remove(this.trainPawns[0]);
            this.ticks = 0;
        }
 internal static void ProgressHalfQuadrum(IEnumerable <CompUniversalFermenter> comps)
 {
     foreach (CompUniversalFermenter comp in comps)
     {
         comp.ProgressTicks += GenDate.TicksPerQuadrum / 2;
     }
     gooseAngle = Rand.Range(0, 360);
     SoundStarter.PlayOneShotOnCamera(UF_DefOf.UF_Honk);
 }
Esempio n. 10
0
        // Token: 0x0600000C RID: 12 RVA: 0x0000231C File Offset: 0x0000051C
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_Tiny, null);
            Texture2D JPIcon = ContentFinder <Texture2D> .Get(Command_JetPack.JPIconPath, true);

            Find.Targeter.BeginTargeting(Command_JetPack.targParms, delegate(LocalTargetInfo target)
            {
                this.action(target.Cell);
            }, this.Pilot, null, JPIcon);
        }
Esempio n. 11
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_Tiny, null);
            Texture2D texture2D = ContentFinder <Texture2D> .Get("UI/Leap", true);

            Find.Targeter.BeginTargeting(ForLeapDestination(), delegate(LocalTargetInfo target)
            {
                this.action(target.Cell);
            }, this.pawn, null, texture2D);
        }
Esempio n. 12
0
        public void CollectTithes()
        {
            List <Building> list = Tithes.TitheUtilities.allTitheContainers;

            for (int i = 0; i < list.Count; i++)
            {
                list[i].Destroy(DestroyMode.Vanish);
            }
            SoundStarter.PlayOneShotOnCamera(SoundDefOf.Thunder_OnMap);

            Tithes.TitheUtilities.CalculateColonyTithes(this);
        }
Esempio n. 13
0
        // Token: 0x04000B62 RID: 2914
        //  public Building Barracks;



        private void canTrain(CompRefuelable cr, String def, float amount)
        {
            if (cr != null && cr.Fuel >= amount)
            {
                SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed(this.parent.def.defName + "_Training", true));
                this.trainPawns.Add(def);
                cr.ConsumeFuel(amount);
            }
            else
            {
                SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed("ra2_Click", true));
            }
        }
 internal static void EmptyObject(IEnumerable <CompUniversalFermenter> comps)
 {
     foreach (CompUniversalFermenter comp in comps)
     {
         if (comp.Finished)
         {
             Thing product = comp.TakeOutProduct();
             GenPlace.TryPlaceThing(product, comp.parent.Position, comp.parent.Map, ThingPlaceMode.Near);
         }
     }
     gooseAngle = Rand.Range(0, 360);
     SoundStarter.PlayOneShotOnCamera(UF_DefOf.UF_Honk);
 }
Esempio n. 15
0
        /*
         * Stop working on  Site
         */
        public static Command StopWorkingOnSite(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "RoadsOfTheRimStopWorkingOnSite".Translate();
            command_Action.defaultDesc  = "RoadsOfTheRimStopWorkingOnSiteDescription".Translate();
            command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/RemoveConstructionSite", true);

            command_Action.action = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.CancelMode, null);
                caravan.GetComponent <WorldObjectComp_Caravan>().stopWorking();
            };
            return(command_Action);
        }
 internal static void FillObject(IEnumerable <CompUniversalFermenter> comps)
 {
     {
         foreach (CompUniversalFermenter comp in comps)
         {
             if (comp.Empty)
             {
                 Thing ingredient = ThingMaker.MakeThing(comp.CurrentProcess.ingredientFilter.AnyAllowedDef);
                 ingredient.stackCount = comp.SpaceLeftForIngredient;
                 comp.AddIngredient(ingredient);
             }
         }
         gooseAngle = Rand.Range(0, 360);
         SoundStarter.PlayOneShotOnCamera(UF_DefOf.UF_Honk);
     }
 }
 internal static void FinishProcess(IEnumerable <CompUniversalFermenter> comps)
 {
     foreach (CompUniversalFermenter comp in comps)
     {
         if (comp.CurrentProcess.usesQuality)
         {
             comp.ProgressTicks = Mathf.RoundToInt(comp.DaysToReachTargetQuality * GenDate.TicksPerDay);
         }
         else
         {
             comp.ProgressTicks = Mathf.RoundToInt(comp.CurrentProcess.processDays * GenDate.TicksPerDay);
         }
     }
     gooseAngle = Rand.Range(0, 360);
     SoundStarter.PlayOneShotOnCamera(UF_DefOf.UF_Honk);
 }
Esempio n. 18
0
 public override void Tick()
 {
     base.Tick();
     Burnticks--;
     if (Burnticks == 600)
     {
         Messages.Message(Translator.Translate("NuclearStrikeIncoming"), MessageSound.Standard);
         Find.TickManager.slower.SignalForceNormalSpeed();
     }
     if (Burnticks == 480)
     {
         SoundStarter.PlayOneShotOnCamera(Building_WarheadDeployed.Siren);
     }
     if (Burnticks == 0)
     {
         this.GetComp <CompExplosiveNuke>().StartWick();
     }
 }
 internal static void LogSpeedFactors()
 {
     foreach (Thing thing in Find.Selector.SelectedObjects.OfType <Thing>())
     {
         CompUniversalFermenter comp = thing.TryGetComp <CompUniversalFermenter>();
         if (comp != null)
         {
             Log.Message(comp.parent.ToString() + ": " +
                         "sun: " + comp.CurrentSunFactor.ToStringPercent() +
                         "| rain: " + comp.CurrentRainFactor.ToStringPercent() +
                         "| snow: " + comp.CurrentSnowFactor.ToStringPercent() +
                         "| wind: " + comp.CurrentWindFactor.ToStringPercent() +
                         "| roofed: " + comp.RoofCoverage.ToStringPercent());
         }
     }
     gooseAngle = Rand.Range(0, 360);
     SoundStarter.PlayOneShotOnCamera(UF_DefOf.UF_Honk);
 }
Esempio n. 20
0
        /*
         * Work on  Site
         */
        public static Command WorkOnSite(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "RoadsOfTheRimWorkOnSite".Translate();
            command_Action.defaultDesc  = "RoadsOfTheRimWorkOnSiteDescription".Translate();
            command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/AddConstructionSite", true);

            command_Action.action = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
                caravan.GetComponent <WorldObjectComp_Caravan>().startWorking();
            };
            // disable if the caravan can't work OR if the site is not ready
            if (caravan.GetComponent <WorldObjectComp_Caravan>().CaravanCurrentState() != CaravanState.ReadyToWork)
            {
                command_Action.Disable("RoadsOfTheRimBuildWorkOnSiteCantWork".Translate(caravan.GetDescription()));
            }
            return(command_Action);
        }
Esempio n. 21
0
 // Token: 0x06000002 RID: 2 RVA: 0x00002067 File Offset: 0x00000267
 public override void DoEffect(Pawn usedBy)
 {
     base.DoEffect(usedBy);
     if (PropsResourceBox.soundDef != null)
     {
         SoundStarter.PlayOneShotOnCamera(PropsResourceBox.soundDef, usedBy.MapHeld);
     }
     this.OpenBox(usedBy);
     if (PropsResourceBox.destoryOnUse && Rand.Chance(PropsResourceBox.destroyChance))
     {
         if (this.parent.stackCount == 1)
         {
             this.parent.Destroy();
         }
         else
         {
             this.parent.stackCount--;
         }
     }
 }
Esempio n. 22
0
        public override void Tick()
        {
            base.Tick();
            if (this.ExactPosition == Vector3.zero)
            {
                SoundStarter.PlayOneShotOnCamera(SoundDef.Named("ra2_NuclearAlert"));
                SoundStarter.PlayOneShotOnCamera(SoundDef.Named("ra2_NuclearLaunch"));
                this.ExactPosition = this.TrueCenter() + new Vector3(0.5f, 10, 5);
            }

            if (speed < 1f)
            {
                speed += 0.002f;
            }

            this.ExactPosition += new Vector3(0, 0, speed);
            MoteMaker.ThrowExplosionCell((this.ExactPosition + new Vector3(0, 0, -5)).ToIntVec3(), this.Map, ThingDefOf.Mote_ExplosionFlash, new Color(1, 0, 0));
            if (this.ExactPosition.z >= this.Map.Size.z)
            {
                Booom();
                this.Destroy(DestroyMode.Vanish);
            }
        }
Esempio n. 23
0
        public void CreateSelector(Rect rect, float curLine, string skillName, ref bool useSkill, ref int minLevel)
        {
            Rect rect2 = new Rect(26f, curLine, 100f, 30f);
            Rect rect3 = new Rect(136f, curLine, 40f, 30f);
            Rect rect4 = new Rect(116f, curLine, 10f, 20f);
            Rect rect5 = new Rect(186f, curLine, 10f, 20f);

            Widgets.Label(rect2, skillName);
            Widgets.Checkbox(2f, curLine, ref useSkill, 24f, false);
            Widgets.Label(rect3, Convert.ToString(minLevel));
            checked {
                if (Widgets.ButtonImage(rect4, TexUI.ArrowTexLeft))
                {
                    if (minLevel > 0)
                    {
                        minLevel--;
                        SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click);
                    }
                    else
                    {
                        SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject);
                    }
                }
                if (Widgets.ButtonImage(rect5, TexUI.ArrowTexRight))
                {
                    if (minLevel < 20)
                    {
                        minLevel++;
                        SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click);
                    }
                    else
                    {
                        SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject);
                    }
                }
            }
        }
Esempio n. 24
0
        public static Command SetUpCampCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "SetUpCamp".Translate();
            command_Action.defaultDesc  = "SetUpCampDesc".Translate();
            command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/SetUpCamp", true);

            command_Action.action = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_High, null);
                Camp(caravan);
            };
            tmpSettleFailReason.Length = 0;
            if (!TileFinder.IsValidTileForNewSettlement(caravan.Tile, tmpSettleFailReason))
            {
                command_Action.Disable(tmpSettleFailReason.ToString());
            }
            if (Find.WorldObjects.AnyWorldObjectOfDefAt(SetUpCampDefOf.AbandonedCamp, caravan.Tile))
            {
                command_Action.Disable("SetUpCampOccupied".Translate());
            }
            return(command_Action);
        }
Esempio n. 25
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);
        }
Esempio n. 26
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);


            Toil gotoThing = new Toil();

            gotoThing.initAction = delegate
            {
                this.pawn.pather.StartPath(this.TargetThingA, PathEndMode.Touch);
            };
            gotoThing.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            gotoThing.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(gotoThing);

            Toil enchanting = new Toil();//actions performed to enchant an item

            enchanting.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            enchanting.FailOnDestroyedOrNull(TargetIndex.A);
            enchanting.initAction = delegate
            {
                actor    = enchanting.actor;
                thing    = TargetThingA;
                thingLoc = thing.Position;
                if (!(thing.def.IsMeleeWeapon || thing.def.IsRangedWeapon || thing.def.IsApparel))
                {
                    actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                    Log.Message("Failed to initialize enchanting - invalid item type.");
                }
                else if (thing.def.defName.Contains("TM_Artifact"))
                {
                    Messages.Message("TM_CannotEnchantArtifact".Translate(
                                         actor.LabelShort,
                                         thing.LabelShort
                                         ), MessageTypeDefOf.RejectInput);
                    actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                }
            };
            enchanting.tickAction = delegate
            {
                if (thing.Position != thingLoc || thing.Destroyed)
                {
                    actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                    Log.Message("Failed to complete enchanting - item being enchanted not at enchanting location or destroyed");
                }
                if (Find.TickManager.TicksGame % 5 == 0)
                {
                    TM_MoteMaker.ThrowEnchantingMote(TargetLocA.ToVector3Shifted(), actor.Map, .6f);
                }
            };
            enchanting.WithProgressBar(TargetIndex.A, delegate
            {
                if (thing == null)
                {
                    return(1f);
                }
                return(1f - (float)enchanting.actor.jobs.curDriver.ticksLeftThisToil / 240);
            }, false, 0f);
            enchanting.defaultCompleteMode = ToilCompleteMode.Delay;
            enchanting.defaultDuration     = 240;
            enchanting.AddFinishAction(delegate
            {
                CompEnchantedItem enchantment = thing.TryGetComp <CompEnchantedItem>();
                CompEnchant enchantingItem    = actor.TryGetComp <CompEnchant>();
                CompAbilityUserMagic pawnComp = actor.TryGetComp <CompAbilityUserMagic>();
                if (enchantment != null && enchantingItem != null && enchanting.actor.jobs.curDriver.ticksLeftThisToil < 1)
                {
                    if (EnchantItem(enchantingItem.enchantingContainer[0], enchantment))
                    {
                        enchantingItem.enchantingContainer[0].SplitOff(1).Destroy(DestroyMode.Vanish);
                        pawnComp.Mana.CurLevel -= .5f;
                        int num = Rand.Range(130, 180);
                        pawnComp.MagicUserXP += num;
                        MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + num, -1f);
                        MoteMaker.ThrowText(TargetLocA.ToVector3Shifted(), actor.Map, "TM_Enchanted".Translate(), -1);
                        SoundStarter.PlayOneShotOnCamera(TorannMagicDefOf.ItemEnchanted, null);
                    }
                    else
                    {
                        Messages.Message("TM_NothingEnchanted".Translate(actor.LabelShort, thing.LabelShort, enchantingItem.enchantingContainer[0].LabelShort), MessageTypeDefOf.RejectInput);
                    }

                    //DestroyEnchantingStone(enchantingItem.innerContainer[0]);
                }
                else
                {
                    Log.Message("Detected null enchanting comp.");
                }
            });
            yield return(enchanting);
        }
        public void DraggingUpdate(float mouseOffX, float rateFactor)
        {
            Update();

            int amount    = 0;
            int direction = 1;

            if (mouseOffX != 0)
            {
                float delta = Math.Abs(mouseOffX);
                if (delta > maxDelta)
                {
                    delta = maxDelta;
                }
                delta = delta * stretch;
                delta = scale / (delta * delta);
                if (lastUpdateTime > delta)
                {
                    amount = 0;
                    while (lastUpdateTime > delta)
                    {
                        lastUpdateTime -= delta;
                        amount++;
                    }
                }
            }

            if (mouseOffX < 0)
            {
                direction = -1;
            }

            AcceptanceReport acceptanceReport = null;

            if (amount != 0)
            {
                if (Event.current.shift)
                {
                    amount = amount * multiplier;
                }
                if (direction > 0)
                {
                    if (value < maxValue)
                    {
                        if (maxValue - value < amount)
                        {
                            value = maxValue;
                        }
                        else
                        {
                            value += amount;
                        }
                        acceptanceReport = true;
                    }
                    else
                    {
                        acceptanceReport = false;
                    }
                }
                else
                {
                    if (value > minValue)
                    {
                        if (minValue + amount > value)
                        {
                            value = minValue;
                        }
                        else
                        {
                            value -= amount;
                        }
                        acceptanceReport = true;
                    }
                    else
                    {
                        acceptanceReport = false;
                    }
                }
                if (acceptanceReport.Accepted)
                {
                    SoundStarter.PlayOneShotOnCamera(DragAmountChangedSound);
                    lastDragRealTime = Time.realtimeSinceStartup;
                }
            }
            if (valueUpdateCallback != null)
            {
                valueUpdateCallback(value);
            }
        }
 public void DraggingCompleted(float mouseOffX, float rateFactor)
 {
     SoundStarter.PlayOneShotOnCamera(DragEndSound);
     valueUpdateCallback = null;
 }
 public void DraggingStart(float mouseOffX, float rateFactor)
 {
     SoundStarter.PlayOneShotOnCamera(DragStartSound);
 }
Esempio n. 30
0
 private static void PlaySoundOf(TimeSpeed speed)
 {
     SoundStarter.PlayOneShotOnCamera(SoundDef.Named(TimeControls.SpeedSounds[(int)speed].ToString()), null);
 }