public override void OnLevelLoaded(LoadMode mode) { _mode = mode; // Don't start in asset and map editor if (_mode != LoadMode.LoadGame && _mode != LoadMode.NewGame) { return; } try { ModLogger.Debug("Starting WorkshopAssetMonitor"); WorkshopAssetMonitor.Instance.Start(); ModLogger.Debug("WorkshopAssetMonitor started"); } catch (Exception ex) { ModLogger.Error("An error occured while starting the WorkshopAssetMonitor"); ModLogger.Exception(ex); } }
//TODO : Convert to transpiler public static void Postfix(ThingDef thingDef, int nestLevel, Listing_ResourceReadout __instance) { ModLogger l = MainMod.logger; if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { try { Traverse tr = Traverse.Create(__instance); Rect rect = new Rect(0f, tr.Field("curY").GetValue <float>() - 24f, tr.Property("LabelWidth").GetValue <float>(), tr.Field("lineHeight").GetValue <float>()) { xMin = tr.Method("XAtIndentLevel", new Type[] { typeof(int) }).GetValue <float>(nestLevel) + 18f }; if (!Mouse.IsOver(rect)) { return; } } catch (Exception e) { l.ReportException(e); return; } Event.current.Use(); MainMod.SelectThisInStorage(thingDef, Find.CurrentMap); } }
public ModEntry(ModInfo info, string path) { Info = info; Path = path; Logger = new ModLogger(Info.Id); Version = ParseVersion(info.Version); ManagerVersion = !string.IsNullOrEmpty(info.ManagerVersion) ? ParseVersion(info.ManagerVersion) : !string.IsNullOrEmpty(Config.MinimalManagerVersion) ? ParseVersion(Config.MinimalManagerVersion) : new Version(); GameVersion = !string.IsNullOrEmpty(info.GameVersion) ? ParseVersion(info.GameVersion) : new Version(); if (info.Requirements == null || info.Requirements.Length <= 0) { return; } var regex = new Regex(@"(.*)-(\d+\.\d+\.\d+).*"); foreach (var id in info.Requirements) { var match = regex.Match(id); if (match.Success) { Requirements.Add(match.Groups[1].Value, ParseVersion(match.Groups[2].Value)); continue; } if (!Requirements.ContainsKey(id)) { Requirements.Add(id, null); } } if (info.LoadAfter != null && info.LoadAfter.Length > 0) { LoadAfter.AddRange(info.LoadAfter); } }
public static IEnumerator PatchContent(Scene scene) { lock (_PatchLock) { ModLogger.Log("content", $"Patching scene content: {scene.name}"); Scene scenePrev = SceneManager.GetActiveScene(); if (scenePrev != scene) { SceneManager.SetActiveScene(scene); yield return(null); } GameObject[] objs = Resources.FindObjectsOfTypeAll <GameObject>(); if (scenePrev != scene) { SceneManager.SetActiveScene(scenePrev); yield return(null); } for (int i = 0; i < objs.Length; i++) { if (objs[i] != null) { if (objs[i].scene != scene) { continue; } if (PatchContent(objs[i].transform)) { _PatchedThisFrame++; } if (_PatchedThisFrame >= _PatchesPerFrame || i % _MaxObjectsPerFrame == 0) { _PatchedThisFrame = 0; yield return(null); } } } } }
// Method that runs when the game starts so it can fix things then internal static void FixAtGameLoad() { // Fixes to the scales if (QOL.FixScales) { // Gilded Ginger Fix ScaleFix(Identifiable.Id.GINGER_VEGGIE, Vector3.one * 1.2f, "model_parsnip"); ObjectFix(Identifiable.Id.GINGER_VEGGIE, (obj) => { // TODO: Fix this later float perc = 1.2f / 2.1f; CapsuleCollider col = obj.GetComponent <CapsuleCollider>(); SphereCollider sCol = obj.GetComponent <SphereCollider>(); GameObject launch = obj.FindChild("DelaunchTrigger"); launch.transform.localScale = launch.transform.localScale * perc; col.radius *= perc; col.height *= perc; sCol.radius *= perc; }); } if (QOL.ImpCollisions) { ObjectFix(SRObjects.Get <GameObject>("ranchPorch"), (obj) => { ModLogger.Log("Test"); foreach (MeshCollider col in obj.GetComponentsInChildren <MeshCollider>()) { col.sharedMesh = col.gameObject.GetComponent <MeshFilter>().sharedMesh; } }); } }
public static bool OnEnable() { try { int num = Singleton <ConfigManager> .instance["albums"].Count - 2; int[] freeAlbumIndexs = Singleton <WeekFreeManager> .instance.freeAlbumIndexs; Dictionary <int, Transform> dictionary = new Dictionary <int, Transform>(); for (int i = 1; i < num; i++) { Transform value = GameObject.Find(string.Format("ImgAlbum{0}", i)).transform; int key = num - i + 2; dictionary.Add(key, value); } dictionary = (from d in dictionary orderby d.Key descending select d).ToDictionary((KeyValuePair <int, Transform> d) => d.Key, (KeyValuePair <int, Transform> d) => d.Value); foreach (KeyValuePair <int, Transform> keyValuePair in dictionary) { keyValuePair.Value.SetSiblingIndex(keyValuePair.Key); } if (freeAlbumIndexs != null && freeAlbumIndexs.Length > 0) { for (int j = 0; j < freeAlbumIndexs.Length; j++) { int num2 = freeAlbumIndexs[j]; Transform transform = GameObject.Find(string.Format("ImgAlbum{0}", num2)).transform; transform.SetSiblingIndex(j + 3); } } } catch (Exception ex) { ModLogger.Debug(ex); } return(false); }
public void Activate() { if (_modActive) { return; } ModLogger.WriteLine("Activating Break HP/MP Limit"); // No check (yet) GameMemory.Assembly.Inject(_offsetHPCheck, "and eax,7FFFFFFF"); GameMemory.Assembly.Inject(_offsetMPLimit, "mov eax,7FFFFFFF"); GameMemory.Assembly.Inject(_offsetMPCheck, "push 7fffffff"); GameMemory.Assembly.Inject(_offsetHPCheck, new[] { "and eax, 7FFFFFFF", "nop", "nop", "nop", "nop", "nop", }); _modActive = true; }
public static ConfigurationContainer LoadConfiguration(string filename) { ModLogger.Debug("Loading configuration from '{0}'", filename); ConfigurationContainer result = null; // Check if the file exists. If so, deserialize it to a new instance. If not so, create a new empty instance if (File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) result = (ConfigurationContainer) new XmlSerializer(typeof(ConfigurationContainer)).Deserialize(sr); } else { result = new ConfigurationContainer(); } // Assign the filename to the result. This is used later on when saving the configuration. result._filename = filename; ModLogger.Debug("Configuration loaded from '{0}'", filename); return(result); }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { // Exit if the monitor was terminated because of an error occured when updating overwatch data if (_terminated) { return; } // Exit if the monitor has not been loaded yet by the overwatch loader when a game is loaded (prevents issues when the loader is not started yet but the monitor is) if (!OverwatchControl.Instance.GameLoaded) { return; } try { // Initialize the monitor if it wasn't initialized yet if (!_initialized) { InitializeMonitor(); } // Run an update cycle if the simulation is not currently paused else if (!SimulationManager.instance.SimulationPaused) { RunUpdateCycle(); } } catch (Exception ex) { ModLogger.Error(string.Format("An unexpected error occured while updating the {0}", _monitorType)); ModLogger.Exception(ex); _terminated = true; } base.OnUpdate(realTimeDelta, simulationTimeDelta); }
public static void RebuildChildren(FancyScrollView __instance) { if (__instance.name == "FancyScrollAlbum") { string activeOption = SingletonScriptableObject <LocalizationSettings> .instance.GetActiveOption("Language"); if (GameObject.Find($"ImgAlbumCustom") == null) { // Add new tab gameobject var gameobject = GameObject.Find("ImgAlbumCollection"); GameObject customTab = GameObject.Instantiate(gameobject, gameobject.transform.parent); customTab.name = $"ImgAlbumCustom"; customTab.transform.SetSiblingIndex(2); // CompTrack(gameobject.transform.parent.gameObject); CompTrack(customTab); var a = customTab.GetComponent <VariableBehaviour>(); if (a != null) { ModLogger.Debug($"{a.result}:{a.variable.result} {a.variable}"); } var b = customTab.transform.Find("TxtAlbumTitle"); if (b != null) { b.GetComponent <UnityEngine.UI.Text>().text = language[activeOption]; var l18n = b.GetComponent <Localization>(); foreach (var opt in l18n.optionPairs) { ((TextOption)opt.option).value = language[opt.optionEntry.name]; ModLogger.Debug($" opt:{opt.optionEntry.name} val:{((TextOption)opt.option).value.ToString()}"); } } ModLogger.Debug("Add custom map tab"); } } }
public override void Initialize() { StoredLogger = Logger; }
public static void Init(ModLogger logger) { modLogger = logger; _logger = new LoggingService(modLogger); }
public override void OnCreated(ILoading loading) { ModLogger.Debug("UILoader created"); }
public ModLoggerTest() { innerLogger = Substitute.For <IBasicLogger>(); logger = new ModLogger("MyMod", innerLogger); }
public override void OnReleased() { ModLogger.Debug("UILoader Released"); }
public void StartGame() { _gameLoaded = true; ModLogger.Debug("Game is marked as loaded by overwatch control"); }
public LoggingService(ModLogger logger) { _logger = logger; }
public void Start() { try { ModLogger.Debug("WorkshopAssetMonitor is loading workshop assets"); // The package manager monitors the list of workshop assets, so retrieve the packageid from each item var workshopIds = PackageManager .FilterAssets(UserAssetType.CustomAssetMetaData) .Where(a => a.isWorkshopAsset) .Select(a => new { Asset = a, Metadata = a.Instantiate <CustomAssetMetaData>() }) .Select(a => ulong.Parse(a.Asset.package.packageName)) .Distinct(); // The PrefabCollections monitor the list of all prefabs available in the game, which includes the default CS prefabs and the custom prefabs from workshop assets // Try to match the prefabs with the workshop packageid list to make sure only workshopassets are loaded. for (int i = 0; i < PrefabCollection <PropInfo> .PrefabCount(); i++) { PropInfo propPrefab = PrefabCollection <PropInfo> .GetPrefab((uint)i); if (propPrefab != null) { var workshopPropMatch = Regex.Match(propPrefab.name, RegexExpression.BuildingName, RegexOptions.IgnoreCase); if (workshopPropMatch.Success) { var workshopPropId = ulong.Parse(workshopPropMatch.Groups["packageid"].Value); if (workshopIds.Any(id => id == workshopPropId)) { _workshopAssets.Add(new WorkshopProp(workshopPropId, workshopPropMatch.Groups["prefabname"].Value, propPrefab.name)); } } } } for (int i = 0; i < PrefabCollection <TreeInfo> .PrefabCount(); i++) { TreeInfo treePrefab = PrefabCollection <TreeInfo> .GetPrefab((uint)i); if (treePrefab != null) { var workshopTreeMatch = Regex.Match(treePrefab.name, RegexExpression.BuildingName, RegexOptions.IgnoreCase); if (workshopTreeMatch.Success) { var workshopPropId = ulong.Parse(workshopTreeMatch.Groups["packageid"].Value); if (workshopIds.Any(id => id == workshopPropId)) { _workshopAssets.Add(new WorkshopTree(workshopPropId, workshopTreeMatch.Groups["prefabname"].Value, treePrefab.name)); } } } } for (int i = 0; i < PrefabCollection <BuildingInfo> .PrefabCount(); i++) { BuildingInfo buildingPrefab = PrefabCollection <BuildingInfo> .GetPrefab((uint)i); if (buildingPrefab != null) { var workshopBuildingMatch = Regex.Match(buildingPrefab.name, RegexExpression.BuildingName, RegexOptions.IgnoreCase); if (workshopBuildingMatch.Success) { var workshopBuildingId = ulong.Parse(workshopBuildingMatch.Groups["packageid"].Value); if (workshopIds.Any(id => id == workshopBuildingId)) { _workshopAssets.Add(new WorkshopBuilding(workshopBuildingId, workshopBuildingMatch.Groups["prefabname"].Value, buildingPrefab.name, buildingPrefab.GetService().ToAssetType())); } } } } ModLogger.Debug("WorkshopAssetMonitor loaded {0} workshop assets", GetWorkshopAssetCount()); } catch (Exception ex) { ModLogger.Error("An error occured while starting the workshop monitor, no workshop assets where loaded"); ModLogger.Exception(ex); } }
public void SetCommand(ICommand command) { ModLogger.Debug("Setting command '{0}' to '{1}' button", command.GetType().Name, this.name); _command = command; }
public override void OnReleased() { ModLogger.Debug("WorkshopAssetMonitorLoader Released"); }
public override void OnCreated(ILoading loading) { ModLogger.Debug("WorkshopAssetMonitorLoader created"); }
public void Update() { if (!_modActive) { return; } // Read battle pointer from memory var battlePointer = GameMemory.Read <IntPtr>(_offsetEnemyPointer); // Check if we need to reset battle if (battlePointer == IntPtr.Zero && changedCreature != null) { changedThisBattle = false; changedCreature = null; } if (battlePointer != IntPtr.Zero && !changedThisBattle) { ModLogger.WriteLine("Battle detected, modifying enemies"); changedCreature = new bool[8]; // Loop until all creatures are modified or limit is hit var loopLimit = 2000; // maximum times to attempt modification before giving up while (changedCreature.Contains(false) && loopLimit > 0) { loopLimit--; for (int i = 0; i < 8; i++) { if (changedCreature[i]) { continue; // Enemy already modified } var entityData = Battle.GetEnemyEntity(i); var entityName = StringConverter.ToString(entityData.text_name); int entityOffset = (int)battlePointer + _sizeBattleEntity * i; if (entityData.guid == 0) // No enemy in this slot { continue; } ModLogger.WriteLine("Modifying creature: {0}", entityName); var newHP = entityData.hp_max * m_HpMpMultiplier; newHP = newHP > int.MaxValue ? int.MaxValue : newHP; var newMP = entityData.mp_max * m_HpMpMultiplier; newMP = newMP > int.MaxValue ? int.MaxValue : newMP; var newStrength = entityData.strength * m_StatMultiplier; newStrength = newStrength > byte.MaxValue ? byte.MaxValue : newStrength; var newDefense = entityData.defense * m_StatMultiplier; newDefense = newDefense > byte.MaxValue ? byte.MaxValue : newDefense; var newMagic = entityData.magic * m_StatMultiplier; newMagic = newMagic > byte.MaxValue ? byte.MaxValue : newMagic; var newMagicDef = entityData.magic_defense * m_StatMultiplier; newMagicDef = newMagicDef > byte.MaxValue ? byte.MaxValue : newMagicDef; var newAgility = entityData.agility * m_StatMultiplier; newAgility = newAgility > byte.MaxValue ? byte.MaxValue : newAgility; var newLuck = entityData.luck * m_StatMultiplier; newLuck = newLuck > byte.MaxValue ? byte.MaxValue : newLuck; var newAccuracy = entityData.accuracy * m_StatMultiplier; newAccuracy = newAccuracy > byte.MaxValue ? byte.MaxValue : newAccuracy; var newEvasion = entityData.evasion * m_StatMultiplier; newEvasion = newEvasion > byte.MaxValue ? byte.MaxValue : newEvasion; // update entity values GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_current"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max2"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_current"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max2"), newMP, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("strength"), (byte)newStrength, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("defense"), (byte)newDefense, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic"), (byte)newMagic, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic_defense"), (byte)newMagicDef, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("agility"), (byte)newAgility, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("luck"), (byte)newLuck, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("accuracy"), (byte)newAccuracy, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("evasion"), (byte)newEvasion, false); changedCreature[i] = true; } } changedThisBattle = true; } }
public void StopGame() { _gameLoaded = false; ModLogger.Debug("Game is marked as unloaded by overwatch control"); }
public static void GetJsonPostfix(string name, bool localization, ref Dictionary <string, JArray> ___m_Dictionary, ref JArray __result) { try { string activeOption = SingletonScriptableObject <LocalizationSettings> .instance.GetActiveOption("Language"); // Load localization album title if (localization && name.StartsWith("albums_")) { string albums_lang = $"albums_{activeOption}"; var found = false; foreach (var obj in ___m_Dictionary[albums_lang]) { if (obj.Value <string>("title") == language[activeOption]) { found = true; break; } } if (!found) { // add custom title ModLogger.Debug($"Add Custom Title: {language[activeOption]}"); var @object = new JObject(); @object.Add("title", language[activeOption]); ___m_Dictionary[albums_lang].Add(@object); // return new result __result = ___m_Dictionary[albums_lang]; } return; } // Load album info if (!localization && name == "albums") { var found = false; foreach (var obj in ___m_Dictionary[name]) { if (obj.Value <string>("uid") == "custom") { found = true; break; } } if (!found) { // add custom title ModLogger.Debug($"Add Custom Info"); var jobj = new JObject(); jobj.Add("uid", "custom"); jobj.Add("title", "Custom Maps"); jobj.Add("prefabsName", "AlbumCollection"); jobj.Add("price", "Free"); jobj.Add("jsonName", "ALBUMCUSTOM"); jobj.Add("needPurchase", false); jobj.Add("free", true); ___m_Dictionary[name].Add(jobj); // return new result __result = ___m_Dictionary[name]; } return; } } catch (Exception ex) { ModLogger.Debug(ex); } }
public override void Initialize() { ShipInteriorMod.instLogger = this.Logger; instance = this; }
public IkenFelineMod(ModManifest manifest) { Manifest = manifest; Logger = new ModLogger(this); Version = new Version(Manifest.Version); }
public void Update() { if (ModInput.GetButtonDown("FreeCam Toggle")) { IsEnabled = !IsEnabled; if (!IsEnabled) { Time.timeScale = 1f; FreeCamera.enabled = false; if (PrevCamera != null) { PrevCamera.enabled = true; } } else { QualitySettings.lodBias = 1f; QualitySettings.maximumLODLevel = 0; PrevCamera = Camera.main; if (PrevCamera != null) { FreeCamera.transform.position = PrevCamera.transform.position; FreeCamera.transform.eulerAngles = new Vector3(0f, PrevCamera.transform.eulerAngles.y, 0f); MouseLook.targetDirection = PrevCamera.transform.rotation.eulerAngles; MouseLook.mouseAbsolute = Vector2.zero; FreeCamera.fieldOfView = PrevCamera.fieldOfView; if (FreeCamera.fieldOfView < 10f) { FreeCamera.fieldOfView = 75f; } PrevCamera.enabled = false; } FreeCamera.enabled = true; if (CameraManager.Instance != null) { ApplyDOFToFreeCam(); } } ModLogger.Log("freecam", $"{(IsEnabled ? "Enabled" : "Disabled")} MAGIC CAMERA™ mode."); } if (IsEnabled && ModInput.GetButtonDown("FreeCam Light Toggle")) { IsFullBright = !IsFullBright; } if (!WasFullBright && IsFullBright) { OriginalAmbienceColor = RenderSettings.ambientLight; RenderSettings.ambientLight = new Color(1f, 1f, 1f, 1f); } else if (WasFullBright && !IsFullBright) { RenderSettings.ambientLight = OriginalAmbienceColor; } WasFullBright = IsFullBright; if (CameraManager.Instance != null) { CameraManager.Instance.enabled = !IsEnabled; } GUIInfoGroup.Visible = IsEnabled && IsGUIVisible; if (_FreeCamera != null) { MouseLook.enabled = IsEnabled; } if (!IsEnabled) { return; } MouseLook.enabled = !ModGUI.MainGroup.Visible; if (ModInput.GetButtonDown("FreeCam GUI Toggle")) { IsGUIVisible = !IsGUIVisible; } if (ModInput.GetButtonDown("FreeCam Game GUI Toggle Ext")) { ModGUI.ToggleGameGUI(); } /* * if (CameraManager.Instance != null) { * FreeCamera.enabled = true; * if (Camera.main != null && Camera.main != FreeCamera) * ApplyDOFToFreeCam(); * } */ FreeCamera.enabled = true; Transform camt = FreeCamera.transform; Speed = Mathf.Max(0.01f, Speed + 0.01f * ModInput.GetAxis("FreeCam Move Speed")); if (ModInput.GetButton("FreeCam Move Speed Reset")) { Speed = DefaultSpeed; } float speed = Speed; if (ModInput.GetButton("FreeCam Run")) { speed *= 4f; } Vector3 dir = Vector3.zero; dir += camt.forward * ModInput.GetAxis("Vertical"); float angleY = camt.rotation.eulerAngles.y; angleY = (angleY + 90f) / 180f * Mathf.PI; if (camt.rotation.eulerAngles.z == 180f) { angleY += Mathf.PI; } dir += new Vector3(Mathf.Sin(angleY), 0f, Mathf.Cos(angleY)) * ModInput.GetAxis("Horizontal"); if (dir != Vector3.zero) { dir.Normalize(); camt.position += dir * speed * SpeedF; } camt.position += Vector3.up * ModInput.GetAxis("FreeCam Y Movement") * speed * SpeedF; float timeScalePrev = Time.timeScale; Time.timeScale = Mathf.Clamp(Time.timeScale + ModInput.GetAxis("FreeCam Game Speed") * ( Time.timeScale < 0.24999f ? 0.01f : Time.timeScale < 1.99999f ? 0.05f : Time.timeScale < 7.99999f ? 0.5f : Time.timeScale < 15.99999f ? 1f : 4f ), 0f, 100f); if (ModInput.GetButton("FreeCam Game Speed Reset")) { Time.timeScale = 1f; } if (ModInput.GetButton("FreeCam Game Speed Freeze")) { Time.timeScale = 0f; } int scaleRound = Mathf.FloorToInt(Time.timeScale * 100f); if (Time.timeScale >= 0.25f && scaleRound % 10 == 9) { Time.timeScale = (scaleRound + 1) / 100f; } GUIInfoGameSpeed.Text = $"Game speed: {Mathf.FloorToInt(Time.timeScale * 100f)}%"; GUIInfoMoveSpeed.Text = $"Movement speed: {(speed / DefaultSpeed * 100f).ToString("N0")}%"; GUIInfoSceneName.Text = $"Scene (level): {SceneManager.GetActiveScene().name}"; Vector3 pos = camt.position; Vector3 rot = camt.eulerAngles; GUIInfoPosition.Text = $"Position: {pos.x.ToString("0000.00")}, {pos.y.ToString("0000.00")}, {pos.z.ToString("0000.00")}"; GUIInfoRotation.Text = $"Rotation: {rot.x.ToString("0000.00")}, {rot.y.ToString("0000.00")}, {rot.z.ToString("0000.00")}"; }
public override void Initialize() { base.Initialize(); HarmonyInst.PatchAll(Assembly.GetExecutingAssembly()); Log = Logger; }
public void ClearCommand() { ModLogger.Debug("Clearing command '{0}' from '{1}' button", _command.GetType().Name, this.name); _command = null; }
public static void AnnounceSelection(Selector __instance) { ModLogger log = new ModLogger("MultiRim"); log.Message("Something was selected"); List <Thing> things = new List <Thing>(); List <Zone_Stockpile> stockpiles = new List <Zone_Stockpile>(); string output = ""; foreach (object obj in __instance.SelectedObjects) { if (obj is Thing) { things.Add((Thing)obj); } if (obj is Zone_Stockpile) { stockpiles.Add((Zone_Stockpile)obj); } } /* * if(things.Count != 0) * { * foreach(Thing thing in things) * { * thing.TryAttachFire(3f); * output = output + thing.Label + ", "; * } * * log.Message("Tried to light {0} things on fire, those things were: {1}", things.Count, output); * } */ if (stockpiles.Count != 0) { Dictionary <string, int> contents = new Dictionary <string, int>(); foreach (Zone_Stockpile stockpile in stockpiles) { foreach (Thing thing in stockpile.AllContainedThings) { if (!thing.def.IsCorpse) { if (contents.ContainsKey(thing.LabelNoCount)) { contents[thing.LabelNoCount] = contents.GetValueSafe(thing.LabelNoCount) + thing.stackCount; //contents.Add(thing.LabelNoCount, contents.GetValueSafe(thing.LabelNoCount) + thing.stackCount); } else { contents.Add(thing.LabelNoCount, thing.stackCount); } } } //output = output + stockpile.label + ", "; } log.Message("You selected a stockpile!!!"); if (contents.Count != 0) { foreach (KeyValuePair <string, int> kvp in contents) { output = output + kvp.Key + " (" + kvp.Value + ")\n"; } log.Message("It contains: " + output); Dialog_MessageBox msgBox = new Dialog_MessageBox("It contains: " + output, "OK"); Find.WindowStack.Add(msgBox); } } }