-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
27 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
NebulaModel/Packets/Factory/Turret/TurretPhaseUpdatePacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace NebulaModel.Packets.Factory.Turret; | ||
|
||
public class TurretPhaseUpdatePacket | ||
{ | ||
public TurretPhaseUpdatePacket() { } | ||
|
||
public TurretPhaseUpdatePacket(int turretId, int phasePos, int planetId) | ||
{ | ||
TurretId = turretId; | ||
PhasePos = phasePos; | ||
PlanetId = planetId; | ||
} | ||
|
||
public int TurretId { get; set; } | ||
public int PhasePos { get; set; } | ||
public int PlanetId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
NebulaNetwork/PacketProcessors/Factory/Turret/TurretPhaseUpdateProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Factory.Turret; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Factory.Turret; | ||
|
||
[RegisterPacketProcessor] | ||
internal class TurretPhaseUpdateProcessor : PacketProcessor<TurretPhaseUpdatePacket> | ||
{ | ||
protected override void ProcessPacket(TurretPhaseUpdatePacket packet, NebulaConnection conn) | ||
{ | ||
var pool = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.defenseSystem.turrets; | ||
if (pool == null || packet.TurretId < 0 || packet.TurretId >= pool.buffer.Length) | ||
{ | ||
return; | ||
} | ||
ref var turret = ref pool.buffer[packet.TurretId]; | ||
turret.phasePos = packet.PhasePos; | ||
|
||
// Refresh UI if viewing on the same turret | ||
var uiTurret = UIRoot.instance.uiGame.turretWindow; | ||
if (uiTurret.factory == null || uiTurret.factory.planetId != packet.PlanetId || uiTurret.turretId != packet.TurretId) | ||
{ | ||
return; | ||
} | ||
uiTurret.phaseText.text = (turret.phasePos / 60f).ToString("0.##"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters