Skip to content

Commit

Permalink
加入赶工的Genshin Pursuit场景
Browse files Browse the repository at this point in the history
  • Loading branch information
TsXor committed May 14, 2024
1 parent 0088d77 commit 5004212
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 2 deletions.
5 changes: 5 additions & 0 deletions res/genshin_pursuit_author.map2d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file: "genshin_pursuit_author.png"
name: "genshin_pursuit_author"
blocks:
- uv: [0, 128, 0, 128]
at: [0, 0]
Binary file added res/genshin_pursuit_author.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/genshin_pursuit_author.pxo
Binary file not shown.
2 changes: 1 addition & 1 deletion res/genshin_pursuit_entry.map2d.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file: "genshin_pursuit_entry.png"
name: "genshin_pursuit_entry"
blocks:
- uv: [0, 128, 0, 256]
- uv: [0, 128, 0, 160]
at: [0, 0]
Binary file modified res/genshin_pursuit_entry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/genshin_pursuit_entry.pxo
Binary file not shown.
5 changes: 5 additions & 0 deletions res/genshin_pursuit_main.map2d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file: "genshin_pursuit_main.png"
name: "genshin_pursuit_main"
blocks:
- uv: [0, 512, 0, 384]
at: [0, 0]
3 changes: 3 additions & 0 deletions src/main/activities/avg_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ avg_scene::string_map<acts::avg_scene::script_t> avg_scene::scene_scripts = {
{"dorm_stairs_middle", avg_scripts::dorm_stairs_middle},
{"dorm_stairs_bottom", avg_scripts::dorm_stairs_bottom},
{"black_jack_entry", avg_scripts::black_jack_entry},
{"genshin_pursuit_entry", avg_scripts::genshin_pursuit_entry},
{"genshin_pursuit_author", avg_scripts::genshin_pursuit_author},
{"genshin_pursuit_main", avg_scripts::genshin_pursuit_main},
};

