Ejemplo n.º 1
0
        private static TagSet FlipHelper(TagSet @this, int index)
        {
            var tags = @this.ToArray();

            for (var i = index; i < tags.Length; i++)
            {
                if (tags[i] == Symbols.Left)
                {
                    tags[i] = Symbols.Right;
                }
                else if (tags[i] == Symbols.Right)
                {
                    tags[i] = Symbols.Left;
                }
                else if (tags[i] == Symbols.Back)
                {
                    tags[i] = Symbols.Front;
                }
                else if (tags[i] == Symbols.Front)
                {
                    tags[i] = Symbols.Back;
                }
            }
            return(new TagSet(tags));
        }
Ejemplo n.º 2
0
            public static void Postfix(SimGameState __instance, TagSet ___companyTags)
            {
                try
                {
                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] Called");

                    bool   heavyMetalCompleted = ___companyTags.Contains("flashpoint_HM7_showdown_complete");
                    TagSet heavyMetalTagSet    = new TagSet(___companyTags.ToArray().Where(tag => tag.Contains("HM")).ToList());


                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.companyTags: {___companyTags}");
                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] heavyMetalTagSet: {heavyMetalTagSet}");
                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.completedFlashpoints: {string.Join(",", __instance.completedFlashpoints.ToArray())}");

                    if (heavyMetalCompleted)
                    {
                        ___companyTags.RemoveRange(heavyMetalTagSet);
                        __instance.completedFlashpoints.RemoveAll(item => item.Contains("fp_HM"));

                        // Items are hashed, cannot extract HM-specific ones... just kill em all
                        __instance.AlreadyClickedConversationResponses.Clear();
                    }

                    Logger.Debug("---");
                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.companyTags: {___companyTags}");
                    Logger.Debug($"[SimGameState_OnAttachUXComplete_POSTFIX] SimGameState.completedFlashpoints: {string.Join(",", __instance.completedFlashpoints.ToArray())}");
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Ejemplo n.º 3
0
        public static MapConfig ParseCurrentMap()
        {
            Mod.Log.Info?.Write("MH:PCM Parsing current map.");

            MoodController moodController = ModState.GetMoodController();

            MoodSettings moodSettings = moodController?.CurrentMood;
            TagSet       moodTags     = moodSettings?.moodTags;

            if (moodTags == null || moodTags.IsEmpty)
            {
                return(new MapConfig {
                    spotterRange = Mod.Config.Vision.BaseRangeBright,
                    visualIDRange = Mod.Config.Vision.ScanRangeHexes
                });
            }

            Mod.Log.Debug?.Write($"  - Parsing current map for mod config");
            MapConfig mapConfig = new MapConfig();

            String allTags = String.Join(", ", moodTags.ToArray());

            Mod.Log.Debug?.Write($"  - All mood tags are: {allTags}");

            float baseVision  = Mod.Config.Vision.BaseRangeBright;
            float visionMulti = 1.0f;

            foreach (string tag in moodTags)
            {
                switch (tag)
                {
                case "mood_timeMorning":
                case "mood_timeNoon":
                case "mood_timeAfternoon":
                case "mood_timeDay":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    mapConfig.isDay  = true;
                    mapConfig.isDim  = false;
                    mapConfig.isDark = false;
                    break;

                case "mood_timeSunrise":
                case "mood_timeSunset":
                case "mood_timeTwilight":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (baseVision > Mod.Config.Vision.BaseRangeDim)
                    {
                        baseVision       = Mod.Config.Vision.BaseRangeDim;
                        mapConfig.isDay  = false;
                        mapConfig.isDim  = true;
                        mapConfig.isDark = false;
                    }
                    break;

                case "mood_timeNight":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (baseVision > Mod.Config.Vision.BaseRangeDark)
                    {
                        baseVision       = Mod.Config.Vision.BaseRangeDark;
                        mapConfig.isDay  = false;
                        mapConfig.isDim  = false;
                        mapConfig.isDark = true;
                    }
                    break;

                case "mood_weatherRain":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (visionMulti > Mod.Config.Vision.RangeMultiRainSnow)
                    {
                        visionMulti       = Mod.Config.Vision.RangeMultiRainSnow;
                        mapConfig.hasRain = true;
                    }
                    break;

                case "mood_weatherSnow":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (visionMulti > Mod.Config.Vision.RangeMultiRainSnow)
                    {
                        visionMulti       = Mod.Config.Vision.RangeMultiRainSnow;
                        mapConfig.hasSnow = true;
                    }
                    break;

                case "mood_fogLight":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (visionMulti > Mod.Config.Vision.RangeMultiLightFog)
                    {
                        visionMulti           = Mod.Config.Vision.RangeMultiLightFog;
                        mapConfig.hasLightFog = true;
                    }
                    break;

                case "mood_fogHeavy":
                    Mod.Log.Debug?.Write($"  - {tag}");
                    if (visionMulti > Mod.Config.Vision.RangeMultiHeavyFog)
                    {
                        visionMulti           = Mod.Config.Vision.RangeMultiHeavyFog;
                        mapConfig.hasHeavyFog = true;
                    }
                    break;

                default:
                    break;
                }
            }

            // Calculate normal vision range
            float visRange = (float)Math.Ceiling(baseVision * 30f * visionMulti);

            Mod.Log.Info?.Write($"  Calculating vision range as Math.Ceil(baseVision:{baseVision} * 30.0 * visionMulti:{visionMulti}) = visRange:{visRange}.");
            if (visRange < Mod.Config.Vision.MinimumVisionRange())
            {
                visRange = Mod.Config.Vision.MinimumVisionRange();
            }

            float roundedVisRange = HexUtils.CountHexes(visRange, false) * 30f;

            Mod.Log.Info?.Write($"MapHelper: Vision range for map will be ==> {roundedVisRange}m (normalized from {visRange}m)");
            mapConfig.spotterRange  = roundedVisRange;
            mapConfig.visualIDRange = Math.Min(roundedVisRange, Mod.Config.Vision.ScanRangeHexes * 30.0f);

            Mod.Log.Info?.Write($"Map vision range = visual:{roundedVisRange} / visualScan:{mapConfig.visualIDRange}");

            // Calculate night vision range
            if (mapConfig.isDark)
            {
                float nightVisRange = (float)Math.Ceiling(Mod.Config.Vision.BaseRangeBright * 30f * visionMulti);
                if (nightVisRange < Mod.Config.Vision.MinimumVisionRange())
                {
                    nightVisRange = Mod.Config.Vision.MinimumVisionRange();
                }

                float roundedNightVisRange = HexUtils.CountHexes(nightVisRange, false) * 30f;
                Mod.Log.Info?.Write($"MapHelper: Night vision range for map will be ==> {roundedNightVisRange}m (normalized from {nightVisRange}m)");
                mapConfig.nightVisionSpotterRange  = roundedNightVisRange;
                mapConfig.nightVisionVisualIDRange = Math.Min(roundedNightVisRange, Mod.Config.Vision.ScanRangeHexes * 30.0f);
            }

            return(mapConfig);
        }
