-
-
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.
- metadata cost is set to 0 as in sandbox mode
- Loading branch information
Showing
6 changed files
with
198 additions
and
10 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
NebulaModel/Packets/Combat/CombatAggressivenessUpdatePacket.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,15 @@ | ||
namespace NebulaModel.Packets.Combat; | ||
|
||
public class CombatAggressivenessUpdatePacket | ||
{ | ||
public CombatAggressivenessUpdatePacket() { } | ||
|
||
public CombatAggressivenessUpdatePacket(ushort playerId, float aggressiveness) | ||
{ | ||
PlayerId = playerId; | ||
Aggressiveness = aggressiveness; | ||
} | ||
|
||
public ushort PlayerId { get; set; } | ||
public float Aggressiveness { 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,15 @@ | ||
namespace NebulaModel.Packets.Combat; | ||
|
||
public class CombatTruceUpdatePacket | ||
{ | ||
public CombatTruceUpdatePacket() { } | ||
|
||
public CombatTruceUpdatePacket(ushort playerId, long truceEndTime) | ||
{ | ||
PlayerId = playerId; | ||
TruceEndTime = truceEndTime; | ||
} | ||
|
||
public ushort PlayerId { get; set; } | ||
public long TruceEndTime { get; set; } | ||
} |
52 changes: 52 additions & 0 deletions
52
NebulaNetwork/PacketProcessors/Combat/CombatAggressivenessProcessor.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,52 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.DataStructures.Chat; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Combat; | ||
using NebulaWorld; | ||
using NebulaWorld.MonoBehaviours.Local.Chat; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Combat; | ||
|
||
[RegisterPacketProcessor] | ||
public class CombatAggressivenessProcessor : PacketProcessor<CombatAggressivenessUpdatePacket> | ||
{ | ||
protected override void ProcessPacket(CombatAggressivenessUpdatePacket packet, NebulaConnection conn) | ||
{ | ||
if (IsHost) | ||
{ | ||
Multiplayer.Session.Network.SendPacketExclude(packet, conn); | ||
} | ||
|
||
var history = GameMain.history; | ||
var oldAggressiveLevel = history.combatSettings.aggressiveLevel; | ||
history.combatSettings.aggressiveness = packet.Aggressiveness; | ||
|
||
var currentPropertyMultiplier = history.currentPropertyMultiplier; | ||
if (currentPropertyMultiplier < history.minimalPropertyMultiplier) | ||
{ | ||
history.minimalPropertyMultiplier = currentPropertyMultiplier; | ||
} | ||
var difficulty = history.combatSettings.difficulty; | ||
if (difficulty < history.minimalDifficulty) | ||
{ | ||
history.minimalDifficulty = difficulty; | ||
} | ||
GameMain.data.spaceSector.OnDFAggressivenessChanged(oldAggressiveLevel, history.combatSettings.aggressiveLevel); | ||
|
||
var userName = ""; | ||
using (Multiplayer.Session.World.GetRemotePlayersModels(out var remotePlayersModels)) | ||
{ | ||
if (remotePlayersModels.TryGetValue(packet.PlayerId, out var player)) | ||
{ | ||
userName = player.Username; | ||
} | ||
} | ||
var message = string.Format("{0} set DF Aggressiveness {1} => {2}".Translate(), userName, oldAggressiveLevel, history.combatSettings.aggressiveLevel); | ||
ChatManager.Instance.SendChatMessage(message, ChatMessageType.BattleMessage); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
NebulaNetwork/PacketProcessors/Combat/CombatTruceUpdateProcessor.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,43 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.DataStructures.Chat; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Combat; | ||
using NebulaWorld; | ||
using NebulaWorld.MonoBehaviours.Local.Chat; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Combat; | ||
|
||
[RegisterPacketProcessor] | ||
public class CombatTruceUpdateProcessor : PacketProcessor<CombatTruceUpdatePacket> | ||
{ | ||
protected override void ProcessPacket(CombatTruceUpdatePacket packet, NebulaConnection conn) | ||
{ | ||
if (IsHost) | ||
{ | ||
Multiplayer.Session.Network.SendPacketExclude(packet, conn); | ||
} | ||
|
||
var truceTime = packet.TruceEndTime - (GameMain.gameTick + GameMain.history.dfTruceTimer); | ||
GameMain.history.AddTruceTime(truceTime); | ||
|
||
var userName = ""; | ||
using (Multiplayer.Session.World.GetRemotePlayersModels(out var remotePlayersModels)) | ||
{ | ||
if (remotePlayersModels.TryGetValue(packet.PlayerId, out var player)) | ||
{ | ||
userName = player.Username; | ||
} | ||
} | ||
var message = userName + " set "; | ||
var second = (int)(GameMain.history.dfTruceTimer / 60L); | ||
var minute = second / 60; | ||
var hour = minute / 60; | ||
message += string.Format("停战时间".Translate(), hour, minute % 60, second % 60); | ||
ChatManager.Instance.SendChatMessage(message, ChatMessageType.BattleMessage); | ||
} | ||
} |
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