145 lines
5.8 KiB
C#
145 lines
5.8 KiB
C#
using GameServer.Contents.GameMode.Manage.PlayManage;
|
|
using GameServer.Contents.GameMode.Mode_Battle.Manage;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCore;
|
|
|
|
namespace GameServer;
|
|
|
|
|
|
[ChatCommandAttribute("battleinstanceinit", typeof(CheatBattleInstanceInit), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
|
public class CheatBattleInstanceInit : ChatCommandBase
|
|
{
|
|
public override async Task invoke(Player player, string token, string[] args)
|
|
{
|
|
Log.getLogger().info($"battleinstanceinit");
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
|
|
var room_id = player.getCurrentInstanceRoomId();
|
|
if (room_id.Equals(string.Empty))
|
|
{
|
|
Log.getLogger().error($"cheat:battleinstanceinit.... this cheat only use in instance");
|
|
return;
|
|
}
|
|
|
|
if (false == GameModeManager.It.tryGetGameMode(room_id, out var gameMode))
|
|
{
|
|
Log.getLogger().error($"cheat:battleinstanceinit.... battle_instance_room is null room_id : {room_id}");
|
|
return;
|
|
}
|
|
|
|
var game_mode_base = gameMode as GameModeBase;
|
|
|
|
// var battle_instance_room = BattleInstanceManager.It.getBattleInstanceRoom(room_id);
|
|
if (game_mode_base is null)
|
|
{
|
|
Log.getLogger().error($"cheat:battleinstanceinit.... game_mode_base is null room_id : {room_id}");
|
|
return;
|
|
}
|
|
|
|
using (var releaser = await game_mode_base.getAsyncLock())
|
|
{
|
|
var attribute = game_mode_base.getEntityAttribute<BattleInstanceSnapshotAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attribute, () => $"attribute is null !!!");
|
|
|
|
if (false == attribute.m_combat_pod_mode.m_round_state_type.Equals(BattleRoundStateType.RoundEndAll) && false == attribute.m_combat_pod_mode.m_round_state_type.Equals(BattleRoundStateType.Destroyed))
|
|
{
|
|
Log.getLogger().error($"cheat:battleinstanceinit.... this cheat only RoundEndAll room_id : {room_id}");
|
|
return;
|
|
}
|
|
|
|
var now = DateTimeHelper.Current;
|
|
|
|
var ffa = gameMode as GameModeTPSFreeForAll<GameModeTPSFreeForAllData>;
|
|
if (ffa is null)
|
|
{
|
|
Log.getLogger().error($"cheat:battleinstanceinit.... ffa is null room_id : {room_id}");
|
|
return;
|
|
}
|
|
|
|
ffa.setEventStartTime(now);
|
|
|
|
attribute.m_combat_pod_mode.m_round_state_type = BattleRoundStateType.Rounding;
|
|
attribute.m_combat_pod_mode.m_current_state_start_time = now;
|
|
attribute.m_combat_pod_mode.m_current_round = 1;
|
|
attribute.m_combat_pod_mode.m_charged_step = 0;
|
|
attribute.m_combat_pod_mode.m_rewarded_step = 0;
|
|
|
|
attribute.m_combat_pod_mode.m_pod_combat.setActive(now);
|
|
|
|
|
|
(Result result, var anchor_guid) = BattleRoomHelper.getRandomCombatPodAnchorGuid(attribute, ffa);
|
|
if (result.isFail())
|
|
{
|
|
Log.getLogger().error("get Random pod combat anchor guid faile !!! ");
|
|
return;
|
|
}
|
|
attribute.m_combat_pod_mode.m_pod_combat.m_source_storage_anchor_guid = anchor_guid;
|
|
|
|
BattleRoomNotifyHelper.broadcast_GS2C_NTF_BATTLE_INSTANCE_STATE(ffa);
|
|
|
|
var update_action = game_mode_base.getEntityAction<BattleInstanceUpdateAction>();
|
|
NullReferenceCheckHelper.throwIfNull(update_action, () => $"attribute is null !!!");
|
|
update_action.battleObjectStateInitAndNotify(ffa, attribute);
|
|
|
|
BattleRoomNotifyHelper.broadcast_GS2C_NTF_POD_COMBAT_STATE(ffa);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[ChatCommandAttribute("gamemodeoccupyhost", typeof(BattleHostOccupy), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
|
public class BattleHostOccupy : ChatCommandBase
|
|
{
|
|
public override async Task invoke(Player player, string token, string[] args)
|
|
{
|
|
//Log.getLogger().info($"battleinstanceinit");
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
|
|
var room_id = player.getCurrentInstanceRoomId();
|
|
if (room_id.Equals(string.Empty))
|
|
{
|
|
Log.getLogger().error($"cheat:gamemodeoccupyhost.... this cheat only use in instance");
|
|
return;
|
|
}
|
|
|
|
|
|
//kihoon todo : 임시 분기 처리
|
|
//나중에 게임모드로 분리되면 그때 재작업
|
|
if (room_id.Contains("battle"))
|
|
{
|
|
//var battle_instance_room = BattleInstanceManager.It.getBattleInstanceRoom(room_id);
|
|
if (false == GameModeManager.It.tryGetGameMode(room_id, out var gameMode))
|
|
{
|
|
Log.getLogger().error($"cheat:gamemodeoccupyhost.... battle_instance_room is null room_id : {room_id}");
|
|
return;
|
|
}
|
|
|
|
var game_mode_base = gameMode as GameModeBase;
|
|
NullReferenceCheckHelper.throwIfNull(game_mode_base, () => $"game_mode_base is null !!!");
|
|
|
|
using (var releaser = await game_mode_base.getAsyncLock())
|
|
{
|
|
game_mode_base.m_host_migrator.modifyHost(player.getUserGuid());
|
|
}
|
|
BattleRoomNotifyHelper.broadcast_GS2C_NTF_P2P_HOST_UPDATE(game_mode_base.getInstanceRoom(), player.getUserGuid());
|
|
}
|
|
else if (room_id.Contains("1017101"))
|
|
{
|
|
var instance_room = InstanceRoomManager.Instance.getInstanceRoomByRoomId(room_id);
|
|
if (instance_room is null)
|
|
{
|
|
Log.getLogger().error($"cheat:gamemodeoccupyhost.... instance_room is null room_id : {room_id}");
|
|
return;
|
|
}
|
|
BattleRoomNotifyHelper.broadcast_GS2C_NTF_P2P_HOST_UPDATE(instance_room, player.getUserGuid());
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |