From 87d76198575530c0734b579ebbbd036372c16de6 Mon Sep 17 00:00:00 2001 From: DragonAura <32223554+DragonAura@users.noreply.github.com> Date: Sat, 11 May 2024 22:10:38 +0800 Subject: [PATCH] Revert "feat: :sparkles: add Repair" --- dependency/proto/Services.proto | 2 - logic/GameClass/GameObj/Areas/Home.cs | 16 +------- logic/Gaming/ActionManager.cs | 57 +-------------------------- logic/Gaming/Game.cs | 13 +----- logic/Server/RpcServices.cs | 32 --------------- 5 files changed, 4 insertions(+), 116 deletions(-) diff --git a/dependency/proto/Services.proto b/dependency/proto/Services.proto index 21c2becb..dbc18505 100755 --- a/dependency/proto/Services.proto +++ b/dependency/proto/Services.proto @@ -17,8 +17,6 @@ service AvailableService rpc Produce(IDMsg) returns (BoolRes); // 开采 rpc Rebuild(ConstructMsg) returns (BoolRes); // 给建筑回血 rpc Construct(ConstructMsg) returns (BoolRes); // 修建建筑 - rpc RepairHome(IDMsg) returns (BoolRes); // 修理大本营 - rpc RepairWormhole(IDMsg) returns (BoolRes); // 修理虫洞 rpc Attack(AttackMsg) returns (BoolRes); // 攻击 rpc Send(SendMsg) returns (BoolRes); // 传递信息 // 大本营 diff --git a/logic/GameClass/GameObj/Areas/Home.cs b/logic/GameClass/GameObj/Areas/Home.cs index c91baffa..3746ca96 100755 --- a/logic/GameClass/GameObj/Areas/Home.cs +++ b/logic/GameClass/GameObj/Areas/Home.cs @@ -1,7 +1,6 @@ using Preparation.Interface; using Preparation.Utility; using Preparation.Utility.Value; -using Preparation.Utility.Value.SafeValue.Atomic; using Preparation.Utility.Value.SafeValue.LockedValue; namespace GameClass.GameObj.Areas; @@ -13,23 +12,10 @@ public class Home(XY initPos, long id) public InVariableRange HP { get; } = new(GameData.HomeHP); public override bool IsRigid => true; public override ShapeType Shape => ShapeType.Square; - public AtomicInt RepairNum { get; } = new AtomicInt(0); - public bool Repair(int constructSpeed, Ship ship) - { - return HP.AddVUseOtherRChange(constructSpeed, ship.MoneyPool.Money, 1) > 0; - } + public void BeAttacked(Bullet bullet) { if (bullet!.Parent!.TeamID != TeamID) HP.SubPositiveV(bullet.AP); } - public void AddRepairNum(int add = 1) - { - RepairNum.Add(add); - } - public void SubRepairNum(int sub = 1) - { - RepairNum.Sub(sub); - } - } diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 25bdcfd3..37c3d021 100755 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -240,62 +240,7 @@ public bool Construct(Ship ship, ConstructionType constructionType) { IsBackground = true }.Start(); return false; } - public bool RepairHome(Ship ship) - { - Home? home = ((Home?)gameMap.OneForInteract(ship.Position, GameObjType.Home)); - if (home == null) - { - return false; - } - if (home.HP.IsMaxV()) - { - return false; - } - long stateNum = ship.SetShipState(RunningStateType.Waiting, ShipStateType.Constructing); - if (stateNum == -1) - { - return false; - } - new Thread - ( - () => - { - ship.ThreadNum.WaitOne(); - if (!ship.StartThread(stateNum, RunningStateType.RunningActively)) - { - ship.ThreadNum.Release(); - return; - } - home.AddRepairNum(); - Thread.Sleep(GameData.CheckInterval); - new FrameRateTaskExecutor - ( - loopCondition: () => stateNum == ship.StateNum && gameMap.Timer.IsGaming, - loopToDo: () => - { - if (!home.Repair(ship.ConstructSpeed / GameData.NumOfStepPerSecond, ship)) - { - ship.ResetShipState(stateNum); - return false; - } - if (home.HP == home.HP.GetMaxV()) - { - ship.ResetShipState(stateNum); - return false; - } - return true; - }, - timeInterval: GameData.CheckInterval, - finallyReturn: () => 0 - ).Start(); - ship.ThreadNum.Release(); - home.SubRepairNum(); - } - ) - { IsBackground = true }.Start(); - return false; - } - public bool RepairWormhole(Ship ship) + public bool Repair(Ship ship) { Wormhole? wormhole = ((WormholeCell?)gameMap.OneForInteract(ship.Position, GameObjType.Wormhole))?.Wormhole; if (wormhole == null) diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index 5ae9c04c..7d9f26ca 100755 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -220,22 +220,13 @@ public bool Recycle(long teamID, long shipID) } return false; } - public bool RepairHome(long teamID, long shipID) + public bool Repair(long teamID, long shipID) { if (!gameMap.Timer.IsGaming) return false; Ship? ship = gameMap.FindShipInPlayerID(teamID, shipID); if (ship != null) - return actionManager.RepairHome(ship); - return false; - } - public bool RepairWormhole(long teamID, long shipID) - { - if (!gameMap.Timer.IsGaming) - return false; - Ship? ship = gameMap.FindShipInPlayerID(teamID, shipID); - if (ship != null) - return actionManager.RepairWormhole(ship); + return actionManager.Repair(ship); return false; } public bool Stop(long teamID, long shipID) diff --git a/logic/Server/RpcServices.cs b/logic/Server/RpcServices.cs index 4cd9f19f..2b8d21d8 100755 --- a/logic/Server/RpcServices.cs +++ b/logic/Server/RpcServices.cs @@ -334,38 +334,6 @@ public override Task Construct(ConstructMsg request, ServerCallContext return Task.FromResult(boolRes); } - public override Task RepairHome(IDMsg request, ServerCallContext context) - { - GameServerLogging.logger.ConsoleLogDebug( - $"TRY RepairHome: Player {request.PlayerId} from Team {request.TeamId}"); - BoolRes boolRes = new(); - if (request.PlayerId >= spectatorMinPlayerID) - { - boolRes.ActSuccess = false; - return Task.FromResult(boolRes); - } - // var gameID = communicationToGameID[request.TeamId][request.PlayerId]; - boolRes.ActSuccess = game.RepairHome(request.TeamId, request.PlayerId); - GameServerLogging.logger.ConsoleLogDebug("END RepairHome"); - return Task.FromResult(boolRes); - } - - public override Task RepairWormhole(IDMsg request, ServerCallContext context) - { - GameServerLogging.logger.ConsoleLogDebug( - $"TRY RepairWormhole: Player {request.PlayerId} from Team {request.TeamId}"); - BoolRes boolRes = new(); - if (request.PlayerId >= spectatorMinPlayerID) - { - boolRes.ActSuccess = false; - return Task.FromResult(boolRes); - } - // var gameID = communicationToGameID[request.TeamId][request.PlayerId]; - boolRes.ActSuccess = game.RepairWormhole(request.TeamId, request.PlayerId); - GameServerLogging.logger.ConsoleLogDebug("END RepairWormhole"); - return Task.FromResult(boolRes); - } - public override Task Attack(AttackMsg request, ServerCallContext context) { GameServerLogging.logger.ConsoleLogDebug(