From 1790ba948bb395caef4c54899cd4a4545c7bf307 Mon Sep 17 00:00:00 2001 From: 964293341 Date: Sat, 11 May 2024 23:27:56 +0800 Subject: [PATCH] fix(Ship): :bug: add `Ship.Init()` method --- logic/GameClass/GameObj/Base.cs | 1 + logic/GameClass/GameObj/Ship.cs | 36 +++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/logic/GameClass/GameObj/Base.cs b/logic/GameClass/GameObj/Base.cs index cb4d24a1..1d965f11 100644 --- a/logic/GameClass/GameObj/Base.cs +++ b/logic/GameClass/GameObj/Base.cs @@ -32,6 +32,7 @@ public Base(Home home) { if (ship.IsRemoved.TrySet(false)) { + ship.Init(); ship.CanMove.SetROri(true); return true; } diff --git a/logic/GameClass/GameObj/Ship.cs b/logic/GameClass/GameObj/Ship.cs index a9818643..c6073182 100755 --- a/logic/GameClass/GameObj/Ship.cs +++ b/logic/GameClass/GameObj/Ship.cs @@ -434,23 +434,16 @@ public bool Commandable() && shipState != ShipStateType.Attacking); } } - public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) : - base(GameData.PosNotInGame, initRadius, GameObjType.Ship) + public void Init() { - CanMove.SetROri(false); - IsRemoved.SetROri(true); - Occupation = OccupationFactory.FindIOccupation(ShipType = shipType); - ViewRange = Occupation.ViewRange; - HP = new(Occupation.MaxHp); - Armor = new(Occupation.BaseArmor); - Shield = new(Occupation.BaseShield); + HP.SetMaxV(Occupation.MaxHp); + HP.SetVToMaxV(); + Armor.SetMaxV(Occupation.BaseArmor); + Armor.SetVToMaxV(); + Shield.SetMaxV(Occupation.BaseShield); + Shield.SetVToMaxV(); MoveSpeed.SetROri(orgMoveSpeed = Occupation.MoveSpeed); - MoneyPool = moneyPool; - - ProducerType producerType; - ConstructorType constructorType; - WeaponType weaponType; - (producerType, constructorType, weaponType) = ShipType switch + var (producerType, constructorType, weaponType) = ShipType switch { ShipType.CivilShip => ( ProducerType.Producer1, @@ -475,4 +468,17 @@ public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) : ShieldModule.SetROri(ModuleFactory.FindIShield(ShipType, ShieldType.Null)); WeaponModule.SetROri(ModuleFactory.FindIWeapon(ShipType, weaponType)); } + public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) : + base(GameData.PosNotInGame, initRadius, GameObjType.Ship) + { + CanMove.SetROri(false); + IsRemoved.SetROri(true); + Occupation = OccupationFactory.FindIOccupation(ShipType = shipType); + ViewRange = Occupation.ViewRange; + HP = new(Occupation.MaxHp); + Armor = new(Occupation.BaseArmor); + Shield = new(Occupation.BaseShield); + MoneyPool = moneyPool; + Init(); + } }