Skip to content

Commit 1321552

Browse files
authored
Merge pull request #367 from asdawej/patch
fix(Ship): 🐛 add `Ship.Init()` method
2 parents 765bb84 + 961f0d6 commit 1321552

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

logic/GameClass/GameObj/Base.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public Base(Home home)
3232
{
3333
if (ship.IsRemoved.TrySet(false))
3434
{
35+
ship.Init();
3536
ship.CanMove.SetROri(true);
3637
return true;
3738
}

logic/GameClass/GameObj/Ship.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -434,23 +434,16 @@ public bool Commandable()
434434
&& shipState != ShipStateType.Attacking);
435435
}
436436
}
437-
public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) :
438-
base(GameData.PosNotInGame, initRadius, GameObjType.Ship)
437+
public void Init()
439438
{
440-
CanMove.SetROri(false);
441-
IsRemoved.SetROri(true);
442-
Occupation = OccupationFactory.FindIOccupation(ShipType = shipType);
443-
ViewRange = Occupation.ViewRange;
444-
HP = new(Occupation.MaxHp);
445-
Armor = new(Occupation.BaseArmor);
446-
Shield = new(Occupation.BaseShield);
439+
HP.SetMaxV(Occupation.MaxHp);
440+
HP.SetVToMaxV();
441+
Armor.SetMaxV(Occupation.BaseArmor);
442+
Armor.SetVToMaxV();
443+
Shield.SetMaxV(Occupation.BaseShield);
444+
Shield.SetVToMaxV();
447445
MoveSpeed.SetROri(orgMoveSpeed = Occupation.MoveSpeed);
448-
MoneyPool = moneyPool;
449-
450-
ProducerType producerType;
451-
ConstructorType constructorType;
452-
WeaponType weaponType;
453-
(producerType, constructorType, weaponType) = ShipType switch
446+
var (producerType, constructorType, weaponType) = ShipType switch
454447
{
455448
ShipType.CivilShip => (
456449
ProducerType.Producer1,
@@ -475,4 +468,17 @@ public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) :
475468
ShieldModule.SetROri(ModuleFactory.FindIShield(ShipType, ShieldType.Null));
476469
WeaponModule.SetROri(ModuleFactory.FindIWeapon(ShipType, weaponType));
477470
}
471+
public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) :
472+
base(GameData.PosNotInGame, initRadius, GameObjType.Ship)
473+
{
474+
CanMove.SetROri(false);
475+
IsRemoved.SetROri(true);
476+
Occupation = OccupationFactory.FindIOccupation(ShipType = shipType);
477+
ViewRange = Occupation.ViewRange;
478+
HP = new(Occupation.MaxHp);
479+
Armor = new(Occupation.BaseArmor);
480+
Shield = new(Occupation.BaseShield);
481+
MoneyPool = moneyPool;
482+
Init();
483+
}
478484
}

0 commit comments

Comments
 (0)