Ejemplo n.º 4
0
        public static void Postfix(ref List <TagSet_MDD> __result, TagSetType tagSetType, TagSet requiredTags, TagSet excludedTags)
        {
            try
            {
                //MAD:
                string overrideBlacklistedTag = ("ignoreTag-BLACKLISTED").ToLower();
                if (!requiredTags.Contains(overrideBlacklistedTag))
                {
                    return;
                }
                //:DAM

                MetadataDatabase mdd = MetadataDatabase.Instance;

                TagSet tags   = new TagSet(requiredTags);
                TagSet tagSet = new TagSet(excludedTags);
                if (!tagSet.Contains(Tags_MDDExtenstions.BLACKLISTED_TAG))
                {
                    tagSet.Add(Tags_MDDExtenstions.BLACKLISTED_TAG);
                }

                //MAD:
                if (tags.Contains(overrideBlacklistedTag))
                {
                    Logger.Debug($"[Tags_MDDExtenstions_GetTagSetWithRequiredTags_PREFIX] Request has ignoreTag-BLACKLISTED tag set. Removing BLACKLISTED tag");
                    tagSet.Remove(Tags_MDDExtenstions.BLACKLISTED_TAG);
                    // Need to remove the custom tag too, otherwise the query below will include it as required -> no result -> fallback unit (cicada)
                    tags.Remove(overrideBlacklistedTag);

                    Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] requiredTags: {String.Join(", ", tags.ToArray())}");
                    Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] excludedTags: {String.Join(", ", tagSet.ToArray())}");
                }
                //:DAM

                List <Tag_MDD> orCreateTagsInTagSet  = mdd.GetOrCreateTagsInTagSet(tags);
                List <Tag_MDD> orCreateTagsInTagSet2 = mdd.GetOrCreateTagsInTagSet(tagSet);
                string         text  = "SELECT ts.* FROM TagSet ts ";
                string         text2 = string.Empty;
                string         text3 = string.Format("WHERE ts.TagSetTypeId = {0} ", (int)tagSetType);
                for (int i = 0; i < orCreateTagsInTagSet.Count; i++)
                {
                    text2 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredInnerJoinFormat, i);
                    text3 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredWhereClauseFormat, i, orCreateTagsInTagSet[i].Name);
                }
                for (int j = 0; j < orCreateTagsInTagSet2.Count; j++)
                {
                    text2 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedLeftJoinFormat, j, orCreateTagsInTagSet2[j].Name);
                    text3 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedWhereClauseFormat, j);
                }
                text = text + text2 + text3 + " COLLATE NOCASE ";

                __result = mdd.Query <TagSet_MDD>(text, null, null, true, null, null).ToList <TagSet_MDD>();
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }