# HG changeset patch # User alys # Date 2021-04-29 02:34:18 # Node ID edc55e82125794d7e86c79b60bb3774611760647 # Parent 8c6bbc430a37439c89c8a867d75b56f48a15545e Change delta to be per-year diff --git a/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache b/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache index 05873cc92109300c3b02ac64753b169217aa3ba2..7a76dd3093ef3fc7732972f332298d6400a0b45e GIT binary patch literal 11415 zc%1E84R96J72bXSn*fR0Dz*p#`ITf}0{J08fJZ_gLINb1su1G7_wGxU?A!O)-4_fh zprS3*Ul69?&wz?nREiYs)andW#F<)kiUn&GZHo#;lv?Rj?Et-Jv%A^N-c3k&afTT- zle3#W=YHoqXYbFsyP;@`qR!$2&T#Z|VX?THk4OnQ5mVUdDPD-O3plw&X3G;2%FU@q zlFTQ>vVtPEfX!#~b92g5f|8O@nTS$~#0j}M^HO1fkIY7G3lc3zEDPt4j}^sAVg&`! zqI_;V=LKg&$v*1ZWCg|R6iz{4#l(04seic#wW}}-K|m1&Q;^wNoZPH%VF3Ya#*Kvs zM3<&MY>+W0!9^>%h?0=}T0EJUZh0b})^Y~-6noZNCwMifnFL&G29U!Na~ z;lY$F1qD7Fj3>lIu#hdvttZrTLE7&@)t+3=A`jOd~Ew5)!_v+GS$9oG$5tRX=Q1 z+@)1*N>unbV(XB^a{|AdgNLoQ?T_2m_d1}ilQjTi&*(LFO)8GrMr0K#3qy_QGDIV{ z+1RwU*Iu17bqU5D-6e$ziCe~tO{(>!*m_FOSy-O_Wf)^jmmV!S`a!ojs^An(HHA@A z8f;F)QIHebB^7DGIFc#KJu3cMKOWg&d7Dmco~SYAz4Q8u+Ub+ z#nFtL6(qvM1Iro>V%5{rZ`pR_F9CH;EPxd(BZHzL8-qG)$LZR^y7m-%eA+xsJ6_ig zA+;^kwK*hhk**y|(iZF5VI;pLy7p?4c7m=QPC_o#wIfJvC+gafq_&fE?I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ogT1kjVS=s}+lXm9=kU*~md_FD*v{bK-l}7gpbRV13r3 zdZ;_6Hm)npfFWR7A za)N%D2>pt7;i6yF8p1bspSj^)bHmfxg%=9x3+#i2tK)-)x_h86e$PnP_lz@?>3u;4 z14R{M)LWEZa-BWXUUGR>;XlrtF_&EMX_Rr}Ywv3pJJ!XHWppeLZB+9a4E*~bTJoB$XS01X!^m(2eID4UCD diff --git a/isometric-park-fna/CellMap.cs b/isometric-park-fna/CellMap.cs --- a/isometric-park-fna/CellMap.cs +++ b/isometric-park-fna/CellMap.cs @@ -114,7 +114,7 @@ public Boolean inBounds(int x, int y) { - return MathUtils.Between(x, 0, MapWidth - 1) && MathUtils.Between(y, 0, MapHeight - 1); + return MathUtils.BetweenExclusive(x, 0, MapWidth - 1) && MathUtils.BetweenExclusive(y, 0, MapHeight - 1); } private System.Collections.Generic.IEnumerable iterate_neighbors(int x, int y) diff --git a/isometric-park-fna/Engines/InputEngine.cs b/isometric-park-fna/Engines/InputEngine.cs --- a/isometric-park-fna/Engines/InputEngine.cs +++ b/isometric-park-fna/Engines/InputEngine.cs @@ -175,19 +175,19 @@ #region mouse_movement - if (MathUtils.Between(mouseCur.Y, menuBarHeight, 50 + menuBarHeight)) + if (MathUtils.BetweenExclusive(mouseCur.Y, menuBarHeight, 50 + menuBarHeight)) { SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)}); } - else if (MathUtils.Between(mouseCur.Y, (this.viewHeight - 50 -menuBarHeight), this.viewHeight-menuBarHeight)) + else if (MathUtils.BetweenExclusive(mouseCur.Y, (this.viewHeight - 50 -menuBarHeight), this.viewHeight-menuBarHeight)) { SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)}); } - if (MathUtils.Between(mouseCur.X, 0, 50)) + if (MathUtils.BetweenExclusive(mouseCur.X, 0, 50)) { SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)}); } - else if (MathUtils.Between(mouseCur.X, (this.viewWidth - 50), this.viewWidth)) + else if (MathUtils.BetweenExclusive(mouseCur.X, (this.viewWidth - 50), this.viewWidth)) { SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)}); } 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 @@ -107,7 +107,7 @@ //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); + double probability = ((double)expected / (double)trials) / 12; foreach (var square in tree_squares) { @@ -120,7 +120,7 @@ } if (removed >= to_remove) { - break; + // break; } } } diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs --- a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -57,8 +57,8 @@ if (random_generator.NextDouble() < 0.5 && !squares.Contains(new_square) && !occupied_squares.Contains(new_square) - && MathUtils.BetweenInclusive(new_square.X, 0, this.MapWidth) - && MathUtils.BetweenInclusive(new_square.Y, 0, this.MapHeight) + && MathUtils.Between(new_square.X, 0, this.MapWidth) + && MathUtils.Between(new_square.Y, 0, this.MapHeight) ) { squares_to_add.Add(new_square); diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -485,8 +485,8 @@ Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice)); return (!FNAGame.enableCulling || - (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width) - && MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); + (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width) + && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); } //Convenience method I'm not super sure about anymore. @@ -782,14 +782,14 @@ null); bool has_tree = false; - if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross)) + if (MathUtils.BetweenExclusive(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.BetweenExclusive(this.mouseGrid.Y, 0, this.squaresAcross)) { has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree; } //*/ String status_left = ""; - if (MathUtils.Between(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight)) + if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight)) { status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status, diff --git a/isometric-park-fna/Line.cs b/isometric-park-fna/Line.cs --- a/isometric-park-fna/Line.cs +++ b/isometric-park-fna/Line.cs @@ -43,7 +43,7 @@ public static Vector2 departurePoint(Vector2 start, Vector2 stop, float width, float height) { - if (MathUtils.Between(stop.X, 0, width ) && MathUtils.Between(stop.Y, 0, height)) { + if (MathUtils.BetweenExclusive(stop.X, 0, width ) && MathUtils.BetweenExclusive(stop.Y, 0, height)) { return stop; } diff --git a/isometric-park-fna/UI/BudgetWindow.cs b/isometric-park-fna/UI/BudgetWindow.cs --- a/isometric-park-fna/UI/BudgetWindow.cs +++ b/isometric-park-fna/UI/BudgetWindow.cs @@ -37,16 +37,16 @@ this.previous_budget = previous_budget; if ((mouseCur.LeftButton == ButtonState.Pressed) - && MathUtils.Between(mouseCur.X, width+x-20, width+x) - && MathUtils.Between(mouseCur.Y, y+bar_height, y+bar_height+20) + && MathUtils.BetweenExclusive(mouseCur.X, width+x-20, width+x) + && MathUtils.BetweenExclusive(mouseCur.Y, y+bar_height, y+bar_height+20) ) { return false; } else if ((mouseCur.LeftButton == ButtonState.Pressed) - && MathUtils.Between(mouseCur.X, x, width+x) - && MathUtils.Between(mouseCur.Y, y, 500 + y)) + && MathUtils.BetweenExclusive(mouseCur.X, x, width+x) + && MathUtils.BetweenExclusive(mouseCur.Y, y, 500 + y)) { if (mousePrev.LeftButton == ButtonState.Released) { diff --git a/isometric-park-fna/Utils/MathUtils.cs b/isometric-park-fna/Utils/MathUtils.cs --- a/isometric-park-fna/Utils/MathUtils.cs +++ b/isometric-park-fna/Utils/MathUtils.cs @@ -7,17 +7,29 @@ { } + public static bool Between(float val, float x, float y) { + return ((x <= val && val < y) || (y <= val && val < x)); + + } + + public static bool Between(int val, int x, int y) + { + return ((x <= val && val < y) || (y <= val && val < x)); + + } + public static bool BetweenExclusive(float val, float x, float y) + { return ((x < val && val < y) || (y < val && val < x)); } - public static bool Between(int val, int x, int y) - { - return ((x < val && val < y) || (y < val && val < x)); + public static bool BetweenExclusive(int val, int x, int y) + { + return ((x < val && val < y) || (y < val && val < x)); - } + } public static bool BetweenInclusive(float val, float x, float y) { @@ -25,88 +37,91 @@ } - public static bool BetweenInclusive(int val, int x, int y) - { - return ((x <= val && val <= y) || (y <= val && val <= x)); + public static bool BetweenInclusive(int val, int x, int y) + { + return ((x <= val && val <= y) || (y <= val && val <= x)); - } + } - public static int Clamp(int val, int min, int max) + public static int Clamp(int val, int min, int max) { - if(val > max) + if (val > max) { - return max; + return max; } - else if (val < min) + else if (val < min) { - return min; + return min; } - else + else { - return val; + return val; } } - protected float Decrement(float value, float delta) - { - float magnitude = Math.Abs(value); + protected float Decrement(float value, float delta) + { + float magnitude = Math.Abs(value); - //If distance from zero is less than our delta, - //go to zero to prevent overshooting: - if (magnitude < delta) - { - return 0.0f; - } - else if (value > 0) - { - return value - delta; - } - else if (value < 0) - { - return value + delta; - } - else - { - return 0.0f; - } - } + //If distance from zero is less than our delta, + //go to zero to prevent overshooting: + if (magnitude < delta) + { + return 0.0f; + } + else if (value > 0) + { + return value - delta; + } + else if (value < 0) + { + return value + delta; + } + else + { + return 0.0f; + } + } public static System.Collections.Generic.IEnumerable NextNormalEnumerator(Random random, float mean, float variation) { - while (true) { + while (true) + { double u1 = random.NextDouble(); double u2 = random.NextDouble(); double z1 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2); double z2 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2); - yield return (variation * z1) + mean; - yield return (variation * z2) + mean; - } + yield return (variation * z1) + mean; + yield return (variation * z2) + mean; + } } public static Double NextNormal(Random random, float mean, float variation) { - //Uses Box-Muller to scale the default uniform distribution - double u1 = random.NextDouble(); - double u2 = random.NextDouble(); + //Uses Box-Muller to scale the default uniform distribution + double u1 = random.NextDouble(); + double u2 = random.NextDouble(); - double z1 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2); - double z2 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2); + double z1 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2); + double z2 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2); - if(random.NextDouble() > 0.5d) { - return (variation * z1) + mean; - } - else { - return (variation * z2) + mean; - } + if (random.NextDouble() > 0.5d) + { + return (variation * z1) + mean; + } + else + { + return (variation * z2) + mean; + } } - } + } }