ksys::eco::LevelSensor::calculatePoints (#90)

This commit is contained in:
alex-botw 2022-03-16 11:59:31 +03:00 committed by GitHub
parent 5fd19128f5
commit 59c85ae8c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 1 deletions

View File

@ -77885,7 +77885,7 @@ Address,Quality,Size,Name
0x0000007100e425b4,O,000288,_ZN4ksys3eco11LevelSensor4initEPN4sead4HeapE
0x0000007100e426d4,U,001552,Ecosystem::LevelSensor::scaleWeapon
0x0000007100e42ce4,U,001308,Ecosystem::LevelSensor::scaleActor
0x0000007100e43200,U,000576,Ecosystem::LevelSensor::calculatePoints
0x0000007100e43200,O,000576,_ZN4ksys3eco11LevelSensor15calculatePointsEv
0x0000007100e43440,O,000052,_ZN5uking6action22EventAppearRupeeActionC1ERKN4ksys3act2ai10ActionBase7InitArgE
0x0000007100e43474,U,000048,_ZN5uking6action22EventAppearRupeeAction8oneShot_Ev
0x0000007100e434a4,O,000108,_ZN5uking6action22EventAppearRupeeAction11loadParams_Ev

Can't render this file because it is too large.

View File

@ -1,4 +1,5 @@
#include "KingSystem/Ecosystem/ecoLevelSensor.h"
#include "KingSystem/GameData/gdtManager.h"
#include "KingSystem/Resource/resLoadRequest.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
@ -20,4 +21,53 @@ void LevelSensor::init(sead::Heap* heap) {
mRootIter = new (heap) al::ByamlIter(res->getRawData());
}
void LevelSensor::calculatePoints() {
if (mDefaultPoints >= 0) {
mPoints = mDefaultPoints;
} else {
al::ByamlIter flag;
if (!mRootIter->tryGetIterByKey(&flag, "flag")) {
return;
}
float point_sum = 0;
for (int index = 0; index < flag.getSize(); index++) {
al::ByamlIter iter_enemy;
if (!flag.tryGetIterByIndex(&iter_enemy, index)) {
return;
}
const char* name;
if (!iter_enemy.tryGetStringByKey(&name, "name")) {
return;
}
s32 kill_count = 0;
if (!gdt::Manager::instance()->getParam().get().getS32(&kill_count, name)) {
bool unique_kill = false;
if (gdt::Manager::instance()->getParam().get().getBool(&unique_kill, name)) {
if (unique_kill) {
kill_count = 1;
}
}
}
if (kill_count > 0) {
f32 point;
if (!iter_enemy.tryGetFloatByKey(&point, "point")) {
return;
}
point_sum += point * kill_count;
}
}
mPoints = point_sum;
}
al::ByamlIter setting_iter;
if (mRootIter->tryGetIterByKey(&setting_iter, "setting")) {
f32 Level2WeaponPower;
f32 Level2EnemyPower;
if (setting_iter.tryGetFloatByKey(&Level2WeaponPower, "Level2WeaponPower") &&
setting_iter.tryGetFloatByKey(&Level2EnemyPower, "Level2EnemyPower")) {
mWeaponPoints = mPoints * Level2WeaponPower;
mEnemyPoints = mPoints * Level2EnemyPower;
}
}
}
} // namespace ksys::eco