From dd2011ef6ab280ba595371b6c789f49c3458608c Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 11 May 2024 20:35:27 +0800 Subject: [PATCH 1/2] fix: :bug: rebuild ship --- logic/Gaming/Game.cs | 2 +- logic/Gaming/ShipManager.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index 1b44ebc7..8d1c577c 100755 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -95,7 +95,7 @@ public long ActivateShip(long teamID, ShipType shipType, int birthPointIndex = 0 birthPointIndex = teamList[(int)teamID].BirthPointList.Count - 1; XY pos = teamList[(int)teamID].BirthPointList[birthPointIndex]; pos += new XY(((random.Next() & 2) - 1) * 1000, ((random.Next() & 2) - 1) * 1000); - if (ShipManager.ActivateShip(ship, pos)) + if (shipManager.ActivateShip(ship, pos)) { GameLogging.logger.ConsoleLogDebug($"Successfully activated {teamID} {shipType} at {pos}"); return ship.PlayerID; diff --git a/logic/Gaming/ShipManager.cs b/logic/Gaming/ShipManager.cs index 7c15eac2..e978aa86 100755 --- a/logic/Gaming/ShipManager.cs +++ b/logic/Gaming/ShipManager.cs @@ -17,7 +17,6 @@ private class ShipManager(Game game, Map gameMap) public Ship? AddShip(long teamID, long playerID, ShipType shipType, MoneyPool moneyPool) { Ship newShip = new(GameData.ShipRadius, shipType, moneyPool); - gameMap.Add(newShip); newShip.TeamID.SetROri(teamID); newShip.PlayerID.SetROri(playerID); ShipManagerLogging.logger.ConsoleLogDebug( @@ -32,12 +31,13 @@ private class ShipManager(Game game, Map gameMap) + $"{newShip.WeaponModuleType}"); return newShip; } - public static bool ActivateShip(Ship ship, XY pos) + public bool ActivateShip(Ship ship, XY pos) { if (ship.ShipState != ShipStateType.Deceased) { return false; } + gameMap.Add(ship); ship.ReSetPos(pos); ship.SetShipState(RunningStateType.Null, ShipStateType.Null); ShipManagerLogging.logger.ConsoleLogDebug( From 928b9314a3ac6b6651c771b84b17de2fea4aa39b Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 11 May 2024 20:38:41 +0800 Subject: [PATCH 2/2] set AddShip static --- logic/Gaming/Game.cs | 2 +- logic/Gaming/ShipManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index 8d1c577c..7d9f26ca 100755 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -63,7 +63,7 @@ public long AddPlayer(PlayerInitInfo playerInitInfo) default: return GameObj.invalidID; } - Ship? newShip = shipManager.AddShip(playerInitInfo.teamID, + Ship? newShip = ShipManager.AddShip(playerInitInfo.teamID, playerInitInfo.playerID, playerInitInfo.shipType, teamList[(int)playerInitInfo.teamID].MoneyPool); diff --git a/logic/Gaming/ShipManager.cs b/logic/Gaming/ShipManager.cs index e978aa86..64b492e1 100755 --- a/logic/Gaming/ShipManager.cs +++ b/logic/Gaming/ShipManager.cs @@ -14,7 +14,7 @@ private class ShipManager(Game game, Map gameMap) { private readonly Game game = game; private readonly Map gameMap = gameMap; - public Ship? AddShip(long teamID, long playerID, ShipType shipType, MoneyPool moneyPool) + public static Ship? AddShip(long teamID, long playerID, ShipType shipType, MoneyPool moneyPool) { Ship newShip = new(GameData.ShipRadius, shipType, moneyPool); newShip.TeamID.SetROri(teamID);