styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-cells.h
Go to the documentation of this file.
1#pragma once
2
3namespace StyyxUtil
4{
5struct CellUtil
6{
8 inline static const std::vector<std::string> is_a_dungeon{
9 "LocTypeDungeon", "LocSetCave", "LocSetCaveIce", "LocTypeDwarvenAutomatons",
10 "LocTypeAnimalDen", "LocTypeBanditCamp", "LocTypeDragonPriestLair", "LocTypeDraugrCrypt",
11 "LocTypeFalmerHive", "LocTypeForswornCamp", "LocTypeGiantCamp", "LocTypeHagravenNest",
12 "LocTypeVampireLair", "LocTypeWarlockLair", "LocTypeWerewolfLair"};
13
17 static bool IsDungeon(const RE::TESObjectCELL* a_cell)
18 {
19 if (!a_cell)
20 return false;
21 if (const auto loc = a_cell->GetLocation();
22 loc && loc->HasAnyKeywordByEditorID(is_a_dungeon) && a_cell->IsInteriorCell())
23 {
24 return true;
25 }
26 return false;
27 }
28
32 static bool IsJail(RE::TESObjectCELL* a_cell)
33 {
34 if (!a_cell)
35 return false;
36 const auto loc = a_cell->GetLocation();
37 if (const auto key = RE::TESForm::LookupByEditorID<RE::BGSKeyword>("LocTypeJail");
38 key && loc && loc->HasKeyword(key))
39 {
40 return true;
41 }
42 return false;
43 }
44
45 static bool IsPlayerHome(RE::BGSLocation* a_location)
46 {
47 if (!a_location)
48 return false;
49 static auto PlayerCellKeyword = RE::TESForm::LookupByEditorID<RE::BGSKeyword>("LocTypePlayerHouse");
50 if (PlayerCellKeyword && a_location->HasKeyword(PlayerCellKeyword))
51 {
52 return true;
53 }
54 return false;
55 }
56
60 static std::vector<RE::Actor*> GetAllActorsInCell(RE::TESObjectCELL* a_cell)
61 {
62 std::vector<RE::Actor*> result;
63 if (!a_cell)
64 return result;
65
66 for (const auto& ref : a_cell->references)
67 {
68 if (!ref)
69 continue;
70 auto actor = ref->As<RE::Actor>();
71 if (!actor)
72 continue;
73 result.push_back(actor);
74 }
75 return result;
76 }
77};
78} // namespace StyyxUtil
Definition st-actor.h:7
Definition st-cells.h:6
static const std::vector< std::string > is_a_dungeon
A vector of what I consider dungeon Keywords.
Definition st-cells.h:8
static bool IsPlayerHome(RE::BGSLocation *a_location)
Definition st-cells.h:45
static bool IsJail(RE::TESObjectCELL *a_cell)
Check if a cell is a Jail.
Definition st-cells.h:32
static bool IsDungeon(const RE::TESObjectCELL *a_cell)
Check if a cell is a dungeon.
Definition st-cells.h:17
static std::vector< RE::Actor * > GetAllActorsInCell(RE::TESObjectCELL *a_cell)
Get a vector of all actors in the specified cell.
Definition st-cells.h:60