Пример #1
0
        public static GameCondition EnforceConditionOn2(CompCauseGameCondition __instance, Map map)
        {
            GameCondition gameCondition = GetConditionInstance2(__instance, map);

            if (gameCondition == null)
            {
                gameCondition = CreateConditionOn2(__instance, map);
            }
            else
            {
                gameCondition.TicksLeft = gameCondition.TransitionTicks;
            }

            return(gameCondition);
        }
Пример #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            GameConditionManager gameConditionManager = parms.target.GameConditionManager;
            int           duration = Mathf.RoundToInt(def.durationDays.RandomInRange * 60000f);
            GameCondition cond     = GameConditionMaker.MakeCondition(def.gameCondition, duration);

            gameConditionManager.RegisterCondition(cond);
            SendStandardLetter(parms, null);
            return(true);
        }
        public static bool CreateConditionOn(CompCauseGameCondition __instance, ref GameCondition __result, Map map)
        {
            GameCondition gameCondition = GameConditionMaker.MakeCondition(__instance.ConditionDef);

            gameCondition.Duration        = gameCondition.TransitionTicks;
            gameCondition.conditionCauser = __instance.parent;
            map.gameConditionManager.RegisterCondition(gameCondition);
            lock (__instance)
            {
                causedConditionsFieldRef(__instance).Add(map, gameCondition);
            }
            gameCondition.suppressEndMessage = true;
            __result = gameCondition;
            return(false);
        }
Пример #4
0
        public override void WorldComponentTick()
        {
            base.WorldComponentTick();
            if (!moons.NullOrEmpty())
            {
                foreach (var moon in moons)
                {
                    moon.Tick();
                }
            }

            if (gcMoonCycle == null)
            {
                gcMoonCycle = GameConditionMaker.MakeConditionPermanent(WWDefOf.ROM_MoonCycle);
                Find.World.gameConditionManager.RegisterCondition(gcMoonCycle);
            }

            if (recentWerewolves.Any())
            {
                recentWerewolves.RemoveAll(x => x.Key.Dead || x.Key.DestroyedOrNull());
            }

            if (!recentWerewolves.Any())
            {
                return;
            }

            var recentVampiresKeys = new List <Pawn>(recentWerewolves.Keys);

            foreach (var key in recentVampiresKeys)
            {
                recentWerewolves[key] += 1;
                if (recentWerewolves[key] <= 100)
                {
                    continue;
                }

                recentWerewolves.Remove(key);
                if (!key.Spawned || key.Faction == Faction.OfPlayerSilentFail)
                {
                    continue;
                }

                Find.LetterStack.ReceiveLetter("ROM_WerewolfEncounterLabel".Translate(),
                                               "ROM_WerewolfEncounterDesc".Translate(key.LabelShort), LetterDefOf.ThreatSmall, key);
            }
        }
Пример #5
0
        public override void End()
        {
            for (int i = 0; i < spawnedThings.Count; i++)
            {
                Pawn p = spawnedThings[i];
                if (!p.DestroyedOrNull())
                {
                    if (p.Map != null)
                    {
                        p.Map.weatherManager.eventHandler.AddEvent(new TM_WeatherEvent_MeshFlash(p.Map, p.Position, TM_MatPool.redLightning));
                    }
                    p.Destroy(DestroyMode.Vanish);
                }
            }
            List <GameCondition> gcs      = new List <GameCondition>();
            GameCondition        gcClouds = null;
            GameCondition        gcVW     = null;

            gcs = this.SingleMap.GameConditionManager.ActiveConditions;
            for (int i = 0; i < gcs.Count; i++)
            {
                if (gcs[i].def == TorannMagicDefOf.DarkClouds)
                {
                    gcClouds = gcs[i];
                }
                else if (gcs[i].def == GameConditionDefOf.VolcanicWinter)
                {
                    gcVW = gcs[i];
                }
            }
            if (gcClouds != null)
            {
                gcClouds.End();
            }
            if (gcVW != null)
            {
                gcVW.End();
            }
            MagicMapComponent mmc = this.SingleMap.GetComponent <MagicMapComponent>();

            if (mmc != null)
            {
                mmc.allowAllIncidents = false;
            }
            base.End();
        }
 private void SolarFlareShieldTick(int tickAmount)
 {
     if ((Find.TickManager.TicksGame) % tickAmount == 0)
     {
         if (compPowerTrader == null || compPowerTrader.PowerOn)
         {
             coordinator.hasActiveShield = true;
             GameCondition gameCondition =
                 Find.World.GameConditionManager.GetActiveCondition(GameConditionDefOf.SolarFlare);
             if (gameCondition != null)
             {
                 compPowerTrader.PowerOutput = -properties.shieldingPowerDrain;
                 rotatorAngle += properties.rotatorSpeedActive * tickAmount;
                 RoomGroup roomGroup = parent.GetRoomGroup();
                 if (roomGroup != null && !roomGroup.UsesOutdoorTemperature)
                 {
                     roomGroup.Temperature += properties.heatingPerTick * tickAmount;
                 }
                 if ((Find.TickManager.TicksGame) % (5 * tickAmount) == 0)
                 {
                     foreach (Building building in parent.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial))
                     {
                         Building_CommsConsole console = building as Building_CommsConsole;
                         if (console != null)
                         {
                             CompPowerTrader consoleCompPowerTrader = console.TryGetComp <CompPowerTrader>();
                             if (consoleCompPowerTrader != null)
                             {
                                 consoleCompPowerTrader.PowerOn = false;
                             }
                         }
                     }
                 }
             }
             else
             {
                 compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption;
                 rotatorAngle += properties.rotatorSpeedIdle * tickAmount;
             }
         }
         else
         {
             coordinator.hasActiveShield = false;
         }
     }
 }
 public override void WorldComponentTick()
 {
     base.WorldComponentTick();
     if (!moons.NullOrEmpty())
     {
         foreach (Moon moon in moons)
         {
             moon.Tick();
         }
     }
     if (gcMoonCycle == null)
     {
         gcMoonCycle           = new GameCondition_MoonCycle();
         gcMoonCycle.Permanent = true;
         Find.World.gameConditionManager.RegisterCondition(gcMoonCycle);
     }
 }
        public static bool GetConditionInstance(CompCauseGameCondition __instance, ref GameCondition __result, Map map)
        {
            if (!causedConditionsFieldRef(__instance).TryGetValue(map, out GameCondition value) && __instance.Props.preventConditionStacking)
            {
                value = map.GameConditionManager.GetActiveCondition(__instance.Props.conditionDef);
                if (value != null)
                {
                    lock (__instance)
                    {
                        causedConditionsFieldRef(__instance).Add(map, value);
                    }
                    value.suppressEndMessage = true;
                }
            }

            __result = value;
            return(false);
        }
