# HG changeset patch # User Alys Brooks # Date 2021-09-29 07:38:57 # Node ID d4905f4fdfdba7b708583338c254a60cad9d53c8 # Parent ad760cacfa0287347946a58fe8d3b5a58bb3c204 Adding events. diff --git a/isometric-park-fna/Content/dialog.ink b/isometric-park-fna/Content/dialog.ink --- a/isometric-park-fna/Content/dialog.ink +++ b/isometric-park-fna/Content/dialog.ink @@ -4,8 +4,11 @@ VAR GovernorOpinion = 0 +LIST assistantTraits = shy, esoteric, sweary -//This is needed to make both including and for jumpting to dialog sections work: + + +//This is needed to make both including and for jumping to dialog sections work: === placeholder === -> END @@ -76,7 +79,6 @@ === BadNewsReact === - + [Damn.] {inc(playerSwears)} ->-> + [Fuck.] {inc(playerSwears)} @@ -85,6 +87,8 @@ ->-> + [*Sigh.* Fine.] ->-> + + [Who cares?] + ->-> === AssistantAcknowlege === + [Thanks.] @@ -97,7 +101,7 @@ -> Appreciate = Appreciate - \#assistantName\#: Oh, you're welcome. + \#assistantName\#: {assistantTraits ? shy:...|{~No problem.|Oh, you're welcome.|My pleasure.}} ->-> === MassVandalism === @@ -110,7 +114,7 @@ -> BadNewsReact -> - \#assistantName\#: Yeah, it's awful. + \#assistantName\#: Yeah, it's {assistantTraits ? sweary:fucking|} awful. I'll see who's around and get to cleaning. diff --git a/isometric-park-fna/Content/dialog_runner.ink b/isometric-park-fna/Content/dialog_runner.ink --- a/isometric-park-fna/Content/dialog_runner.ink +++ b/isometric-park-fna/Content/dialog_runner.ink @@ -3,6 +3,8 @@ INCLUDE dialog.ink +~ assistantTraits = (shy, sweary) + -> MassVandalism diff --git a/isometric-park-fna/Engines/EventEngine.cs b/isometric-park-fna/Engines/EventEngine.cs --- a/isometric-park-fna/Engines/EventEngine.cs +++ b/isometric-park-fna/Engines/EventEngine.cs @@ -52,11 +52,11 @@ var campaignEntity = CreateEntity(); - AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(4)}); + AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(40)}); // AddComponent(campaignEntity, new AreaComponent{squares=final_squares}); } - if (this.Random.Next(0, 10) == 3) + if (this.Random.Next(0, 100) == 3) { Logging.Debug("Mass vandalism 😿"); diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -128,40 +128,44 @@ { var delta = GetComponent(entity); - if (delta.deltaTrees.Value < 0) - { - var squares = HasComponent(entity) ? GetComponent(entity).squares : this.all_squares; - var removed = 0; - var tree_squares = squares.Where((square) => simulation.map.cells[(int)square.X][(int)square.Y].hasTree); - var to_remove = -delta.deltaTrees.Value; + var squares = HasComponent(entity) ? GetComponent(entity).squares : this.all_squares; + var removed = 0; + var added = 0; + var tree_squares = squares.Where((square) => simulation.map.cells[(int)square.X][(int)square.Y].hasTree); + var to_remove = Math.Abs(delta.deltaTrees.Value); - //calculate the probability in order to get the expected number of removed trees - var expected = to_remove; - var trials = tree_squares.Count(); - double probability = ((double)expected / (double)trials) / 12; + //calculate the probability in order to get the expected number of removed trees + var expected = to_remove; + var trials = tree_squares.Count(); + double probability = ((double)expected / (double)trials) / 12; - foreach (var square in tree_squares) + foreach (var square in tree_squares) + { + var cell = simulation.map.cells[(int)square.X][(int)square.Y]; + if (cell.hasTree + && random_generator.NextDouble() < probability) { - var cell = simulation.map.cells[(int)square.X][(int)square.Y]; - if (cell.hasTree - && random_generator.NextDouble() < probability) + if (delta.deltaTrees.Value < 0) { cell.removeTree(); removed++; } - if (removed >= to_remove) + else if (delta.deltaTrees.Value > 0) { - // break; + cell.addTree(this.simulation.DateTime); + added++; } } - Logging.Info(String.Format("Destroyed {0} trees, expected {1}, P(destroy)= {2}", removed, (expected / 12), probability)); + if (removed >= to_remove) + { + // break; + } } - else - { - } + Logging.Info(String.Format("Destroyed {0} trees, expected {1}, P(plant)= {2}", removed, (expected / 12.0), probability)); + Logging.Info(String.Format("Planted {0} trees, expected {1}, P(destroy)= {2}", added, (expected / 12.0), probability)); } + } - } } this.ticksToSend = 0;