avg_scene::entity_comp_t avg_scene::default_sprites_sorter() {
Expand Down
13 changes: 13 additions & 0 deletions src/main/activities/avg_scripts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ static inline constexpr struct {
eng::basics::vec2 black_jack_entry_default = {512, 352};
eng::basics::vec2 black_jack_entry_left = {36, 352};
eng::basics::vec2 black_jack_entry_right = {988, 352};

eng::basics::vec2 genshin_pursuit_entry_default = {256, 432};
eng::basics::vec2 genshin_pursuit_entry_top = {256, 228};
eng::basics::vec2 genshin_pursuit_entry_bottom = {256, 604};

eng::basics::vec2 genshin_pursuit_author_default = {384, 256};
eng::basics::vec2 genshin_pursuit_author_right = {476, 256};

eng::basics::vec2 genshin_pursuit_main_default = {1024, 1152};
eng::basics::vec2 genshin_pursuit_main_bottom = {1024, 1388};
} points;

#define AVG_SCRIPT_ARGS avg_scene& self, const std::optional<eng::basics::vec2>& spawn, const std::string& arg
Expand All @@ -71,6 +81,9 @@ void dorm_stairs(AVG_SCRIPT_ARGS);
void dorm_stairs_middle(AVG_SCRIPT_ARGS);
void dorm_stairs_bottom(AVG_SCRIPT_ARGS);
void black_jack_entry(AVG_SCRIPT_ARGS);
void genshin_pursuit_entry(AVG_SCRIPT_ARGS);
void genshin_pursuit_author(AVG_SCRIPT_ARGS);
void genshin_pursuit_main(AVG_SCRIPT_ARGS);

#undef AVG_SCRIPT_ARGS

Expand Down
3 changes: 3 additions & 0 deletions src/main/activities/avg_scripts/dorm_room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void acts::avg_scripts::dorm_room(avg_scene& self, const std::optional<eng::basi
{ {person.ptr(), back_door.ptr()}, [&](){ self.next<acts::avg_scene>("dorm_balcony", points.dorm_balcony_door, std::to_string(room_number)); } }
};

if (room_number == 605) {
colls[{person.ptr(), table_1.ptr()}] = [&](){ self.next<acts::avg_scene>("genshin_pursuit_entry", points.genshin_pursuit_entry_bottom); };
}
if (room_number == 311) {
colls[{person.ptr(), table_2.ptr()}] = [&](){ self.next<acts::avg_scene>("black_jack_entry", points.black_jack_entry_left); };
colls[{person.ptr(), table_3.ptr()}] = [&](){ self.next<acts::avg_scene>("dorm_room", std::nullopt, "508"); };
Expand Down
41 changes: 41 additions & 0 deletions src/main/activities/avg_scripts/genshin_pursuit_author.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "../avg_scripts.hpp"
#include "./utils.hpp"
#include "static_sprites.hpp"
#include "static_maps.hpp"

using namespace acts::avg_scripts;
using namespace naive_engine;
using namespace silly_framework;

void acts::avg_scripts::genshin_pursuit_author(avg_scene& self, const std::optional<eng::basics::vec2>& spawn, const std::string& arg) {
coutils::sync::unleash_lambda([&]() -> coutils::async_fn<void> {
// 出生点
basics::vec2 spawn_pos = spawn.value_or(points.genshin_pursuit_author_default);
simulator::entity_node_t person(basics::aabb(-16, 16, -12, 12), spawn_pos);
self.simu.emplace(512, 512);
utils::add_main_char(self, person);

self.bound_map.emplace(&maps::genshin_pursuit_author(), 4.0);
self.bound_sprites[person.ptr()] = {&sprites::container_small(), 4.0, {0, -36}};

// 地图边界固定阻挡物
simulator::entity_node_t obstacles[] = {
{basics::aabb{0, 512, 0, 192}},
{basics::aabb{0, 512, 320, 512}},
{basics::aabb{0, 288, 192, 320}},
};
utils::add_map_obstacles(self, obstacles);

simulator::entity_node_t
leave = {basics::aabb{496, 512, 192, 320}};
utils::add_trigger_boxes(self, leave);
utils::coll_event_table colls {
{ {person.ptr(), leave.ptr()}, [&](){ self.next<acts::avg_scene>("genshin_pursuit_entry", points.genshin_pursuit_entry_bottom); } },
};

while (true) {
auto [_, evt_data] = co_await self.cohost.wait_event({simu_coro_host::EVT_COLLISION});
utils::check_coll_events(self, colls, evt_data);
}
});
}
44 changes: 44 additions & 0 deletions src/main/activities/avg_scripts/genshin_pursuit_entry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "../avg_scripts.hpp"
#include "./utils.hpp"
#include "static_sprites.hpp"
#include "static_maps.hpp"

using namespace acts::avg_scripts;
using namespace naive_engine;
using namespace silly_framework;

void acts::avg_scripts::genshin_pursuit_entry(avg_scene& self, const std::optional<eng::basics::vec2>& spawn, const std::string& arg) {
coutils::sync::unleash_lambda([&]() -> coutils::async_fn<void> {
// 出生点
basics::vec2 spawn_pos = spawn.value_or(points.genshin_pursuit_entry_default);
simulator::entity_node_t person(basics::aabb(-16, 16, -12, 12), spawn_pos);
self.simu.emplace(512, 640);
utils::add_main_char(self, person);

self.bound_map.emplace(&maps::genshin_pursuit_entry(), 4.0);
self.bound_sprites[person.ptr()] = {&sprites::container_small(), 4.0, {0, -36}};

// 地图边界固定阻挡物
simulator::entity_node_t obstacles[] = {
{basics::aabb{0, 192, 0, 576}},
{basics::aabb{320, 512, 0, 640}},
};
utils::add_map_obstacles(self, obstacles);

simulator::entity_node_t
hidden = {basics::aabb{0, 16, 576, 640}},
launch = {basics::aabb{192, 320, 0, 208}},
leave = {basics::aabb{192, 320, 624, 640}};
utils::add_trigger_boxes(self, hidden, launch, leave);
utils::coll_event_table colls {
{ {person.ptr(), hidden.ptr()}, [&](){ self.next<acts::avg_scene>("genshin_pursuit_author", points.genshin_pursuit_author_right); } },
{ {person.ptr(), launch.ptr()}, [&](){ self.next<acts::avg_scene>("genshin_pursuit_main", points.genshin_pursuit_main_bottom); } },
{ {person.ptr(), leave.ptr()}, [&](){ self.next<acts::avg_scene>("dorm_room", std::nullopt, "605"); } },
};

while (true) {
auto [_, evt_data] = co_await self.cohost.wait_event({simu_coro_host::EVT_COLLISION});
utils::check_coll_events(self, colls, evt_data);
}
});
}
37 changes: 37 additions & 0 deletions src/main/activities/avg_scripts/genshin_pursuit_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../avg_scripts.hpp"
#include "./utils.hpp"
#include "static_sprites.hpp"
#include "static_maps.hpp"

using namespace acts::avg_scripts;
using namespace naive_engine;
using namespace silly_framework;

void acts::avg_scripts::genshin_pursuit_main(avg_scene& self, const std::optional<eng::basics::vec2>& spawn, const std::string& arg) {
coutils::sync::unleash_lambda([&]() -> coutils::async_fn<void> {
// 出生点
basics::vec2 spawn_pos = spawn.value_or(points.genshin_pursuit_entry_default);
simulator::entity_node_t person(basics::aabb(-16, 16, -12, 12), spawn_pos);
self.simu.emplace(2048, 1536);
utils::add_main_char(self, person);

self.bound_map.emplace(&maps::genshin_pursuit_main(), 4.0);
self.bound_sprites[person.ptr()] = {&sprites::container_small(), 4.0, {0, -36}};

// 地图边界固定阻挡物
//simulator::entity_node_t obstacles[] = {};
//utils::add_map_obstacles(self, obstacles);

simulator::entity_node_t
leave = {basics::aabb{896, 1152, 1408, 1536}};
utils::add_trigger_boxes(self, leave);
utils::coll_event_table colls {
{ {person.ptr(), leave.ptr()}, [&](){ self.next<acts::avg_scene>("genshin_pursuit_entry", points.genshin_pursuit_entry_top); } },
};

while (true) {
auto [_, evt_data] = co_await self.cohost.wait_event({simu_coro_host::EVT_COLLISION});
utils::check_coll_events(self, colls, evt_data);
}
});
}
18 changes: 17 additions & 1 deletion src/main/static_maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,26 @@ const map2d& maps::dorm_stairs_top() {
);
return map;
}
const map2d& maps::genshin_pursuit_author() {
static const map2d map("genshin_pursuit_author.png",
map_blocks{
{{0, 128, 0, 128}, {0, 0}}
}
);
return map;
}
const map2d& maps::genshin_pursuit_entry() {
static const map2d map("genshin_pursuit_entry.png",
map_blocks{
{{0, 128, 0, 256}, {0, 0}}
{{0, 128, 0, 160}, {0, 0}}
}
);
return map;
}
const map2d& maps::genshin_pursuit_main() {
static const map2d map("genshin_pursuit_main.png",
map_blocks{
{{0, 512, 0, 384}, {0, 0}}
}
);
return map;
Expand Down
2 changes: 2 additions & 0 deletions src/main/static_maps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ const silly_framework::map2d& dorm_stairs();
const silly_framework::map2d& dorm_stairs_bottom();
const silly_framework::map2d& dorm_stairs_middle();
const silly_framework::map2d& dorm_stairs_top();
const silly_framework::map2d& genshin_pursuit_author();
const silly_framework::map2d& genshin_pursuit_entry();
const silly_framework::map2d& genshin_pursuit_main();
} // namespace maps

0 comments on commit 5004212

Please sign in to comment.