private void onDroughtEnd() { KingdomLog.TryLog("droughtend", "<color=green>The peasants rejoice! The blight upon our land has ended!</color>", KingdomLog.LogStatus.Neutral); timeRemaining = 0; droughtRunning = false; }
private void Update() { if (Input.GetKeyDown(KeyCode.M)) { ModSettingsUI._base.SetActive(!ModSettingsUI._base.activeSelf); } #region Debug if (Settings.debug) { if (Input.GetKeyDown(KeyCode.T)) { Events.EventManager.TriggerEvent(typeof(Events.EarthquakeEvent)); } if (Input.GetKeyDown(KeyCode.F)) { KingdomLog.TryLog("eat" + SRand.Range(1f, 100f).ToString(), "eat rate " + Player.inst.SecondsPerEat.ToString(), KingdomLog.LogStatus.Important); } if (Input.GetKeyDown(KeyCode.R)) { Events.EventManager.TriggerEvent(typeof(Events.RiotEvent)); } if (Input.GetKeyDown(KeyCode.E)) { Events.EventManager.TriggerEvent(typeof(Events.DroughtEvent)); } } #endregion }
public bool InsideSelectionBounds(int minx, int minz, int maxx, int maxz) { KingdomLog.TryLog("test-1-212-12", "test1212113", KingdomLog.LogStatus.Neutral); Vector3 c = riot.rallyPos; return((minx < c.x && c.x < maxx) && (minz < c.z && c.z < maxz)); }
public static void Log(string message, bool repeatable = false, KingdomLog.LogStatus type = KingdomLog.LogStatus.Neutral, object GameObjectOrVector3 = null) { if (ModUtilsMain.debug) { KingdomLog.TryLog(ModUtilsMain.ModID + "_debugmsg-" + IDs.Count + (repeatable ? SRand.Range(0, 1).ToString() : ""), message, type, (repeatable ? 1 : 20), GameObjectOrVector3); IDs.Add(1); } }
public override void Run() { base.Run(); KingdomLog.TryLog("drought", "My Lord, a terrible drought has struck our land, for the next <color=yellow>" + Settings.droughtLength.ToString() + " " + (Settings.droughtLength == 1 ? "year" : "years") + "</color>, our harvest will be poor!", KingdomLog.LogStatus.Neutral); timeRemaining = Settings.droughtLength; droughtRunning = true; originalWaterHeight = -0.65f; }
public override void Run() { base.Run(); try { RiotSpawn riot = null; if (riots.Count > 0) { foreach (RiotSpawn riotSpawn in riots) { if (riotSpawn.rioters.Count < Settings.riotMaxSize) { riot = riotSpawn; } } } if (riot == null) { riot = new RiotSpawn(GetRallyPoint(Util.GetPlayerStartLandmass())); } ArrayExt <Villager> villagers = World.inst.GetVillagersForLandMass(Util.GetPlayerStartLandmass()); int numRioters = Settings.riotStartSize; int num = (int)((float)numRioters / Settings.riotMaxSize); for (int k = 0; k < num + 1; k++) { while (riot.rioters.Count < Settings.riotMaxSize && numRioters > 0) { Villager vil = Player.inst.Workers.data[SRand.Range(0, Player.inst.Workers.Count - 1)]; RioterJob newRioter = new RioterJob(riot); newRioter.AssignEmployee(vil); newRioter.employer = riot; JobSystem.inst.AddNewJob(newRioter, JobCategory.Homemakers); numRioters -= 1; } if (numRioters > 0) { riots.Add(riot); riot = new RiotSpawn(GetRallyPoint(Util.GetPlayerStartLandmass())); } else { break; } } KingdomLog.TryLog("riotAssembling", "My Lord, a riot has begun to assemble!", KingdomLog.LogStatus.Important, 20, riot.GetRallyPoint().Center); }catch (Exception ex) { KingdomLog.TryLog("Exception-" + SRand.Range(0, 100), ex.Message + "\n" + ex.StackTrace, KingdomLog.LogStatus.Neutral); } }
public void SetRallyPoint(Cell cell) { rallyCell = cell; rallyPos = cell.Center; foreach (Villager rioter in rioters) { KingdomLog.TryLog("vil", "vil", KingdomLog.LogStatus.Neutral); ((RioterJob)rioter.job).SetRallyPoint(cell); } SetupRallyMarker(); }
private void Thief_OnCapture() { KingdomLog.TryLog("thiefcaptured", "My lord, a thief has been caught, in their crimes they have robbed " + AmountStolen.ToString() + " of the royal treasury, they will return the gold and anwser for their crimes", KingdomLog.LogStatus.Neutral); Player.inst.PlayerLandmassOwner.Gold += AmountStolen; }
public override void Run() { base.Run(); float magnitude = Util.LinearWeightedRandom(Settings.earthquakeStrength.Min, Settings.earthquakeStrength.Max) + Settings.earthquakeVariance.Rand(); float m_weightage = magnitude / 10f; float burnLine_terrafromChance = 0.8f; float burnLine_terraformLikelinessWeightage = 0.2f; float AOE_terraformChance = 0.5f * m_weightage; float AOE_terraformLikelinessWeightage = 0.6f; float AOE_fireChance = 0.9f; float AOE_rockChance = 0.05f; float AOE_ironChance = 0.05f; float AOE_stoneChance = 0.1f; float AOE_treeKillChance = 0.3f; float radius = 1f; int peopleKilled = 0; int buildingsDestroyed = 0; int landmass = (int)SRand.Range(0, World.inst.NumLandMasses); float lineBreak = 1.5f; float lineResolution = 1f; Cell rand1 = World.inst.cellsToLandmass[landmass].RandomElement(); Cell rand2 = World.inst.cellsToLandmass[landmass].RandomElement(); Cell[] line = getCraggyLine(rand1, rand2, 10); Cell last = null; Cam.inst.Shake(new Vector3(magnitude * 2, 0f, magnitude * 2)); float i = line.Length; Vector3 midpoint = line[line.Length / 2].Center; KingdomLog.TryLog("earthquakeStruck", "My lord, " + GetAdjectiveForMagnitude(magnitude) + " earthquake of magnitude " + Util.RoundToFactor(magnitude, 0.1f).ToString() + " has struck the land! ", KingdomLog.LogStatus.Warning, 1, midpoint); foreach (Cell point in line) { radius = (line.Length - Math.Abs(i - (line.Length / 2))) * m_weightage; if (last != null) { Vector3 difference = -(last.Center - point.Center); Vector3 currentPos = last.Center; float currentDiff = Math.Abs(Vector3.Distance(point.Center, last.Center)); while (currentDiff > lineBreak) { currentPos += Vector3.ClampMagnitude(difference, lineResolution); Cell currentCell = World.inst.GetCellData(currentPos); #region Burn Line int m_radius = (int)(magnitude * radius); if (m_radius <= 0) { m_radius = 1; } bool terraform = Util.Randi() <= burnLine_terrafromChance; #region Terraform if (terraform) { // weighted random in favor of terraforming tiles into similar type of the original tile bool likeType = Util.Randi() < burnLine_terraformLikelinessWeightage; if (currentCell.Type != ResourceType.Water) { float height = Settings.earthquakeLandElevation.Rand(); if (likeType) { Util.AnnhiliateCell(currentCell, false, true); Util.SetLandTile(currentCell, 0, height); Util.SetCellLandmass(currentCell, landmass); } else { height = Settings.earthquakeWaterElevation.Rand(); Util.AnnhiliateCell(currentCell); Util.SetWaterTile(currentCell, height); Util.SetCellLandmass(currentCell, landmass); } } else { float height = Settings.earthquakeWaterElevation.Rand(); if (likeType) { Util.AnnhiliateCell(currentCell, false, true); Util.SetWaterTile(currentCell, height); Util.SetCellLandmass(currentCell, landmass); } else { height = Settings.earthquakeLandElevation.Rand(); Util.AnnhiliateCell(currentCell); Util.SetLandTile(currentCell, 0, height); Util.SetCellLandmass(currentCell, landmass); } } } #endregion #endregion #region AOE World.inst.ForEachTileInRadius((int)currentCell.Center.x, (int)currentCell.Center.z, m_radius, delegate(int x, int z, Cell _cell) { float burnLineDist = Vector3.Distance(currentCell.Center, _cell.Center); // bias all chance events to be less likely further from the source line float weightage = 1f - (burnLineDist / m_radius); bool c_terraform = Util.Randi() < weightage * AOE_terraformChance; bool c_fire = Util.Randi() < weightage * AOE_fireChance; bool c_rock = Util.Randi() < weightage * AOE_rockChance && _cell.Type != ResourceType.Water; bool c_treeKill = Util.Randi() < weightage * AOE_treeKillChance; if (c_terraform) { // weighted random in favor of terraforming tiles into similar type of the original tile bool likeType = Util.Randi() < AOE_terraformLikelinessWeightage * 10; if (_cell.Type != ResourceType.Water) { float height = Settings.earthquakeLandElevation.Rand(); if (likeType) { Util.AnnhiliateCell(_cell, false, true); Util.SetLandTile(_cell, 0, height); Util.SetCellLandmass(_cell, landmass); } else { height = Settings.earthquakeWaterElevation.Rand(); Util.AnnhiliateCell(_cell); Util.SetWaterTile(_cell, height); Util.SetCellLandmass(_cell, landmass); } } else { float height = Settings.earthquakeWaterElevation.Rand(); if (likeType) { Util.AnnhiliateCell(_cell, false, true); Util.SetWaterTile(_cell, height); Util.SetCellLandmass(_cell, landmass); } else { height = Settings.earthquakeLandElevation.Rand(); Util.AnnhiliateCell(_cell); Util.SetLandTile(_cell, 0, height); Util.SetCellLandmass(_cell, landmass); } } } if (c_fire) { Assets.Code.FireManager.inst.StartFireAt(_cell); } if (c_rock) { ResourceType type = ResourceType.UnusableStone; if (Util.Randi() < weightage * AOE_stoneChance) { type = ResourceType.Stone; } if (Util.Randi() < weightage * AOE_ironChance) { type = ResourceType.IronDeposit; } Util.SetCellType(_cell, type); } if (c_treeKill) { TreeSystem.inst.DeleteTreesAt(_cell); } }); #endregion TerrainGen.inst.FinalizeChanges(); currentDiff = Math.Abs(Vector3.Distance(point.Center, currentPos)); } } last = point; i -= 1f; } }
public void ReportArrivalAtRallyPoint(Villager person) { KingdomLog.TryLog("arrival2", "arrival2", KingdomLog.LogStatus.Neutral); riotersAtRally.Add(person); CheckRallyAttendance(); }
public void OnRallyOrganized() { KingdomLog.TryLog("riotAssembled", "My lord, the peasants demand that we pay tribute to them by the close of the year, else they shall march on your Keep!", KingdomLog.LogStatus.Warning, 20, GetRallyPoint()); }
// ===================================================================== // Utility Functions // ===================================================================== // Logger in the log box in game. private static void LogInGame(string message, KingdomLog.LogStatus status = KingdomLog.LogStatus.Neutral) { KingdomLog.TryLog($"{modId}-{logId}", message, status); logId++; }
public void ReportArrivalAtRallyPoint() { KingdomLog.TryLog("arrival", "arrival", KingdomLog.LogStatus.Neutral); riot.ReportArrivalAtRallyPoint(base.Employee); }