Skip to content

Commit

Permalink
Merge pull request #152 from shangfengh/dev
Browse files Browse the repository at this point in the history
refactor: 🎨 standardize naming and introduce IAddable
  • Loading branch information
shangfengh authored Mar 28, 2024
2 parents 6a458f0 + 298b35a commit b12844e
Show file tree
Hide file tree
Showing 24 changed files with 551 additions and 519 deletions.
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Areas/Construction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool Construct(int constructSpeed, ConstructionType constructionType, Shi
{
if (this.constructionType == ConstructionType.Null || HP == 0)
{
TeamID.SetReturnOri(ship.TeamID);
TeamID.SetROri(ship.TeamID);
this.constructionType = constructionType;
switch (constructionType)
{
Expand Down
4 changes: 2 additions & 2 deletions logic/GameClass/GameObj/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public override bool IgnoreCollideExecutor(IGameObj targetObj)
public Bullet(Ship ship, int radius, XY Position) :
base(Position, radius, GameObjType.Bullet)
{
CanMove.SetReturnOri(true);
MoveSpeed.SetReturnOri(Speed);
CanMove.SetROri(true);
MoveSpeed.SetROri(Speed);
Parent = ship;
}
}
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Bullets/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public Arc(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
Random random = new();
AP.SetReturnOri(random.Next(GameData.ArcDamageMin, GameData.ArcDamageMax));
AP.SetROri(random.Next(GameData.ArcDamageMin, GameData.ArcDamageMax));
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.ArcRange;
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Bullets/Laser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class Laser : Bullet
public Laser(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
AP.SetReturnOri(GameData.LaserDamage);
AP.SetROri(GameData.LaserDamage);
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.LaserRange;
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Bullets/Missile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal sealed class Missile : Bullet
public Missile(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
AP.SetReturnOri(GameData.MissileDamage);
AP.SetROri(GameData.MissileDamage);
}
public override double BulletBombRange => GameData.MissileBombRange;
public override double AttackDistance => GameData.MissileRange;
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Bullets/Plasma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class Plasma : Bullet
public Plasma(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
AP.SetReturnOri(GameData.PlasmaDamage);
AP.SetROri(GameData.PlasmaDamage);
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.PlasmaRange;
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Bullets/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class Shell : Bullet
public Shell(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
AP.SetReturnOri(GameData.ShellDamage);
AP.SetROri(GameData.ShellDamage);
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.ShellRange;
Expand Down
2 changes: 1 addition & 1 deletion logic/GameClass/GameObj/Map/MapGameTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public bool StartGame(int timeInMilliseconds)
return false;
startTime = Environment.TickCount64;
Thread.Sleep(timeInMilliseconds);
IsGaming.SetReturnOri(false);
IsGaming.SetROri(false);
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions logic/GameClass/GameObj/MoneyPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ public class MoneyPool : IMoneyPool
public AtomicLong Score { get; } = new AtomicLong(0);
public MoneyPool()
{
Money.SetScore(Score);
Money.Score = Score;
}
public long AddMoney(long add)
{
return Money.Add(add);
return Money.AddRNow(add);
}
public long SubMoney(long sub)
{
return Money.Sub(sub);
return Money.SubRNow(sub);
}
}
8 changes: 4 additions & 4 deletions logic/GameClass/GameObj/Ship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public bool TryToRemoveFromGame(ShipStateType shipStateType)
{
if (SetShipState(RunningStateType.RunningForcibly, shipStateType) == -1) return false;
TryToRemove();
CanMove.SetReturnOri(false);
CanMove.SetROri(false);
position = GameData.PosNotInGame;
}
return true;
Expand All @@ -408,14 +408,14 @@ public bool Commandable()
public Ship(int initRadius, ShipType shipType, MoneyPool moneyPool) :
base(GameData.PosNotInGame, initRadius, GameObjType.Ship)
{
this.CanMove.SetReturnOri(false);
this.IsRemoved.SetReturnOri(true);
this.CanMove.SetROri(false);
this.IsRemoved.SetROri(true);
this.Occupation = OccupationFactory.FindIOccupation(this.ShipType = shipType);
this.ViewRange = this.Occupation.ViewRange;
this.HP = new(this.Occupation.MaxHp);
this.Armor = new(this.Occupation.BaseArmor);
this.Shield = new(this.Occupation.BaseShield);
this.MoveSpeed.SetReturnOri(this.orgMoveSpeed = Occupation.MoveSpeed);
this.MoveSpeed.SetROri(this.orgMoveSpeed = Occupation.MoveSpeed);
this.MoneyPool = moneyPool;
(this.producerType, this.constructorType, this.armorType, this.shieldType, this.weaponType) = this.ShipType switch
{
Expand Down
8 changes: 4 additions & 4 deletions logic/GameEngine/MoveEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void MoveObj(IMovable obj, int moveTime, double direction, long stateNum)
lock (obj.ActionLock)
{
if (!obj.IsAvailableForMove) { EndMove(obj); return; }
obj.IsMoving.SetReturnOri(true);
obj.IsMoving.SetROri(true);
}

new Thread
Expand Down Expand Up @@ -170,7 +170,7 @@ public void MoveObj(IMovable obj, int moveTime, double direction, long stateNum)
if (isEnded)
{
obj.IsMoving.SetReturnOri(false);
obj.IsMoving.SetROri(false);
EndMove(obj);
return;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ public void MoveObj(IMovable obj, int moveTime, double direction, long stateNum)
}
if (isEnded)
{
obj.IsMoving.SetReturnOri(false);
obj.IsMoving.SetROri(false);
EndMove(obj);
return;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ public void MoveObj(IMovable obj, int moveTime, double direction, long stateNum)
}
} while (flag);
}
obj.IsMoving.SetReturnOri(false); // 结束移动
obj.IsMoving.SetROri(false); // 结束移动
EndMove(obj);
}
}
Expand Down
4 changes: 2 additions & 2 deletions logic/Gaming/AttackManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private class AttackManager(Map gameMap, ShipManager shipManager)
public readonly MoveEngine moveEngine = new(
gameMap: gameMap,
OnCollision: (obj, collisionObj, moveVec) => MoveEngine.AfterCollision.Destroyed,
EndMove: obj => obj.CanMove.SetReturnOri(false)
EndMove: obj => obj.CanMove.SetROri(false)
);

public void ProduceBulletNaturally(BulletType bulletType, Ship ship, double angle, XY pos)
Expand Down Expand Up @@ -57,7 +57,7 @@ public bool TryRemoveBullet(Bullet bullet)
{
if (gameMap.Remove(bullet))
{
bullet.CanMove.SetReturnOri(false);
bullet.CanMove.SetROri(false);
if (bullet.BulletBombRange > 0)
{
BombedBullet bombedBullet = new(bullet);
Expand Down
2 changes: 1 addition & 1 deletion logic/Gaming/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void ClearAllLists()
{
gameMap.GameObjDict[GameObjType.Ship].ForEach(delegate (IGameObj ship)
{
((Ship)ship).CanMove.SetReturnOri(false);
((Ship)ship).CanMove.SetROri(false);
});
gameMap.GameObjDict[keyValuePair.Key].Clear();
}
Expand Down
6 changes: 3 additions & 3 deletions logic/Gaming/ShipManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ private class ShipManager(Map gameMap)
{
Ship newShip = new(GameData.ShipRadius, shipType, moneyPool);
gameMap.Add(newShip);
newShip.TeamID.SetReturnOri(teamID);
newShip.PlayerID.SetReturnOri(playerID);
newShip.TeamID.SetROri(teamID);
newShip.PlayerID.SetROri(playerID);
return newShip;
}
public bool ActivateShip(Ship ship, XY pos)
Expand All @@ -38,7 +38,7 @@ public bool ActivateShip(Ship ship, XY pos)
ship.ReSetPos(pos);
long stateNum = ship.SetShipState(RunningStateType.RunningActively, ShipStateType.Null);
ship.ResetShipState(stateNum);
ship.CanMove.SetReturnOri(true);
ship.CanMove.SetROri(true);
return true;
}
public void BeAttacked(Ship ship, Bullet bullet)
Expand Down
Loading

0 comments on commit b12844e

Please sign in to comment.