Skip to content

Commit

Permalink
fix(Ship): 🐛 add Ship.Init() method
Browse files Browse the repository at this point in the history
  • Loading branch information
asdawej committed May 11, 2024
1 parent 5fa8518 commit 1790ba9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions logic/GameClass/GameObj/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public Base(Home home)
{
if (ship.IsRemoved.TrySet(false))
{
ship.Init();
ship.CanMove.SetROri(true);
return true;
}
Expand Down
36 changes: 21 additions & 15 deletions logic/GameClass/GameObj/Ship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}
}

0 comments on commit 1790ba9

Please sign in to comment.