-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
NebulaModel/Packets/Factory/Foundation/VeinPosUpdatePacket.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,20 @@ | ||
using NebulaAPI.DataStructures; | ||
using UnityEngine; | ||
|
||
namespace NebulaModel.Packets.Factory.Foundation; | ||
|
||
public class VeinPosUpdatePacket | ||
{ | ||
public VeinPosUpdatePacket() { } | ||
|
||
public VeinPosUpdatePacket(int planetId, int veinId, Vector3 pos) | ||
{ | ||
PlanetId = planetId; | ||
VeinId = veinId; | ||
Pos = new Float3(pos); | ||
} | ||
|
||
public int PlanetId { get; set; } | ||
public int VeinId { get; set; } | ||
public Float3 Pos { get; set; } | ||
} |
61 changes: 61 additions & 0 deletions
61
NebulaNetwork/PacketProcessors/Factory/Foundation/VeinPosUpdateProcessor.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,61 @@ | ||
#region | ||
|
||
using NebulaAPI.DataStructures; | ||
using NebulaAPI.Packets; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Factory.Foundation; | ||
using NebulaWorld; | ||
using UnityEngine; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Factory.Foundation; | ||
|
||
[RegisterPacketProcessor] | ||
internal class VeinPosUpdateProcessor : PacketProcessor<VeinPosUpdatePacket> | ||
{ | ||
protected override void ProcessPacket(VeinPosUpdatePacket packet, NebulaConnection conn) | ||
{ | ||
var planet = GameMain.galaxy.PlanetById(packet.PlanetId); | ||
if (planet?.factory == null) | ||
{ | ||
return; | ||
} | ||
|
||
var pos = packet.Pos.ToVector3(); | ||
ref var veinData = ref planet.factory.veinPool[packet.VeinId]; | ||
veinData.pos = pos; | ||
if (planet != GameMain.localPlanet) | ||
{ | ||
return; | ||
} | ||
|
||
// Update GPU models on the local planet | ||
var rot = Maths.SphericalRotation(pos, Random.value * 360f); | ||
GameMain.gpuiManager.AlterModel(veinData.modelIndex, veinData.modelId, packet.VeinId, pos, rot, false); | ||
var veinProto = LDB.veins.Select((int)veinData.type); | ||
if (veinProto != null) | ||
{ | ||
var magnitude = pos.magnitude; | ||
var normalVector = pos / magnitude; | ||
if (veinData.minerId0 > 0) | ||
{ | ||
GameMain.gpuiManager.AlterModel(veinProto.MinerBaseModelIndex, veinData.minerBaseModelId, veinData.minerId0, normalVector * (magnitude + 0.1f), false); | ||
GameMain.gpuiManager.AlterModel(veinProto.MinerCircleModelIndex, veinData.minerCircleModelId0, veinData.minerId0, normalVector * (magnitude + 0.4f), false); | ||
} | ||
if (veinData.minerId1 > 0) | ||
{ | ||
GameMain.gpuiManager.AlterModel(veinProto.MinerCircleModelIndex, veinData.minerCircleModelId1, veinData.minerId1, normalVector * (magnitude + 0.6f), false); | ||
} | ||
if (veinData.minerId2 > 0) | ||
{ | ||
GameMain.gpuiManager.AlterModel(veinProto.MinerCircleModelIndex, veinData.minerCircleModelId2, veinData.minerId2, normalVector * (magnitude + 0.8f), false); | ||
} | ||
if (veinData.minerId3 > 0) | ||
{ | ||
GameMain.gpuiManager.AlterModel(veinProto.MinerCircleModelIndex, veinData.minerCircleModelId3, veinData.minerId3, normalVector * (magnitude + 1f), false); | ||
} | ||
} | ||
} | ||
} |
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