Пример #9
0
        public SplashScreen(Game game, Vector2 pos, float timeLeft,
                            Texture2D txMain, Texture2D txGameOver, Queue <Texture2D> txQueue,
                            Song menuMusic, Song playMusic, Song pauseMusic, Song gameOverMusic, Song winMusic,
                            Keys pauseKey, Keys activateKey, Buttons activateButton, Buttons pauseButton,
                            SpriteFont fontIn, SoundEffect blinkPlay, SoundEffect blinkPause) : base(game)
        {
            game.Components.Add(this);
            DrawOrder = 1000;

            _txMain  = txMain;
            _txBlack = new Texture2D(game.GraphicsDevice, 1, 1);
            _txBlack.SetData(new[] { new Color(0, 0, 0, 255) });
            _txWhite = new Texture2D(game.GraphicsDevice, 1, 1);
            _txWhite.SetData(new[] { Color.White });
            _txGameOver     = txGameOver;
            this.txWinQueue = txQueue;
            txWin           = txWinQueue.Dequeue();
            txWinQueue.Enqueue(txWin);
            Position             = pos;
            ActivationKey        = activateKey;
            ActivationButton     = activateButton;
            PauseKey             = pauseKey;
            PauseButton          = pauseButton;
            Font                 = fontIn;
            TimeRemaining        = timeLeft;
            CurrentScreen        = ActiveScreen.MAIN;
            CurrentGameCondition = GameCondition.LOSE;
            OverlayAlpha         = 1;
            Active               = true;

            #region Load Audio
            MenuTrack     = menuMusic;
            BackingTrack  = playMusic;
            PauseTrack    = pauseMusic;
            GameOverTrack = gameOverMusic;
            WinTrack      = winMusic;
            BlinkPlay     = blinkPlay;
            BlinkPause    = blinkPause;
            #endregion

            MediaPlayer.Volume      = VOLUME;
            MediaPlayer.IsRepeating = true;
        }
 private void SolarFlareShieldTick(int tickAmount)
 {
     if ((Find.TickManager.TicksGame) % tickAmount == 0)
     {
         if (Active)
         {
             GameCondition gameCondition =
                 Find.World.GameConditionManager.GetActiveCondition(GameConditionDefOf.SolarFlare);
             if (gameCondition != null)
             {
                 compPowerTrader.PowerOutput = -Properties.shieldingPowerDrain;
                 rotatorAngle += Properties.rotatorSpeedActive * tickAmount;
                 var map = parent.Map;
                 if (map != null)
                 {
                     GenTemperature.PushHeat(parent.Position, parent.Map, Properties.heatingPerTick * tickAmount);
                 }
                 if ((Find.TickManager.TicksGame) % (5 * tickAmount) == 0)
                 {
                     foreach (Thing building in parent.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial))
                     {
                         if (building is Building_CommsConsole console)
                         {
                             CompPowerTrader consoleCompPowerTrader = console.TryGetComp <CompPowerTrader>();
                             if (consoleCompPowerTrader != null)
                             {
                                 consoleCompPowerTrader.PowerOn = false;
                             }
                         }
                     }
                 }
             }
             else
             {
                 compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption;
                 rotatorAngle += Properties.rotatorSpeedIdle * tickAmount;
             }
         }
     }
 }
