mirror of
https://git.xeondev.com/LR/S.git
synced 2026-03-22 07:32:21 +01:00
refactor(scene): decouple player level/position from notifying systems
This commit is contained in:
@@ -8,32 +8,37 @@ const Player = logic.Player;
|
||||
const ArrayList = std.ArrayList;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const default_level = "map02_lv001";
|
||||
|
||||
pub fn enterSceneOnLogin(
|
||||
rx: logic.event.Receiver(.login),
|
||||
tx: logic.event.Sender(.change_scene_begin),
|
||||
) !void {
|
||||
_ = rx;
|
||||
try tx.send(.{});
|
||||
}
|
||||
|
||||
pub fn beginChangingScene(
|
||||
rx: logic.event.Receiver(.change_scene_begin),
|
||||
session: *Session,
|
||||
assets: *const Assets,
|
||||
base_comp: Player.Component(.base),
|
||||
location: *const logic.World.Location,
|
||||
) !void {
|
||||
_ = rx;
|
||||
|
||||
const level_config = assets.level_config_table.getPtr(default_level).?;
|
||||
const position: pb.VECTOR = .{
|
||||
.X = level_config.playerInitPos.x,
|
||||
.Y = level_config.playerInitPos.y,
|
||||
.Z = level_config.playerInitPos.z,
|
||||
.X = location.position[0],
|
||||
.Y = location.position[1],
|
||||
.Z = location.position[2],
|
||||
};
|
||||
|
||||
try session.send(pb.SC_CHANGE_SCENE_BEGIN_NOTIFY{
|
||||
.scene_num_id = level_config.idNum,
|
||||
.scene_num_id = location.level,
|
||||
.position = position,
|
||||
.pass_through_data = .init,
|
||||
});
|
||||
|
||||
try session.send(pb.SC_ENTER_SCENE_NOTIFY{
|
||||
.role_id = base_comp.data.role_id,
|
||||
.scene_num_id = level_config.idNum,
|
||||
.scene_num_id = location.level,
|
||||
.position = position,
|
||||
.pass_through_data = .init,
|
||||
});
|
||||
@@ -58,6 +63,7 @@ pub fn syncSelfScene(
|
||||
session: *Session,
|
||||
arena: logic.Resource.Allocator(.arena),
|
||||
char_bag: logic.Player.Component(.char_bag),
|
||||
location: *const logic.World.Location,
|
||||
assets: *const Assets,
|
||||
) !void {
|
||||
const reason: pb.SELF_INFO_REASON_TYPE = switch (rx.payload.reason) {
|
||||
@@ -65,18 +71,17 @@ pub fn syncSelfScene(
|
||||
.team_modified => .SLR_CHANGE_TEAM,
|
||||
};
|
||||
|
||||
const level_config = assets.level_config_table.getPtr(default_level).?;
|
||||
const position: pb.VECTOR = .{
|
||||
.X = level_config.playerInitPos.x,
|
||||
.Y = level_config.playerInitPos.y,
|
||||
.Z = level_config.playerInitPos.z,
|
||||
.X = location.position[0],
|
||||
.Y = location.position[1],
|
||||
.Z = location.position[2],
|
||||
};
|
||||
|
||||
const team_index = char_bag.data.meta.curr_team_index;
|
||||
const leader_index = char_bag.data.teams.items(.leader_index)[team_index];
|
||||
|
||||
var self_scene_info: pb.SC_SELF_SCENE_INFO = .{
|
||||
.scene_num_id = level_config.idNum,
|
||||
.scene_num_id = location.level,
|
||||
.self_info_reason = @intFromEnum(reason),
|
||||
.teamInfo = .{
|
||||
.team_type = .CHAR_BAG_TEAM_TYPE_MAIN,
|
||||
@@ -106,7 +111,7 @@ pub fn syncSelfScene(
|
||||
.templateid = char_template_id,
|
||||
.position = position,
|
||||
.rotation = .{},
|
||||
.scene_num_id = level_config.idNum,
|
||||
.scene_num_id = location.level,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user