SuperMarioOdysseyOnline/include/helpers.hpp

162 lines
4.8 KiB
C++
Raw Permalink Normal View History

2022-06-16 21:33:18 +00:00
#pragma once
#include "types.h"
#include "sead/math/seadVector.h"
#include "sead/math/seadQuat.hpp"
#include "al/util.hpp"
#include "puppets/PuppetInfo.h"
bool isPartOf(const char* w1, const char* w2);
2024-06-14 09:21:27 +00:00
int indexOf(char* w1, char c1);
2022-06-16 21:33:18 +00:00
void logVector(const char* vectorName, sead::Vector3f vector);
2024-06-14 09:21:27 +00:00
void logQuat(const char* quatName, sead::Quatf quat);
2022-06-16 21:33:18 +00:00
2024-06-14 09:21:27 +00:00
sead::Vector3f QuatToEuler(sead::Quatf* quat);
2022-06-16 21:33:18 +00:00
2024-06-14 09:21:27 +00:00
float vecMagnitude(sead::Vector3f const& input);
refac: abstracting game mode - change: general game mode management more abstract and less H&S oriented - change: split 8bit updateType into 4bit game mode and 4bit update type. - change: don't process packets from other game modes (legacy mode for backwards compatibility) - change: cache game mode of other players in puppet, resend GameModeInf on detected game mode change - change: send gamemode NONE when H&S is selected but not active - change: improved distance calculations in squared distance space - change: change from hider to seeker when dead even if there are no other players - fix: add hours to the minutes for the H&S GameModeInf packet - fix: set milliseconds and hours when receiving time from server - fix: keep the new time from the server for longer than a single frame - fix: reset H&S icon after receiving a new state from the server - refac: move code to generate PlayerList into own abstract LayoutPlayerList class. - refac: to_string() method for GameTime to simplify code in the Game Mode Icon class. - refac: rename TagInf packet to GameModeInf packet - refac: remove param from `SocketClient::tryGetPacket()` (unused) - refac: move all H&S specific files into the same directory (out of layouts) - refac: move GameModeTimer.cpp from source/server/hns/ to source/server/gamemode/ - refac: clean up some unused, duplicate or complicated imports - [mod menu] change: use the game mode name in the options & menu title - [mod menu] change: select the next game mode in the game mode select menu - [mod menu] change: possibility to always change the gravity setting in the H&S config menu - [mod menu] add: toggle options to control mario/cappy collision/bounciness (cherry picked from commit a9b2c87aa024cee6ba85ad2856db60de7ec67124) (cherry picked from commit 918f61fbfd619d781d88dc74878d392c48cfa480) (cherry picked from commit 96aff7dd7167d8244acef7884fa3503d4c3f868a) (cherry picked from commit 0fb6413ec91bbf679e9f8cea1aa512159101fa46) (cherry picked from commit ab78a812fd18781655ccf38e803f619ea427d1ac) Co-authored-by: Robin C. Ladiges <rcl.git@blackpinguin.de>
2022-06-22 03:01:18 +00:00
float vecDistance(sead::Vector3f const& a, sead::Vector3f const& b);
float vecDistanceSq(sead::Vector3f const& a, sead::Vector3f const& b);
2022-06-16 21:33:18 +00:00
2024-06-14 09:21:27 +00:00
float quatAngle(sead::Quatf const& q1, sead::Quatf& q2);
2022-06-16 21:33:18 +00:00
2024-06-14 09:21:27 +00:00
bool isInCostumeList(const char* costumeName);
2022-06-16 21:33:18 +00:00
2024-06-14 09:21:27 +00:00
const char* tryGetPuppetCapName(PuppetInfo* info);
2022-06-16 21:33:18 +00:00
const char* tryGetPuppetBodyName(PuppetInfo* info);
const char* tryConvertName(const char* className);
void killMainPlayer(al::LiveActor* actor);
void killMainPlayer(PlayerActorHakoniwa* mainPlayer);
__attribute__((used)) static const char* costumeNames[] = {
"Mario",
"Mario64",
"Mario64Metal",
"MarioAloha",
"MarioArmor",
"MarioBone",
"MarioClown",
"MarioColorClassic",
"MarioColorGold",
"MarioColorLuigi",
"MarioColorWaluigi",
"MarioColorWario",
"MarioCook",
"MarioDiddyKong",
"MarioDoctor",
"MarioExplorer",
"MarioFootball",
"MarioGolf",
"MarioGunman",
"MarioHakama",
"MarioHappi",
"MarioKing",
"MarioKoopa",
"MarioMaker",
"MarioMechanic",
"MarioNew3DS",
"MarioPainter",
"MarioPeach",
"MarioPilot",
"MarioPirate",
"MarioPoncho",
"MarioPrimitiveMan",
"MarioSailor",
"MarioScientist",
"MarioShopman",
"MarioSnowSuit",
"MarioSpaceSuit",
"MarioSuit",
"MarioSwimwear",
"MarioTailCoat",
"MarioTuxedo",
"MarioUnderwear"
};
// full costume list from 1.3
// attribute otherwise the build log is spammed with unused warnings
// __attribute__((used)) static const char* costumeNames[] = {
// "Mario", "Mario3D", "Mario64", "Mario64Metal", "MarioAloha", "MarioArmor",
// // "MarioArmorWestern", // DLC
// "MarioBandman",
// // "MarioBatter", // DLC
2024-06-14 09:21:27 +00:00
// "MarioBone", "MarioCaptain", "MarioClown", "MarioColorClassic", "MarioColorGold",
2022-06-16 21:33:18 +00:00
// "MarioColorLuigi", "MarioColorWaluigi", "MarioColorWario",
// // "MarioConductor", // DLC
// "MarioCook", "MarioDiddyKong", "MarioDoctor", "MarioDot", "MarioDot3d", "MarioExplorer",
// "MarioFootball", "MarioGolf", "MarioGunman", "MarioHakama", "MarioHappi",
// // "MarioHariet", // DLC
// // "MarioHigh",
// "MarioKing", "MarioKoopa", "MarioMaker", "MarioMechanic", "MarioNew3DS", "MarioPainter",
// "MarioPeach", "MarioPilot", "MarioPirate", "MarioPoncho", "MarioPrimitiveMan", "MarioRacer",
// //"MarioRango", // DLC
// //"MarioRsv", // DLC
// "MarioSailor", "MarioSanta",
// // "MarioSatellite", // DLC
// "MarioScientist", "MarioShopman", "MarioSnowSuit", "MarioSpaceSuit",
// // "MarioSpewart", // DLC
// "MarioSuit",
// // "MarioSunshine", // DLC
// "MarioSwimwear",
// // "MarioTopper", // DLC
// "MarioTuxedo",
// // "MarioZombie" // DLC
// };
struct HackActorName {
2024-06-14 09:21:27 +00:00
const char* className;
const char* hackName;
2022-06-16 21:33:18 +00:00
};
// attribute otherwise the build log is spammed with unused warnings
__attribute__((used)) static HackActorName classHackNames[] = {
{"SenobiGeneratePoint", "Senobi"},
{"KuriboPossessed", "Kuribo"},
{"KillerLauncher", "Killer"},
{"KillerLauncherMagnum", "KillerMagnum"},
{"FireBrosPossessed", "FireBros"},
{"HammerBrosPossessed", "HammerBros"},
{"ElectricWire", "ElectricWireMover"},
{"TRexSleep", "TRex"},
{"TRexPatrol", "TRex"},
{"WanwanBig", "Wanwan"}, // FIXME: this will make chain chomp captures always be the small
// variant for syncing
{"Koopa","KoopaHack"}
};
struct Transform
{
2024-06-14 09:21:27 +00:00
sead::Vector3f* position;
sead::Quatf* rotation;
2022-06-16 21:33:18 +00:00
};
// From Boss Room Unity Example
class VisualUtils
{
public:
2024-06-14 09:21:27 +00:00
/*
2022-06-16 21:33:18 +00:00
* @brief Smoothly interpolates towards the parent transform.
* @param moveTransform The transform to interpolate
* @param targetTransform The transform to interpolate towards.
* @param timeDelta Time in seconds that has elapsed, for purposes of interpolation.
2024-06-14 09:21:27 +00:00
* @param closingSpeed The closing speed in m/s. This is updated by SmoothMove every time it is called, and will drop to 0 whenever the moveTransform has "caught up".
2022-06-16 21:33:18 +00:00
* @param maxAngularSpeed The max angular speed to to rotate at, in degrees/s.
*/
2024-06-14 09:21:27 +00:00
static float SmoothMove(
Transform moveTransform,
Transform targetTransform,
float timeDelta,
float closingSpeed,
float maxAngularSpeed
);
2022-06-16 21:33:18 +00:00
constexpr static const float k_MinSmoothSpeed = 0.1f;
constexpr static const float k_TargetCatchupTime = 0.2f;
2024-06-14 09:21:27 +00:00
};