Пример #11
0
 private static void Postfix(GameCondition __instance)
 {
     foreach (var map in __instance.AffectedMaps)
     {
         if (ZUtils.ZTracker.GetZIndexFor(map) == 0)
         {
             foreach (var otherMap in ZUtils.ZTracker.GetAllMaps(map.Tile))
             {
                 if (ZUtils.ZTracker.GetZIndexFor(otherMap) != 0)
                 {
                     for (int num = otherMap.gameConditionManager.ActiveConditions.Count - 1; num >= 0; num--)
                     {
                         if (otherMap.gameConditionManager.ActiveConditions[num].def == __instance.def)
                         {
                             otherMap.gameConditionManager.ActiveConditions[num].End();
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #12
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            if (!LoadedModManager.GetMod <MonsterHunterRimworldMod>().GetSettings <MonsterHunterRimworldModSettings>().elderDragonWeatherEffects)
            {
                return;
            }
            if (!(parent is Pawn elderDragon))
            {
                return;
            }
            if (!WyvernUtility.IsElderDragon(elderDragon))
            {
                return;
            }
            if (elderDragon.Dead)
            {
                return;
            }
            Map map = elderDragon.Map;

            if (map == null)
            {
                return;
            }

            GameConditionManager gameConditionManager = map.GameConditionManager;

            if (gameConditionManager.ConditionIsActive(GameConditionDefOf.ToxicFallout))
            {
                return;
            }
            int           duration = Mathf.RoundToInt(0.5f * 60000f); // lasts half a day after elder dragon dies
            GameCondition cond     = GameConditionMaker.MakeCondition(GameConditionDefOf.ToxicFallout, duration);

            gameConditionManager.RegisterCondition(cond);
        }
        public override void Execute(int amount, string boughtBy)
        {
            GameConditionDef conditionDef = DefDatabase <GameConditionDef> .GetNamed(defName);

            String notificationMessage;

            // I hope no viewer uses RC with the name "Poll"
            if (boughtBy == "Poll")
            {
                notificationMessage = $"<color=#9147ff>By popular opinion</color>, your channel has triggered {defLabel} for a whole day! Let's hope you get out the other side";
            }
            else
            {
                notificationMessage = $"<color=#9147ff>{boughtBy}</color> purchased {defLabel} for a whole day! Let's hope you get out the other side";
            }

            Map map = Find.CurrentMap;

            GameCondition gameCondition = GameConditionMaker.MakeCondition(conditionDef, 60000);

            map.gameConditionManager.RegisterCondition(gameCondition);

            AlertManager.BadEventNotification(notificationMessage);
        }
Пример #14
0
 public BehaviorSkill(string skillName, GameCondition overrideCondition = GameCondition.None)
 {
     SkillName         = skillName;
     OverrideCondition = overrideCondition;
 }
Пример #15
0
 public static void SetupCondition2(GameCondition condition, Map map)
 {
     condition.suppressEndMessage = true;
 }
Пример #16
0
        public override void Update(GameTime gameTime)
        {
            float deltaTime = gameTime.ElapsedGameTime.Milliseconds;

            switch (CurrentScreen)
            {
            case ActiveScreen.MAIN:
                if (Active)
                {
                    if (MediaPlayer.State == MediaState.Stopped)
                    {
                        MediaPlayer.Play(MenuTrack);
                    }
                }
                else
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(BackingTrack);
                    CurrentScreen = ActiveScreen.PLAY;
                }

                if (fadeIn && OverlayAlpha <= 1)
                {
                    OverlayAlpha -= FADE_AMOUNT;
                }

                // Check Input
                if (InputEngine.IsKeyPressed(ActivationKey) ||
                    InputEngine.IsButtonPressed(ActivationButton))
                {
                    OverlayAlpha = 1;
                    BlinkPlay.Play();
                    Active = !Active;
                    Helper.CurrentGameStatus = GameStatus.PLAYING;
                }

                break;

            case ActiveScreen.PLAY:
                TilePlayer player = (TilePlayer)Game.Services.GetService(typeof(TilePlayer));

                if (Active)
                {
                    MediaPlayer.Stop();
                    PauseTime     = gameTime.TotalGameTime;
                    CurrentScreen = ActiveScreen.PAUSE;
                }

                if (player.Health > 0 && TimeRemaining > 0)
                {
                    TimeRemaining -= deltaTime;

                    // Check Input
                    if (InputEngine.IsKeyPressed(PauseKey) ||
                        InputEngine.IsButtonPressed(PauseButton))
                    {
                        Active = !Active;
                        BlinkPause.Play();
                        Helper.CurrentGameStatus = GameStatus.PAUSED;
                    }

                    if (OverlayAlpha <= 0)
                    {
                        fadeIn = false;
                    }
                    if (fadeIn && OverlayAlpha > 0)
                    {
                        OverlayAlpha -= FADE_AMOUNT;
                    }
                }
                else
                {
                    MediaPlayer.Stop();

                    // Wait for Input
                    if (InputEngine.IsPadInputChanged(true) ||
                        InputEngine.IsKeyInputChanged())
                    {
                        fadeOut = true;
                    }

                    if (fadeOut)
                    {
                        OverlayAlpha += FADE_AMOUNT;
                        if (OverlayAlpha >= 1)
                        {
                            Active = !Active;
                            CurrentGameCondition = GameCondition.LOSE;
                            CurrentScreen        = ActiveScreen.LOSE;
                            fadeIn = true;
                        }
                    }
                }

                if (CurrentGameCondition == GameCondition.WIN)
                {
                    OverlayAlpha += FADE_AMOUNT;
                    if (OverlayAlpha >= 1)
                    {
                        MediaPlayer.Stop();
                        Active        = !Active;
                        CurrentScreen = ActiveScreen.WIN;
                    }
                }
                break;

            case ActiveScreen.PAUSE:
                if (MediaPlayer.State == MediaState.Stopped)
                {
                    OverlayAlpha = 0.5f;
                    MediaPlayer.Play(PauseTrack);
                }

                if (!Active)
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(BackingTrack);
                    CurrentScreen          = ActiveScreen.PLAY;
                    gameTime.TotalGameTime = PauseTime;
                }

                // Check Input
                if (InputEngine.IsKeyPressed(PauseKey) ||
                    InputEngine.IsButtonPressed(PauseButton))
                {
                    OverlayAlpha = 0;
                    Active       = !Active;
                    BlinkPause.Play();
                    Helper.CurrentGameStatus = GameStatus.PLAYING;
                }
                break;

            case ActiveScreen.LOSE:
                if (OverlayAlpha <= 1 || OverlayAlpha > 0)
                {
                    OverlayAlpha -= FADE_AMOUNT;
                }

                if (MediaPlayer.State == MediaState.Stopped && TrackPlayCount < 1)
                {
                    MediaPlayer.Play(GameOverTrack);
                    TrackPlayCount++;
                    MediaPlayer.IsRepeating = false;
                }
                Helper.CurrentGameStatus = GameStatus.PAUSED;
                break;

            case ActiveScreen.WIN:
                if (OverlayAlpha <= 1 || OverlayAlpha > 0)
                {
                    OverlayAlpha -= FADE_AMOUNT;
                }

                if (MediaPlayer.State == MediaState.Stopped && TrackPlayCount < 1)
                {
                    MediaPlayer.Play(WinTrack);
                    TrackPlayCount++;
                }

                frameTime += gameTime.ElapsedGameTime;

                if (frameTime.Milliseconds > FRAME_SPEED)
                {
                    txWin = txWinQueue.Dequeue();
                    txWinQueue.Enqueue(txWin);
                    frameTime = TimeSpan.Zero;
                }

                Helper.CurrentGameStatus = GameStatus.PAUSED;
                break;

            default:
                break;
            }

            base.Update(gameTime);
        }
Пример #17
0
 private void Start()
 {
     gameCon = GameObject.FindGameObjectWithTag("Player").GetComponent <GameCondition>();
 }
Пример #18
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map  map = parms.target as Map;
            bool result;

            if (map == null)
            {
                result = false;
            }

            else if ((from wo in Find.WorldObjects.Sites
                      where wo is Site && wo.parts.Select(x => x.def) == SiteDefOfReconAndDiscovery.RD_QuakesQuest
                      select wo).Count <WorldObject>() > 0)
            {
                result = false;
            }
            else
            {
                int tile;
                if (TileFinder.TryFindNewSiteTile(out tile))
                {
                    Site site = (Site)WorldObjectMaker.MakeWorldObject(SiteDefOfReconAndDiscovery.RD_AdventureDestroyThing);
                    site.Tile = tile;
                    site.AddPart(new SitePart(site, SiteDefOfReconAndDiscovery.RD_QuakesQuest,
                                              SiteDefOfReconAndDiscovery.RD_QuakesQuest.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null)));
                    SitePart faultyGenerator = new SitePart(site, SiteDefOfReconAndDiscovery.RD_SitePart_FaultyGenerator,
                                                            SiteDefOfReconAndDiscovery.RD_SitePart_FaultyGenerator.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                    faultyGenerator.hidden = true;
                    site.parts.Add(faultyGenerator);
                    site.GetComponent <QuestComp_DestroyThing>().StartQuest(ThingDefOf.GeothermalGenerator);
                    site.GetComponent <QuestComp_DestroyThing>().gameConditionCaused = GameConditionDef.Named("RD_Tremors");
                    site.GetComponent <QuestComp_DestroyThing>().worldTileAffected   = map.Tile;
                    if (Rand.Value < 0.05f)
                    {
                        SitePart scatteredTreasure = new SitePart(site, SiteDefOfReconAndDiscovery.RD_ScatteredTreasure, SiteDefOfReconAndDiscovery.RD_ScatteredTreasure.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        scatteredTreasure.hidden = true;
                        site.parts.Add(scatteredTreasure);
                    }
                    if (Rand.Value < 0.1f)
                    {
                        SitePart scatteredManhunters = new SitePart(site, SiteDefOfReconAndDiscovery.RD_ScatteredManhunters, SiteDefOfReconAndDiscovery.RD_ScatteredManhunters.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        scatteredManhunters.hidden = true;
                        site.parts.Add(scatteredManhunters);
                    }
                    if (Rand.Value < 0.1f)
                    {
                        SitePart mechanoidForces = new SitePart(site, SiteDefOfReconAndDiscovery.RD_MechanoidForces, SiteDefOfReconAndDiscovery.RD_MechanoidForces.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        mechanoidForces.hidden = true;
                        site.parts.Add(mechanoidForces);
                    }
                    if (Rand.Value < 0.05f)
                    {
                        SitePart enemyRaidOnArrival = new SitePart(site, SiteDefOfReconAndDiscovery.RD_EnemyRaidOnArrival, SiteDefOfReconAndDiscovery.RD_EnemyRaidOnArrival.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        enemyRaidOnArrival.hidden = true;
                        site.parts.Add(enemyRaidOnArrival);
                    }
                    int           num           = 30;
                    GameCondition gameCondition = GameConditionMaker.MakeCondition(GameConditionDef.Named("RD_Tremors"), 60000 * num);
                    map.gameConditionManager.RegisterCondition(gameCondition);
                    site.GetComponent <TimeoutComp>().StartTimeout(num * 60000);
                    base.SendStandardLetter(parms, site);
                    Find.WorldObjects.Add(site);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Пример #19
0
        protected override bool TryCastShot()
        {
            bool flag   = false;
            Pawn caster = base.CasterPawn;

            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            pwrVal    = comp.MagicData.MagicPowerSkill_AlterFate.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AlterFate_pwr").level;
            arcaneDmg = comp.arcaneDmg;

            if (comp.predictionIncidentDef != null)
            {
                if (Rand.Chance((.25f + (.05f * pwrVal)) * this.arcaneDmg)) //success end
                {
                    //Log.Message("remove event");
                    List <QueuedIncident> iQue = Traverse.Create(root: Find.Storyteller.incidentQueue).Field(name: "queuedIncidents").GetValue <List <QueuedIncident> >();
                    if (iQue != null && iQue.Count > 0)
                    {
                        for (int i = 0; i < iQue.Count; i++)
                        {
                            //Log.Message("checking ique " + iQue[i].FiringIncident.def.defName + " against " + comp.predictionIncidentDef.defName);
                            if (iQue[i].FiringIncident.def == comp.predictionIncidentDef)
                            {
                                //Log.Message("Removing incident " + iQue[i].FiringIncident.def.defName);
                                iQue.Remove(iQue[i]);
                                if (Rand.Chance(.6f + (.1f * pwrVal)))
                                {
                                    this.confident = true;
                                }
                                else if (Rand.Chance(.1f))
                                {
                                    this.uneasy = true;
                                }
                                else
                                {
                                    this.unsure = true;
                                }
                                break;
                            }
                        }
                    }
                }
                else if (Rand.Chance(.2f - (.02f * pwrVal))) //shifting incident
                {
                    //Log.Message("shift event");
                    List <QueuedIncident> iQue = Traverse.Create(root: Find.Storyteller.incidentQueue).Field(name: "queuedIncidents").GetValue <List <QueuedIncident> >();
                    if (iQue != null && iQue.Count > 0)
                    {
                        for (int i = 0; i < iQue.Count; i++)
                        {
                            //Log.Message("checking ique " + iQue[i].FiringIncident.def.defName + " against " + comp.predictionIncidentDef.defName);
                            if (iQue[i].FiringIncident.def == comp.predictionIncidentDef)
                            {
                                //Log.Message("replacing incident " + iQue[i].FiringIncident.def.defName);
                                iQue.Remove(iQue[i]);
                            }
                        }
                    }

                    IEnumerable <IncidentDef> enumerable = from def in DefDatabase <IncidentDef> .AllDefs
                                                           where (def != comp.predictionIncidentDef && def.TargetAllowed(this.CasterPawn.Map))
                                                           orderby Rand.ValueSeeded(Find.TickManager.TicksGame)
                                                           select def;

                    foreach (IncidentDef item in enumerable)
                    {
                        //Log.Message("checking incident " + item.defName);
                        IncidentDef   localDef = item;
                        IncidentParms parms    = StorytellerUtility.DefaultParmsNow(localDef.category, this.CasterPawn.Map);
                        if (localDef.Worker.CanFireNow(parms))
                        {
                            QueuedIncident iq = new QueuedIncident(new FiringIncident(localDef, null, parms), comp.predictionTick);
                            Find.Storyteller.incidentQueue.Add(iq);
                            //Log.Message("queueing incident " + localDef.defName + " in " + comp.predictionTick + " ticks");
                            //localDef.Worker.TryExecute(parms);
                            if (Rand.Chance(.6f + (.1f * pwrVal)))
                            {
                                this.uneasy = true;
                            }
                            else if (Rand.Chance(.1f))
                            {
                                this.confident = true;
                            }
                            else
                            {
                                this.unsure = true;
                            }
                            break;
                        }
                    }
                }
                else if (Rand.Chance(.11f - (.011f * pwrVal))) //add another event
                {
                    //Log.Message("add event");
                    IEnumerable <IncidentDef> enumerable = from def in DefDatabase <IncidentDef> .AllDefs
                                                           where (def != comp.predictionIncidentDef && def.TargetAllowed(this.CasterPawn.Map))
                                                           orderby Rand.ValueSeeded(Find.TickManager.TicksGame)
                                                           select def;

                    foreach (IncidentDef item in enumerable)
                    {
                        //Log.Message("checking incident " + item.defName);
                        IncidentDef   localDef = item;
                        IncidentParms parms    = StorytellerUtility.DefaultParmsNow(localDef.category, this.CasterPawn.Map);
                        if (localDef.Worker.CanFireNow(parms))
                        {
                            QueuedIncident iq = new QueuedIncident(new FiringIncident(localDef, null, parms), comp.predictionTick + Rand.Range(-500, 10000));

                            Find.Storyteller.incidentQueue.Add(iq);
                            //Log.Message("queueing incident " + localDef.defName + " in " + comp.predictionTick + " ticks");
                            //localDef.Worker.TryExecute(parms);
                            if (Rand.Chance(.4f + (.1f * pwrVal)))
                            {
                                this.uneasy = true;
                            }
                            else if (Rand.Chance(.2f))
                            {
                                this.terrified = true;
                            }
                            else
                            {
                                this.unsure = true;
                            }
                            break;
                        }
                    }
                }
                else if (Rand.Chance(.05f - (.005f * pwrVal))) //butterfly effect
                {
                    int eventCount     = Rand.RangeInclusive(1, 5);
                    int butterflyCount = 0;
                    //Log.Message("butteryfly event");
                    IEnumerable <IncidentDef> enumerable = from def in DefDatabase <IncidentDef> .AllDefs
                                                           where (def.TargetAllowed(this.CasterPawn.Map))
                                                           orderby Rand.ValueSeeded(Find.TickManager.TicksGame)
                                                           select def;

                    foreach (IncidentDef item in enumerable)
                    {
                        //Log.Message("checking incident " + item.defName);
                        IncidentDef   localDef = item;
                        IncidentParms parms    = StorytellerUtility.DefaultParmsNow(localDef.category, this.CasterPawn.Map);
                        if (localDef.Worker.CanFireNow(parms))
                        {
                            int            eventTick = Find.TickManager.TicksGame + Rand.Range(0, 3600);
                            QueuedIncident iq        = new QueuedIncident(new FiringIncident(localDef, null, parms), eventTick);
                            Find.Storyteller.incidentQueue.Add(iq);
                            //Log.Message("queueing incident " + localDef.defName + " in " + eventTick + " ticks");
                            //localDef.Worker.TryExecute(parms);
                            butterflyCount++;
                            if (butterflyCount > eventCount)
                            {
                                if (Rand.Chance(.6f + (.1f * pwrVal)))
                                {
                                    this.terrified = true;
                                }
                                else if (Rand.Chance(.3f))
                                {
                                    this.uneasy = true;
                                }
                                else
                                {
                                    this.unsure = true;
                                }
                                break;
                            }
                        }
                    }
                }
                else // failed
                {
                    //Log.Message("failed event");
                    if (Rand.Chance(.6f + (.1f * pwrVal)))
                    {
                        this.unsure = true;
                    }
                    else if (Rand.Chance(.1f))
                    {
                        this.uneasy = true;
                    }
                    else
                    {
                        this.confident = true;
                    }
                    //Messages.Message("TM_AlterGameConditionFailed".Translate(this.CasterPawn.LabelShort, localGC.Label), MessageTypeDefOf.NeutralEvent);
                }
                DisplayConfidence(comp.predictionIncidentDef.label);
            }
            else if (pwrVal >= 3)
            {
                if (this.CasterPawn.Map.GameConditionManager.ActiveConditions.Count > 0)
                {
                    GameCondition localGC = null;
                    foreach (GameCondition activeCondition in this.CasterPawn.Map.GameConditionManager.ActiveConditions)
                    {
                        localGC = activeCondition;
                        if (activeCondition.TicksPassed < (2500 + (250 * pwrVal)))
                        {
                            if (Rand.Chance(.25f + (.05f * pwrVal))) //success
                            {
                                Messages.Message("TM_EndingGameCondition".Translate(this.CasterPawn.LabelShort, localGC.Label), MessageTypeDefOf.PositiveEvent);
                                localGC.End();
                            }
                            else if (Rand.Chance(.2f - (.02f * pwrVal))) //shifting game condition
                            {
                                IEnumerable <GameConditionDef> enumerable = from def in DefDatabase <GameConditionDef> .AllDefs
                                                                            where (def != localGC.def)
                                                                            select def;

                                GameConditionDef newGCdef = enumerable.RandomElement();
                                GameConditionMaker.MakeCondition(newGCdef);
                                Messages.Message("TM_GameConditionChanged".Translate(this.CasterPawn.LabelShort, localGC.Label, newGCdef.label), MessageTypeDefOf.NeutralEvent);
                                localGC.End();
                            }
                            else if (Rand.Chance(.02f)) //permanent
                            {
                                Messages.Message("TM_GameConditionMadePermanent".Translate(localGC.Label), MessageTypeDefOf.NeutralEvent);
                                localGC.Permanent = true;
                            }
                            else if (Rand.Chance(.15f - (.015f * pwrVal))) //add another event
                            {
                                IEnumerable <GameConditionDef> enumerable = from def in DefDatabase <GameConditionDef> .AllDefs
                                                                            where (def != localGC.def)
                                                                            select def;
                                GameConditionDef newGCdef = enumerable.RandomElement();
                                GameConditionMaker.MakeCondition(newGCdef);
                                Messages.Message("TM_GameConditionAdded".Translate(this.CasterPawn.LabelShort, newGCdef.label, localGC.Label), MessageTypeDefOf.NeutralEvent);
                            }
                            else
                            {
                                Messages.Message("TM_AlterGameConditionFailed".Translate(this.CasterPawn.LabelShort, localGC.Label), MessageTypeDefOf.NeutralEvent);
                            }
                            break;
                        }
                    }
                }
            }
            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_AlterFate, CasterPawn.DrawPos, this.CasterPawn.Map, 1f, .2f, 0, 1f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_AlterFate, CasterPawn.DrawPos, this.CasterPawn.Map, 2.5f, .2f, .1f, .8f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_AlterFate, CasterPawn.DrawPos, this.CasterPawn.Map, 6f, 0f, .2f, .6f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
            this.PostCastShot(flag, out flag);
            return(flag);
        }
Пример #20
0
 private void ChangeScene(GameCondition condition)
 {
     view.ClearScene();
     view.ShowScene(condition);
 }
Пример #21
0
        public void ShowScene(GameCondition condition)
        {
            DialogBack.SetActive(false);

            var sceneData = scenes.Find(x => x.condition == condition);

            activeScreen = InstantiateObject(sceneData.screenPrefab, Gui, false);
            InstantiateObject(sceneData.worldPrefab, World);
        }
Пример #22
0
 public UpdateFinishedGameAction(Game game, GameCondition gameCondition)
 {
     this.game          = game;
     this.gameCondition = gameCondition;
 }
        public static void TryGenerateMapCondition(GameConditionDef gameCondition, Map map, int duration = -1, bool permanent = false, bool remove = false, bool add = false, bool reduce = false, bool increase = false, bool random = false)
        {
            GameCondition        gc     = null;
            List <GameCondition> gcList = new List <GameCondition>();

            map.GameConditionManager.GetAllGameConditionsAffectingMap(map, gcList);
            if (random && !add && gcList != null && gcList.Count > 0)
            {
                gc = map.GameConditionManager.GetActiveCondition(gcList.RandomElement().def);
            }
            else if (gameCondition != null && map.GameConditionManager.ConditionIsActive(gameCondition))
            {
                gc = map.GameConditionManager.GetActiveCondition(gameCondition);
            }
            else if (gameCondition != null)
            {
                gc = GameConditionMaker.MakeCondition(gameCondition, duration);
            }
            else if (gameCondition == null && random && add)
            {
                IEnumerable <GameConditionDef> enumerable = from def in DefDatabase <GameConditionDef> .AllDefs
                                                            where true
                                                            select def;
                gc = GameConditionMaker.MakeCondition(enumerable.RandomElement());
            }

            if (gc != null)
            {
                if (permanent)
                {
                    gc.Permanent = true;
                }
                else if (remove)
                {
                    gc.End();
                }
                else if (duration != -1)
                {
                    if (reduce)
                    {
                        gc.Duration -= duration;
                        if (gc.Duration < 0)
                        {
                            gc.End();
                        }
                    }
                    else if (increase)
                    {
                        gc.Duration += duration;
                    }
                    else
                    {
                        gc.Duration = duration;
                    }
                }
                map.gameConditionManager.RegisterCondition(gc);
            }
            else
            {
                Messages.Message("No game condition found.", MessageTypeDefOf.RejectInput);
            }
        }
Пример #24
0
 public void PlayerIsDead()
 {
     current_game_condition = GameCondition.lose_logic;
 }
Пример #25
0
        public void AndTheBoardHasAllInARowThenTrueIsReturned()
        {
            var board = new BoardBuilder().Fill('x', 0, 0).Fill('x', 0, 1).Fill('x', 0, 2).Create();

            Assert.IsTrue(GameCondition.AllInARow('x', board));
        }
Пример #26
0
        public void AndTheBoardHasAnUpperRightDiagonalFilledThenTrueIsReturned()
        {
            var board = new BoardBuilder().Fill('x', 0, 2).Fill('x', 1, 1).Fill('x', 2, 0).Create();

            Assert.IsTrue(GameCondition.AllInADiagonal('x', board));
        }
 public override void PostExposeData(object obj)
 {
     if (Scribe.mode == LoadSaveMode.LoadingVars)
     {
         Game game = obj as Game;
         if (game != null && game.battleLog == null)
         {
             game.battleLog = new BattleLog();
         }
         BattleLogEntry_MeleeCombat battleLogEntry_MeleeCombat = obj as BattleLogEntry_MeleeCombat;
         if (battleLogEntry_MeleeCombat != null)
         {
             if (battleLogEntry_MeleeCombat.RuleDef == null)
             {
                 RulePackDef value  = null;
                 RulePackDef value2 = null;
                 Scribe_Defs.Look(ref value, "outcomeRuleDef");
                 Scribe_Defs.Look(ref value2, "maneuverRuleDef");
                 if (value != null && value2 != null)
                 {
                     foreach (RulePackDef item in DefDatabase <RulePackDef> .AllDefsListForReading)
                     {
                         if (!item.include.NullOrEmpty() && item.include.Count == 2 && ((item.include[0] == value && item.include[1] == value2) || (item.include[1] == value && item.include[0] == value2)))
                         {
                             battleLogEntry_MeleeCombat.RuleDef = item;
                             break;
                         }
                     }
                 }
             }
             if (battleLogEntry_MeleeCombat.def == null)
             {
                 battleLogEntry_MeleeCombat.def = LogEntryDefOf.MeleeAttack;
             }
         }
     }
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         Map map = obj as Map;
         if (map != null && map.pawnDestinationReservationManager == null)
         {
             map.pawnDestinationReservationManager = new PawnDestinationReservationManager();
         }
         Pawn pawn = obj as Pawn;
         if (pawn != null && pawn.Spawned && pawn.rotationTracker == null)
         {
             pawn.rotationTracker = new Pawn_RotationTracker(pawn);
         }
         Pawn_MindState pawn_MindState = obj as Pawn_MindState;
         if (pawn_MindState != null && pawn_MindState.inspirationHandler == null)
         {
             pawn_MindState.inspirationHandler = new InspirationHandler(pawn_MindState.pawn);
         }
         ImportantPawnComp importantPawnComp = obj as ImportantPawnComp;
         if (importantPawnComp != null && importantPawnComp.pawn == null)
         {
             importantPawnComp.pawn = new ThingOwner <Pawn>(importantPawnComp, oneStackOnly: true);
         }
         Pawn_RecordsTracker pawn_RecordsTracker = obj as Pawn_RecordsTracker;
         if (pawn_RecordsTracker != null && Find.TaleManager.AnyTaleConcerns(pawn_RecordsTracker.pawn))
         {
             pawn_RecordsTracker.AccumulateStoryEvent(StoryEventDefOf.TaleCreated);
         }
         WorldPawns worldPawns = obj as WorldPawns;
         if (worldPawns != null && worldPawns.gc == null)
         {
             worldPawns.gc = new WorldPawnGC();
         }
         GameCondition gameCondition = obj as GameCondition;
         if (gameCondition != null && !gameCondition.Permanent && gameCondition.Duration > 1000000000)
         {
             gameCondition.Permanent = true;
         }
         Building_TurretGun building_TurretGun = obj as Building_TurretGun;
         if (building_TurretGun != null && building_TurretGun.gun == null)
         {
             building_TurretGun.MakeGun();
         }
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map  map = parms.target as Map;
            bool result;

            if (map == null)
            {
                result = false;
            }
            else if ((from wo in Find.WorldObjects.AllWorldObjects
                      where wo is Site && (wo as Site).parts.Select(x => x.def) == SiteDefOfReconAndDiscovery.RD_QuakesQuest
                      select wo).Count <WorldObject>() > 0)
            {
                result = false;
            }
            else
            {
                int tile;
                if (TileFinder.TryFindNewSiteTile(out tile))
                {
                    Site site = (Site)WorldObjectMaker.MakeWorldObject(SiteDefOfReconAndDiscovery.RD_AdventureThingCounter);
                    site.Tile = tile;
                    site.AddPart(new SitePart(site, SiteDefOfReconAndDiscovery.RD_SiteRadiationQuest,
                                              SiteDefOfReconAndDiscovery.RD_SiteRadiationQuest.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null)));
                    SitePart radioactiveDust = new SitePart(site, SiteDefOfReconAndDiscovery.RD_SitePart_RadioactiveDust, SiteDefOfReconAndDiscovery.RD_SitePart_RadioactiveDust.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                    radioactiveDust.hidden = true;
                    site.parts.Add(radioactiveDust);
                    QuestComp_CountThings component = site.GetComponent <QuestComp_CountThings>();
                    component.targetNumber        = 200;
                    component.ticksTarget         = 60000;
                    component.ticksHeld           = 0;
                    component.worldTileAffected   = map.Tile;
                    component.gameConditionCaused = GameConditionDef.Named("RD_Radiation");
                    component.StartQuest(ThingDef.Named("Plant_Psychoid"));
                    if (Rand.Value < 0.1f)
                    {
                        SitePart scatteredTreasure = new SitePart(site, SiteDefOfReconAndDiscovery.RD_ScatteredTreasure, SiteDefOfReconAndDiscovery.RD_ScatteredTreasure.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        scatteredTreasure.hidden = true;
                        site.parts.Add(scatteredTreasure);
                    }
                    if (Rand.Value < 0.05f)
                    {
                        SitePart scatteredManhunters = new SitePart(site, SiteDefOfReconAndDiscovery.RD_ScatteredManhunters, SiteDefOfReconAndDiscovery.RD_ScatteredManhunters.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        scatteredManhunters.hidden = true;
                        site.parts.Add(scatteredManhunters);
                    }
                    if (Rand.Value < 0.05f)
                    {
                        SitePart mechanoidForces = new SitePart(site, SiteDefOfReconAndDiscovery.RD_MechanoidForces, SiteDefOfReconAndDiscovery.RD_MechanoidForces.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        mechanoidForces.hidden = true;
                        site.parts.Add(mechanoidForces);
                    }
                    if (Rand.Value < 0.05f)
                    {
                        SitePart enemyRaidOnArrival = new SitePart(site, SiteDefOfReconAndDiscovery.RD_EnemyRaidOnArrival, SiteDefOfReconAndDiscovery.RD_EnemyRaidOnArrival.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, null));
                        enemyRaidOnArrival.hidden = true;
                        site.parts.Add(enemyRaidOnArrival);
                    }

                    if (Find.World.tileTemperatures.GetSeasonalTemp(site.Tile) < 10f || Find.World.tileTemperatures.GetSeasonalTemp(site.Tile) > 40f)
                    {
                        result = false;
                    }
                    else
                    {
                        int           num           = 30;
                        GameCondition gameCondition = GameConditionMaker.MakeCondition(GameConditionDef.Named("RD_Radiation"), 60000 * num);
                        map.gameConditionManager.RegisterCondition(gameCondition);
                        site.GetComponent <TimeoutComp>().StartTimeout(num * 60000);
                        base.SendStandardLetter(parms, site);
                        Find.WorldObjects.Add(site);
                        result = true;
                    }
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Пример #29
0
        public override void Update(GameTime gameTime)
        {
            float deltaTime = (float)gameTime.ElapsedGameTime.Milliseconds;

            switch (CurrentScreen)
            {
            case ActiveScreen.MAIN:
                if (Active)
                {
                    if (MediaPlayer.State == MediaState.Stopped)
                    {
                        MediaPlayer.Play(MenuTrack);
                    }
                }
                else
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(BackingTrack);
                    CurrentScreen = ActiveScreen.PLAY;
                }

                // Check Input
                if (InputEngine.IsKeyPressed(ActivationKey) ||
                    InputEngine.IsButtonPressed(ActivationButton))
                {
                    Active = !Active;
                    BlinkPlay.Play();
                    Helper.CurrentGameStatus = GameStatus.PLAYING;
                }
                break;

            case ActiveScreen.PLAY:
                TilePlayer player = (TilePlayer)Game.Services.GetService(typeof(TilePlayer));

                if (Active)
                {
                    MediaPlayer.Stop();
                    PauseTime     = gameTime.TotalGameTime;
                    CurrentScreen = ActiveScreen.PAUSE;
                }

                // Check Input
                if (InputEngine.IsKeyPressed(PauseKey) ||
                    InputEngine.IsButtonPressed(PauseButton))
                {
                    Active = !Active;
                    BlinkPause.Play();
                    Helper.CurrentGameStatus = GameStatus.PAUSED;
                }

                if (player.Health > 0 && TimeRemaining > 0)
                {
                    TimeRemaining -= deltaTime;
                }
                else
                {
                    MediaPlayer.Stop();
                    Active = !Active;
                    CurrentGameCondition = GameCondition.LOSE;
                    CurrentScreen        = ActiveScreen.LOSE;
                }

                if (CurrentGameCondition == GameCondition.WIN)
                {
                    MediaPlayer.Stop();
                    Active        = !Active;
                    CurrentScreen = ActiveScreen.WIN;
                }
                break;

            case ActiveScreen.PAUSE:
                if (MediaPlayer.State == MediaState.Stopped)
                {
                    MediaPlayer.Play(PauseTrack);
                }

                if (!Active)
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(BackingTrack);
                    CurrentScreen          = ActiveScreen.PLAY;
                    gameTime.TotalGameTime = PauseTime;
                }

                // Check Input
                if (InputEngine.IsKeyPressed(PauseKey) ||
                    InputEngine.IsButtonPressed(PauseButton))
                {
                    Active = !Active;
                    BlinkPause.Play();
                    Helper.CurrentGameStatus = GameStatus.PLAYING;
                }
                break;

            case ActiveScreen.LOSE:

                if (MediaPlayer.State == MediaState.Stopped && TrackPlayCount < 1)
                {
                    MediaPlayer.Play(GameOverTrack);
                    TrackPlayCount++;
                    MediaPlayer.IsRepeating = false;
                }
                Helper.CurrentGameStatus = GameStatus.PAUSED;
                break;

            case ActiveScreen.WIN:
                if (MediaPlayer.State == MediaState.Stopped && TrackPlayCount < 1)
                {
                    MediaPlayer.Play(WinTrack);
                    TrackPlayCount++;
                }
                Helper.CurrentGameStatus = GameStatus.PAUSED;
                break;

            default:
                break;
            }

            base.Update(gameTime);
        }
Пример #30
0
 protected abstract void DoWeatherOutcomeSpecial(Pawn pawn, GameCondition gameCondition);