Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ This page lists all the individual contributions to the project by their author.
- Fix an issue that the move mission of the jumpjet does not end correctly
- Fix the issue that the Jumpjet must end its movement before starting the next mission
- Taunt warhead
- Export interface for external call
- **solar-III (凤九歌)**
- Target scanning delay customization (documentation)
- Skip target scanning function calling for unarmed technos (documentation)
Expand Down
4 changes: 4 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<ClCompile Include="src\Ext\EBolt\Hooks.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.SimpleDeployer.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Unload.cpp" />
<ClCompile Include="src\Interop\AttachEffect.cpp" />
<ClCompile Include="src\Interop\TechnoExt.cpp" />
<ClCompile Include="src\New\Entity\Ares\RadarJammerClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\CreateUnitTypeClass.cpp" />
<ClCompile Include="src\Blowfish\blowfish.cpp" />
Expand Down Expand Up @@ -221,6 +223,8 @@
<ItemGroup>
<ClInclude Include="src\Ext\EBolt\Body.h" />
<ClInclude Include="src\Ext\Event\Body.h" />
<ClInclude Include="src\Interop\AttachEffect.h" />
<ClInclude Include="src\Interop\TechnoExt.h" />
<ClInclude Include="src\New\Entity\Ares\RadarJammerClass.h" />
<ClInclude Include="src\New\Type\Affiliated\CreateUnitTypeClass.h" />
<ClInclude Include="src\Blowfish\blowfish.h" />
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Credits

This project was founded by [@Belonit](https://github.com/Belonit) (Gluk-v48) and [@Metadorius](https://github.com/Metadorius) (Kerbiter) in 2020, with the first public stable release in 2021. Since then it has grown into a large community project with many contributors and maintainers.

### Interoperability

Phobos has opened the external interfaces of some key components. If you are also developing your own engine extension and wish to use Phobos at the same time, please check out [Interop](https://github.com/Phobos-developers/Phobos/tree/develop/src/Interop).

### Maintenance crew

Maintenance crew consists of experienced Phobos contributors who are recognized and given the permission to maintain and shape the project to the extent of their permissions.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ New:
- [Taunt warhead](New-or-Enhanced-Logics.md#taunt-warhead) (by TaranDahl)
- [Custom hover vehicles shutdown drowning death](New-or-Enhanced-Logics.md#custom-hover-vehicles-shutdown-drowning-death) (by FlyStar)
- [SHP turret vehicles support the use of `*tur.shp` files](New-or-Enhanced-Logics.md#independent-shp-vehicle-turret-files) (by FlyStar)
- [Export interface for external call](index.md#interoperability) (by TaranDahl)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
109 changes: 109 additions & 0 deletions src/Interop/AttachEffect.cpp
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"

int __stdcall 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);
}

int __stdcall 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);
}

int __stdcall 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);
}

void __stdcall AE_TransferEffects(
TechnoClass* pSource,
TechnoClass* pTarget
)
{
if (!pSource || !pTarget)
return;

AttachEffectClass::TransferAttachedEffects(pSource, pTarget);
}
50 changes: 50 additions & 0 deletions src/Interop/AttachEffect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include <TechnoClass.h>
#include <HouseClass.h>
#include <AbstractClass.h>

extern "C"
{
/// <summary>
/// Attaches AttachEffect instances to a target unit.
/// </summary>
__declspec(dllexport) int __stdcall AE_Attach(
TechnoClass* pTarget,
HouseClass* pInvokerHouse,
TechnoClass* pInvoker,
AbstractClass* pSource,
const char** effectTypeNames,
int typeCount,
int durationOverride,
int delay,
int initialDelay,
int recreationDelay
);

/// <summary>
/// Removes AttachEffect instances matching given types from a unit.
/// </summary>
__declspec(dllexport) int __stdcall AE_Detach(
TechnoClass* pTarget,
const char** effectTypeNames,
int typeCount
);

/// <summary>
/// Removes AttachEffect instances matching given groups from a unit.
/// </summary>
__declspec(dllexport) int __stdcall AE_DetachByGroups(
TechnoClass* pTarget,
const char** groupNames,
int groupCount
);

/// <summary>
/// Transfers AttachEffect instances from one unit to another.
/// </summary>
__declspec(dllexport) void __stdcall AE_TransferEffects(
TechnoClass* pSource,
TechnoClass* pTarget
);
}
7 changes: 7 additions & 0 deletions src/Interop/TechnoExt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "TechnoExt.h"
#include <Ext/Techno/Body.h>

extern "C" __declspec(dllexport) bool __stdcall ConvertToType_Phobos(FootClass* pThis, TechnoTypeClass* toType)
{
return TechnoExt::ConvertToType(pThis, toType);
}
15 changes: 15 additions & 0 deletions src/Interop/TechnoExt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <TechnoTypeClass.h>
#include <FootClass.h>

extern "C"
{
/// <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>
__declspec(dllexport) bool __stdcall ConvertToType_Phobos(FootClass* pThis, TechnoTypeClass* toType);
}