-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Library/Nerve: Finish implementation (#319)
- Loading branch information
1 parent
6395d28
commit e0f81e8
Showing
42 changed files
with
446 additions
and
146 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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
#pragma once | ||
|
||
#include <basis/seadTypes.h> | ||
|
||
#include "Library/Nerve/Nerve.h" | ||
#include "Library/Nerve/NerveUtil.h" | ||
|
||
namespace alNerveFunction { | ||
class NerveActionCollector; | ||
} | ||
|
||
namespace al { | ||
class NerveAction : public Nerve { | ||
public: | ||
NerveAction(); | ||
virtual const char* getActionName() const = 0; | ||
|
||
NerveAction* getNext() const { return mNextAction; } | ||
|
||
protected: | ||
friend class alNerveFunction::NerveActionCollector; | ||
|
||
private: | ||
NerveAction* mNextAction = nullptr; | ||
}; | ||
} // namespace al | ||
|
||
namespace alNerveFunction { | ||
|
||
class NerveActionCollector { | ||
public: | ||
NerveActionCollector(); | ||
|
||
void addNerve(al::NerveAction* action); | ||
|
||
s32 getNumActions() const { return mActionCount; } | ||
|
||
al::NerveAction* getHead() { return mHead; } | ||
|
||
protected: | ||
friend class al::NerveAction; | ||
|
||
private: | ||
s32 mActionCount = 0; | ||
al::NerveAction* mHead = nullptr; | ||
al::NerveAction* mTail = nullptr; | ||
|
||
static NerveActionCollector* sCurrentCollector; | ||
}; | ||
|
||
} // namespace alNerveFunction |
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,36 @@ | ||
#include "Library/Nerve/NerveActionCtrl.h" | ||
|
||
#include "Library/Base/StringUtil.h" | ||
#include "Library/Nerve/NerveAction.h" | ||
#include "Library/Nerve/NerveUtil.h" | ||
|
||
namespace al { | ||
|
||
NerveActionCtrl::NerveActionCtrl(alNerveFunction::NerveActionCollector* collector) { | ||
mNumActions = collector->getNumActions(); | ||
mActions = new NerveAction*[mNumActions]; | ||
|
||
if (mNumActions > 0) { | ||
NerveAction* current = collector->getHead(); | ||
mActions[0] = current; | ||
|
||
for (s32 i = 1; i < mNumActions; ++i) { | ||
// requires doing this pattern to calculate mActions[i] first | ||
NerveAction** next = &mActions[i]; | ||
current = current->getNext(); | ||
*next = current; | ||
} | ||
} | ||
} | ||
|
||
NerveAction* NerveActionCtrl::findNerve(const char* name) const { | ||
for (s32 i = 0; i < mNumActions; ++i) { | ||
NerveAction* action = mActions[i]; | ||
if (isEqualString(action->getActionName(), name)) | ||
return action; | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
} // namespace al |
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,25 @@ | ||
#pragma once | ||
|
||
#include <basis/seadTypes.h> | ||
|
||
namespace alNerveFunction { | ||
class NerveActionCollector; | ||
} // namespace alNerveFunction | ||
|
||
namespace al { | ||
class NerveAction; | ||
|
||
class NerveActionCtrl { | ||
public: | ||
NerveActionCtrl(alNerveFunction::NerveActionCollector* collector); | ||
|
||
NerveAction* findNerve(const char* name) const; | ||
|
||
private: | ||
s32 mNumActions = 0; | ||
NerveAction** mActions = nullptr; | ||
}; | ||
|
||
static_assert(sizeof(NerveActionCtrl) == 0x10); | ||
|
||
} // namespace al |
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
Oops, something went wrong.