-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #653 from starfi5h/pr-drone
Rework drone syncing for 0.10.29.21950
- Loading branch information
Showing
22 changed files
with
445 additions
and
1,360 deletions.
There are no files selected for viewing
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; | ||
|
||
public class PrebuildItemRequiredUpdate | ||
{ | ||
public PrebuildItemRequiredUpdate() { } | ||
|
||
public PrebuildItemRequiredUpdate(int planetId, int prebuildId, int itemCount) | ||
{ | ||
PlanetId = planetId; | ||
PrebuildId = prebuildId; | ||
ItemCount = itemCount; | ||
} | ||
|
||
public int PlanetId { get; set; } | ||
public int PrebuildId { get; set; } | ||
public int ItemCount { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
NebulaModel/Packets/Players/PlayerEjectMechaDronePacket.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,26 @@ | ||
namespace NebulaModel.Packets.Players; | ||
|
||
public class PlayerEjectMechaDronePacket | ||
{ | ||
public PlayerEjectMechaDronePacket() { } | ||
|
||
public PlayerEjectMechaDronePacket(ushort playerId, int planetId, int targetObjectId, | ||
int next1ObjectId, int next2ObjectId, int next3ObjectId, int dronePriority) | ||
{ | ||
PlayerId = playerId; | ||
PlanetId = planetId; | ||
TargetObjectId = targetObjectId; | ||
Next1ObjectId = next1ObjectId; | ||
Next2ObjectId = next2ObjectId; | ||
Next3ObjectId = next3ObjectId; | ||
DronePriority = dronePriority; | ||
} | ||
|
||
public ushort PlayerId { get; set; } | ||
public int PlanetId { get; set; } | ||
public int TargetObjectId { get; set; } | ||
public int Next1ObjectId { get; set; } | ||
public int Next2ObjectId { get; set; } | ||
public int Next3ObjectId { get; set; } | ||
public int DronePriority { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace NebulaModel.Packets.Players; | ||
|
||
public class PlayerGiveItemPacket | ||
{ | ||
public PlayerGiveItemPacket() { } | ||
|
||
public PlayerGiveItemPacket(int itemId, int itemCount, int itemInc) | ||
{ | ||
ItemId = itemId; | ||
ItemCount = itemCount; | ||
ItemInc = itemInc; | ||
} | ||
|
||
public int ItemId { get; set; } | ||
public int ItemCount { get; set; } | ||
public int ItemInc { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
NebulaNetwork/PacketProcessors/Factory/Entity/PrebuildItemRequiredUpdateProcessor.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,51 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Factory; | ||
using NebulaModel.Packets.Players; | ||
using NebulaWorld; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Factory.Entity; | ||
|
||
[RegisterPacketProcessor] | ||
public class PrebuildItemRequiredUpdateProcessor : PacketProcessor<PrebuildItemRequiredUpdate> | ||
{ | ||
protected override void ProcessPacket(PrebuildItemRequiredUpdate packet, NebulaConnection conn) | ||
{ | ||
var planet = GameMain.galaxy.PlanetById(packet.PlanetId); | ||
if (planet.factory == null || packet.PrebuildId >= planet.factory.prebuildCursor) | ||
{ | ||
return; | ||
} | ||
var factory = planet.factory; | ||
|
||
ref var ptr = ref factory.prebuildPool[packet.PrebuildId]; | ||
if (ptr.id != packet.PrebuildId || ptr.itemRequired == 0) | ||
{ | ||
//Prebuild not exist or the prebuild has satisfied the item requirement (green) | ||
if (IsHost) | ||
{ | ||
//Refund the item back to the player | ||
var itemId = ptr.protoId; | ||
conn.SendPacket(new PlayerGiveItemPacket(itemId, packet.ItemCount, 0)); | ||
} | ||
return; | ||
} | ||
|
||
using (Multiplayer.Session.Factories.IsIncomingRequest.On()) | ||
{ | ||
//From ConstructionModuleComponent.PlaceItems | ||
ptr.itemRequired = 0; | ||
factory.NotifyPrebuildChange(ptr.id, 3); | ||
if (factory.planet.factoryLoaded || factory.planet.factingCompletedStage >= 3) | ||
{ | ||
factory.AlterPrebuildModelState(ptr.id, false); | ||
} | ||
factory.constructionSystem.AddBuildTargetToModules(ptr.id, ref ptr.pos); | ||
} | ||
} | ||
} |
192 changes: 0 additions & 192 deletions
192
NebulaNetwork/PacketProcessors/Players/NewDroneOrderProcessor.cs
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
NebulaNetwork/PacketProcessors/Players/PlayerEjectMechaDroneProcessor.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,23 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Players; | ||
using NebulaWorld; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Players; | ||
|
||
[RegisterPacketProcessor] | ||
public class PlayerEjectMechaDroneProcessor : PacketProcessor<PlayerEjectMechaDronePacket> | ||
{ | ||
protected override void ProcessPacket(PlayerEjectMechaDronePacket packet, NebulaConnection conn) | ||
{ | ||
var factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory; | ||
if (factory == null) return; | ||
|
||
Multiplayer.Session.Drones.EjectMechaDroneFromOtherPlayer(packet); | ||
} | ||
} |
Oops, something went wrong.