-
-
Notifications
You must be signed in to change notification settings - Fork 128
Export interface for external call #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TaranDahl
wants to merge
11
commits into
Phobos-developers:develop
Choose a base branch
from
TaranDahl:Interop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
864b5b1
core
TaranDahl 2e94212
Update AttachEffect.cpp
TaranDahl 12021a6
update
TaranDahl 19499e7
Update README.md
TaranDahl 5d711d9
Update docs/Whats-New.md
TaranDahl 33dd370
update
TaranDahl 3f5a207
Update YRpp
TaranDahl 7e1ccd4
Potential fix for pull request finding
DeathFishAtEase 08eb21d
Potential fix for pull request finding
TaranDahl 560b0e8
Update Macro.h
TaranDahl 523374f
Create .po entries
DeathFishAtEase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,109 @@ | ||
|
|
||
| #include "AttachEffect.h" | ||
| #include "New/Entity/AttachEffectClass.h" | ||
| #include "New/Type/AttachEffectTypeClass.h" | ||
|
|
||
| DEFINE_EXPORT(int, AE_Attach, | ||
| TechnoClass* pTarget, | ||
| HouseClass* pInvokerHouse, | ||
| TechnoClass* pInvoker, | ||
| AbstractClass* pSource, | ||
| const char** effectTypeNames, | ||
| int typeCount, | ||
| int durationOverride, | ||
| int delay, | ||
| int initialDelay, | ||
| int recreationDelay | ||
| ) | ||
| { | ||
| if (!pTarget || !effectTypeNames || typeCount <= 0) | ||
| return 0; | ||
|
|
||
| AEAttachInfoTypeClass attachInfo; | ||
|
|
||
| for (int i = 0; i < typeCount; i++) | ||
| { | ||
| if (effectTypeNames[i]) | ||
| { | ||
| if (auto pType = AttachEffectTypeClass::Find(effectTypeNames[i])) | ||
| attachInfo.AttachTypes.push_back(pType); | ||
| } | ||
| } | ||
|
|
||
| if (attachInfo.AttachTypes.empty()) | ||
| return 0; | ||
|
|
||
| if (durationOverride != 0) | ||
| attachInfo.DurationOverrides.push_back(durationOverride); | ||
|
|
||
| if (delay >= 0) | ||
| attachInfo.Delays.push_back(delay); | ||
|
|
||
| if (initialDelay >= 0) | ||
| attachInfo.InitialDelays.push_back(initialDelay); | ||
|
|
||
| if (recreationDelay >= -1) | ||
| attachInfo.RecreationDelays.push_back(recreationDelay); | ||
|
|
||
| return AttachEffectClass::Attach(pTarget, pInvokerHouse, pInvoker, pSource, attachInfo); | ||
| } | ||
|
|
||
| DEFINE_EXPORT(int, AE_Detach, | ||
| TechnoClass* pTarget, | ||
| const char** effectTypeNames, | ||
| int typeCount | ||
| ) | ||
| { | ||
| if (!pTarget || !effectTypeNames || typeCount <= 0) | ||
| return 0; | ||
|
|
||
| AEAttachInfoTypeClass detachInfo; | ||
|
|
||
| for (int i = 0; i < typeCount; i++) | ||
| { | ||
| if (effectTypeNames[i]) | ||
| { | ||
| if (auto pType = AttachEffectTypeClass::Find(effectTypeNames[i])) | ||
| detachInfo.RemoveTypes.push_back(pType); | ||
| } | ||
| } | ||
|
|
||
| if (detachInfo.RemoveTypes.empty()) | ||
| return 0; | ||
|
|
||
| return AttachEffectClass::Detach(pTarget, detachInfo); | ||
| } | ||
|
|
||
| DEFINE_EXPORT(int, AE_DetachByGroups, | ||
| TechnoClass* pTarget, | ||
| const char** groupNames, | ||
| int groupCount | ||
| ) | ||
| { | ||
| if (!pTarget || !groupNames || groupCount <= 0) | ||
| return 0; | ||
|
|
||
| AEAttachInfoTypeClass detachInfo; | ||
|
|
||
| for (int i = 0; i < groupCount; i++) | ||
| { | ||
| if (groupNames[i]) | ||
| detachInfo.RemoveGroups.push_back(groupNames[i]); | ||
| } | ||
|
|
||
| if (detachInfo.RemoveGroups.empty()) | ||
| return 0; | ||
|
|
||
| return AttachEffectClass::DetachByGroups(pTarget, detachInfo); | ||
| } | ||
|
|
||
| DEFINE_EXPORT(void, AE_TransferEffects, | ||
| TechnoClass* pSource, | ||
| TechnoClass* pTarget | ||
| ) | ||
| { | ||
| if (!pSource || !pTarget) | ||
| return; | ||
|
|
||
| AttachEffectClass::TransferAttachedEffects(pSource, pTarget); | ||
| } | ||
This file contains hidden or 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,58 @@ | ||
| #pragma once | ||
|
|
||
| #include <TechnoClass.h> | ||
| #include <HouseClass.h> | ||
| #include <AbstractClass.h> | ||
| // Interop exports for AttachEffect operations. | ||
| // C# P/Invoke examples (simplified): | ||
| // ```csharp | ||
| // [DllImport("Phobos.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "AE_Attach")] | ||
| // public static extern int AE_Attach(IntPtr pTarget, IntPtr pInvokerHouse, IntPtr pInvoker, IntPtr pSource, IntPtr effectTypeNames, int typeCount, int durationOverride, int delay, int initialDelay, int recreationDelay); | ||
| // | ||
| // [DllImport("Phobos.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "AE_Detach")] | ||
| // public static extern int AE_Detach(IntPtr pTarget, IntPtr effectTypeNames, int typeCount); | ||
| // ``` | ||
|
|
||
| #include "Utilities/Macro.h" | ||
|
|
||
| /// <summary> | ||
| /// Attaches AttachEffect instances to a target unit. | ||
| /// </summary> | ||
| DEFINE_EXPORT(int, AE_Attach, | ||
| TechnoClass* pTarget, | ||
| HouseClass* pInvokerHouse, | ||
| TechnoClass* pInvoker, | ||
| AbstractClass* pSource, | ||
| const char** effectTypeNames, | ||
TaranDahl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| int typeCount, | ||
| int durationOverride, | ||
| int delay, | ||
| int initialDelay, | ||
| int recreationDelay | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Removes AttachEffect instances matching given types from a unit. | ||
| /// </summary> | ||
| DEFINE_EXPORT(int, AE_Detach, | ||
| TechnoClass* pTarget, | ||
| const char** effectTypeNames, | ||
| int typeCount | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Removes AttachEffect instances matching given groups from a unit. | ||
| /// </summary> | ||
| DEFINE_EXPORT(int, AE_DetachByGroups, | ||
| TechnoClass* pTarget, | ||
| const char** groupNames, | ||
| int groupCount | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Transfers AttachEffect instances from one unit to another. | ||
| /// </summary> | ||
| DEFINE_EXPORT(void, AE_TransferEffects, | ||
| TechnoClass* pSource, | ||
| TechnoClass* pTarget | ||
| ); | ||
This file contains hidden or 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,7 @@ | ||
| #include "TechnoExt.h" | ||
| #include <Ext/Techno/Body.h> | ||
|
|
||
| DEFINE_EXPORT(bool, ConvertToType_Phobos, FootClass* pThis, TechnoTypeClass* toType) | ||
| { | ||
| return TechnoExt::ConvertToType(pThis, toType); | ||
| } |
This file contains hidden or 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,23 @@ | ||
| #pragma once | ||
|
|
||
| #include <TechnoTypeClass.h> | ||
| #include <FootClass.h> | ||
| // Interop exports for external engine extensions. | ||
| // C# P/Invoke example: | ||
| // ```csharp | ||
| // [DllImport("Phobos.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ConvertToType_Phobos")] | ||
| // [return: MarshalAs(UnmanagedType.I1)] | ||
| // public static extern bool ConvertToType_Phobos(IntPtr pThis, IntPtr toType); | ||
| // ``` | ||
| // Use `IntPtr` or `unsafe` pointers in managed code. The function below exposes | ||
| // the same signature as used internally (FootClass*, TechnoTypeClass*). | ||
|
|
||
| #include "Utilities/Macro.h" | ||
|
|
||
| /// <summary> | ||
| /// Converts a unit to a different type. | ||
| /// </summary> | ||
| /// <param name="pThis">Pointer to the FootClass instance to convert</param> | ||
| /// <param name="toType">Pointer to the target TechnoTypeClass</param> | ||
| /// <returns>true if conversion was successful, false otherwise</returns> | ||
| DEFINE_EXPORT(bool, ConvertToType_Phobos, FootClass* pThis, TechnoTypeClass* toType); |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.