forked from HarbourMasters/Shipwright
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from dcvz/chore/game-interactor
Chore/game interactor
- Loading branch information
Showing
9 changed files
with
492 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// GameInteractionEffect.cpp | ||
// soh | ||
// | ||
// Created by David Chavez on 15.12.22. | ||
// | ||
|
||
#include "GameInteractionEffect.h" | ||
#include "GameInteractor.h" | ||
|
||
extern "C" { | ||
#include <z64.h> | ||
#include "variables.h" | ||
#include "functions.h" | ||
#include "macros.h" | ||
extern PlayState* gPlayState; | ||
} | ||
|
||
// Effect State | ||
|
||
uint32_t GameInteractor_NoUI; | ||
|
||
// AddHeartContainer | ||
|
||
namespace GameInteractionEffect { | ||
GameInteractionEffectQueryResult AddHeartContainer::CanBeApplied() { | ||
return gSaveContext.healthCapacity >= 0x140 | ||
? GameInteractionEffectQueryResult::NotPossibe | ||
: GameInteractionEffectQueryResult::Possible; | ||
} | ||
|
||
void AddHeartContainer::Apply() { | ||
Health_GiveHearts(1); | ||
} | ||
|
||
// RemoveHeartContainer | ||
|
||
GameInteractionEffectQueryResult RemoveHeartContainer::CanBeApplied() { | ||
return ((gSaveContext.healthCapacity - 0x10) <= 0) | ||
? GameInteractionEffectQueryResult::NotPossibe | ||
: GameInteractionEffectQueryResult::Possible; | ||
} | ||
|
||
void RemoveHeartContainer::Apply() { | ||
Health_RemoveHearts(1); | ||
} | ||
|
||
// GiveRupees | ||
|
||
GameInteractionEffectQueryResult GiveRupees::CanBeApplied() { | ||
return GameInteractionEffectQueryResult::Possible; | ||
} | ||
|
||
void GiveRupees::Apply() { | ||
Rupees_ChangeBy(amount); | ||
} | ||
|
||
|
||
// NoUIEffect | ||
|
||
GameInteractionEffectQueryResult NoUI::CanBeApplied() { | ||
return GameInteractionEffectQueryResult::Possible; | ||
} | ||
|
||
void NoUI::Apply() { | ||
GameInteractor_NoUI = 1; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
soh/soh/Enhancements/game-interactor/GameInteractionEffect.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// GameInteractionEffect.h | ||
// soh | ||
// | ||
// Created by David Chavez on 15.12.22. | ||
// | ||
|
||
#ifndef GameInteractionEffect_h | ||
#define GameInteractionEffect_h | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
extern uint32_t GameInteractor_NoUI; | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
enum GameInteractionEffectQueryResult { | ||
Possible = 0x00, | ||
TemporarilyNotPossible = 0x01, | ||
NotPossibe = 0xFF | ||
}; | ||
|
||
class GameInteractionEffectBase { | ||
public: | ||
virtual GameInteractionEffectQueryResult CanBeApplied() = 0; | ||
virtual void Apply() = 0; | ||
}; | ||
|
||
namespace GameInteractionEffect { | ||
class AddHeartContainer: public GameInteractionEffectBase { | ||
GameInteractionEffectQueryResult CanBeApplied() override; | ||
void Apply() override; | ||
}; | ||
|
||
class RemoveHeartContainer: public GameInteractionEffectBase { | ||
GameInteractionEffectQueryResult CanBeApplied() override; | ||
void Apply() override; | ||
}; | ||
|
||
class AddOrRemoveHeartContainer: public GameInteractionEffectBase { | ||
int32_t amount; | ||
|
||
GameInteractionEffectQueryResult CanBeApplied() override; | ||
void Apply() override; | ||
}; | ||
|
||
class GiveRupees: public GameInteractionEffectBase { | ||
public: | ||
uint32_t amount; | ||
|
||
GameInteractionEffectQueryResult CanBeApplied() override; | ||
void Apply() override; | ||
}; | ||
|
||
class NoUI: public GameInteractionEffectBase { | ||
GameInteractionEffectQueryResult CanBeApplied() override; | ||
void Apply() override; | ||
}; | ||
} | ||
|
||
#endif /* __cplusplus */ | ||
#endif /* GameInteractionEffect_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// GameInteractor.cpp | ||
// soh | ||
// | ||
// Created by David Chavez on 07.12.22. | ||
// | ||
|
||
#include "GameInteractor.h" | ||
|
||
GameInteractionEffectQueryResult GameInteractor::CanApplyEffect(GameInteractionEffectBase effect) { | ||
return effect.CanBeApplied(); | ||
} | ||
|
||
void GameInteractor::ApplyEffect(GameInteractionEffectBase effect) { | ||
return effect.Apply(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// GameInteractor.h | ||
// soh | ||
// | ||
// Created by David Chavez on 07.12.22. | ||
// | ||
|
||
#ifndef GameInteractor_h | ||
#define GameInteractor_h | ||
|
||
#include "GameInteractionEffect.h" | ||
|
||
#ifdef __cplusplus | ||
class GameInteractor { | ||
public: | ||
static GameInteractor* Instance; | ||
|
||
static GameInteractionEffectQueryResult CanApplyEffect(GameInteractionEffectBase effect); | ||
static void ApplyEffect(GameInteractionEffectBase effect); | ||
static void RemoveEffect(); | ||
|
||
static bool CanSpawnEnemy(); | ||
static void SpawnEnemy(); | ||
}; | ||
|
||
#endif | ||
#endif /* GameInteractor_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters