Overhaul memory model to new Arbutils memory.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@ namespace CreatureLib::Battling {
|
||||
class BattleSide : public ScriptSource {
|
||||
uint8_t _index;
|
||||
uint8_t _creaturesPerSide;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<Creature>> _creatures;
|
||||
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _creatures;
|
||||
ArbUt::List<std::shared_ptr<BaseTurnChoice>> _choices;
|
||||
ArbUt::List<bool> _fillableSlots;
|
||||
uint8_t _choicesSet = 0;
|
||||
@@ -40,20 +40,22 @@ namespace CreatureLib::Battling {
|
||||
void SetChoice(BaseTurnChoice* choice);
|
||||
void ResetChoices() noexcept;
|
||||
|
||||
void SetCreature(ArbUt::BorrowedPtr<Creature> creature, uint8_t index);
|
||||
void SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint8_t index);
|
||||
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature(uint8_t index) const;
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(uint8_t index) const;
|
||||
bool CreatureOnSide(const ArbUt::BorrowedPtr<Creature>& creature) const;
|
||||
|
||||
size_t ScriptCount() const override;
|
||||
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override;
|
||||
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& GetCreatures() { return _creatures; }
|
||||
const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& GetCreatures() { return _creatures; }
|
||||
|
||||
uint8_t GetSideIndex() noexcept { return _index; }
|
||||
uint8_t GetCreatureIndex(const ArbUt::BorrowedPtr<Creature>& c) {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
if (_creatures[i] == c)
|
||||
if (!_creatures[i].HasValue())
|
||||
continue;
|
||||
if (_creatures[i].GetValue() == c.GetRaw())
|
||||
return i;
|
||||
}
|
||||
THROW("Unable to find creature on field.");
|
||||
@@ -61,7 +63,9 @@ namespace CreatureLib::Battling {
|
||||
|
||||
void MarkSlotAsUnfillable(const ArbUt::BorrowedPtr<Creature>& creature) noexcept {
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
|
||||
if (_creatures[i] == creature) {
|
||||
if (!_creatures[i].HasValue())
|
||||
continue;
|
||||
if (_creatures[i].GetValue() == creature) {
|
||||
_fillableSlots.At(i) = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user