Skip to content

Commit

Permalink
Merge pull request #360 from Panakotta00/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Panakotta00 authored Nov 18, 2024
2 parents dae2192 + 83b86fa commit 40f353c
Show file tree
Hide file tree
Showing 102 changed files with 3,481 additions and 2,823 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ jobs:
- name: Commit
working-directory: FicsItNetworks
continue-on-error: true
run: |
git add docs
git commit -m "docs: Automatic Documentation Update"
- name: Push
working-directory: FicsItNetworks
continue-on-error: true
run: |
git push
Binary file modified Content/Buildings/-Shared/BP_ModuleHoloWithCompass_def.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/BP_TestArrow.uasset
Binary file not shown.
Binary file added Content/Buildings/-Shared/MI_ArrowFont.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/MI_UpArrow.uasset
Binary file not shown.
Binary file added Content/Buildings/-Shared/M_ArrowFont.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/M_ArrowMaterial.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/Schematics/Schematic_Test2.uasset
Binary file not shown.
Binary file added Content/UI/Misc/BPW_FIN_Dependency.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion FicsItNetworks.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"FileVersion": 3,
"Version": 0,
"VersionName": "0.3",
"SemVersion": "0.3.27",
"SemVersion": "0.3.29",
"FriendlyName": "FicsIt-Networks",
"Description": "Adds a computer network and programmable computers to the Game.",
"Category": "Modding",
Expand Down
40 changes: 28 additions & 12 deletions Source/FicsItNetworks/Private/Components/FINSizeablePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void AFINSizeablePanel::EndPlay(const EEndPlayReason::Type endPlayReason) {

int32 AFINSizeablePanel::GetDismantleRefundReturnsMultiplier() const {
//return FMath::Abs(PanelWidth) * FMath::Abs(PanelHeight);
return FGenericPlatformMath::Max((FMath::Abs(PanelWidth) * FMath::Abs(PanelHeight)) / 10, 1);
return FMath::Max((FMath::Abs(PanelWidth) * FMath::Abs(PanelHeight)) / 10, 1);
}

bool AFINSizeablePanel::ShouldSave_Implementation() const {
Expand All @@ -75,14 +75,16 @@ bool AFINSizeablePanel::ShouldSave_Implementation() const {
void AFINSizeablePanel::ConstructParts() {
// Clear Components
for (UStaticMeshComponent* comp : Parts) {
comp->UnregisterComponent();
comp->SetActive(false);
comp->DestroyComponent();
if(IsValid(comp)) {
comp->UnregisterComponent();
comp->SetActive(false);
comp->DestroyComponent();
}
}
Parts.Empty();

// Create Components
SpawnComponents(UFGColoredInstanceMeshProxy::StaticClass(), PanelWidth, PanelHeight, PanelCornerMesh, PanelSideMesh, PanelCenterMesh, PanelConnectorMesh, this, RootComponent, Parts);
SpawnComponents(UStaticMeshComponent::StaticClass(), PanelWidth, PanelHeight, PanelCornerMesh, PanelSideMesh, PanelCenterMesh, PanelCenterMeshNoConnector, PanelConnectorMesh, this, RootComponent, Parts);
FVector ConnectorOffset;
if(PanelWidth < 0 && PanelHeight < 0) {
ConnectorOffset = {3.3, 0, 8};
Expand Down Expand Up @@ -110,29 +112,43 @@ void AFINSizeablePanel::SpawnComponents(TSubclassOf<UStaticMeshComponent> Class,
UStaticMesh* ULMesh,
UStaticMesh* UCMesh,
UStaticMesh* CCMesh,
UStaticMesh* CCMesh_NoCon,
UStaticMesh* ConnectorMesh,
AActor* Parent, USceneComponent* Attach,
TArray<UStaticMeshComponent*>& OutParts)
{
int xf = PanelWidth/FMath::Abs(PanelWidth);
int yf = PanelHeight/FMath::Abs(PanelHeight);
for (int x = 0; x < FMath::Abs(PanelWidth); ++x) {
for (int y = 0; y < FMath::Abs(PanelHeight); ++y) {
int absPanelWidth = FMath::Abs(PanelWidth);
int absPanelHeight = FMath::Abs(PanelHeight);
int xf = PanelWidth/absPanelWidth;
int yf = PanelHeight/absPanelHeight;
for (int x = 0; x < absPanelWidth; ++x) {
for (int y = 0; y < absPanelHeight; ++y) {
UStaticMeshComponent* MiddlePart = NewObject<UStaticMeshComponent>(Parent, Class);
MiddlePart->AttachToComponent(Attach, FAttachmentTransformRules::KeepRelativeTransform);
MiddlePart->SetRelativeLocation(FVector(0, x * 10 * xf, y * 10 * yf));
MiddlePart->RegisterComponent();
MiddlePart->CreationMethod = EComponentCreationMethod::UserConstructionScript;
//MiddlePart->CreationMethod = EComponentCreationMethod::UserConstructionScript;
MiddlePart->SetStaticMesh(CCMesh);
MiddlePart->SetMobility(EComponentMobility::Static);
MiddlePart->SetVisibility(true);
OutParts.Add(MiddlePart);
}
}
if(FMath::Abs(PanelWidth) > 1) {
UStaticMeshComponent* MiddlePart = NewObject<UStaticMeshComponent>(Parent, Class);
MiddlePart->AttachToComponent(Attach, FAttachmentTransformRules::KeepRelativeTransform);
MiddlePart->SetRelativeScale3D(FVector(1, absPanelWidth, absPanelHeight));
MiddlePart->SetRelativeLocation(FVector(0, (absPanelWidth * 10 / 2 - 5)* (yf > 0?xf:-xf), (absPanelHeight * 10)/ 2 - 5)* yf);
MiddlePart->RegisterComponent();
//MiddlePart->CreationMethod = EComponentCreationMethod::UserConstructionScript;
MiddlePart->SetStaticMesh(CCMesh_NoCon);
MiddlePart->SetMobility(EComponentMobility::Static);
MiddlePart->SetVisibility(false);
OutParts.Add(MiddlePart);
if(absPanelWidth > 1) {
SpawnEdgeComponent(Class, 0, 0, 2, PanelWidth, 1, UCMesh, Parent, Attach, PanelWidth, PanelHeight, OutParts); //DC
SpawnEdgeComponent(Class, 0, PanelHeight - 1, 0, PanelWidth, 1, UCMesh, Parent, Attach, PanelWidth, PanelHeight, OutParts); //UC
}
if(FMath::Abs(PanelHeight) > 1) {
if(absPanelHeight > 1) {
SpawnEdgeComponent(Class, 0, 0, -1, PanelHeight, 1, UCMesh, Parent, Attach, PanelWidth, PanelHeight, OutParts); //CR
SpawnEdgeComponent(Class, PanelWidth - 1, 0, 1, PanelHeight, 1, UCMesh, Parent, Attach, PanelWidth, PanelHeight, OutParts); //CL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ void AFINSizeablePanelHolo::ConstructParts() {
UStaticMesh* UL = Cast<AFINSizeablePanel>(mBuildClass->GetDefaultObject())->PanelCornerMesh;
UStaticMesh* UC = Cast<AFINSizeablePanel>(mBuildClass->GetDefaultObject())->PanelSideMesh;
UStaticMesh* CC = Cast<AFINSizeablePanel>(mBuildClass->GetDefaultObject())->PanelCenterMesh;
UStaticMesh* CCN = Cast<AFINSizeablePanel>(mBuildClass->GetDefaultObject())->PanelCenterMeshNoConnector;
UStaticMesh* Con = Cast<AFINSizeablePanel>(mBuildClass->GetDefaultObject())->PanelConnectorMesh;
AFINSizeablePanel::SpawnComponents(UStaticMeshComponent::StaticClass(), PanelWidth, PanelHeight, UL, UC, CC, Con, this, RootComponent, Parts);
AFINSizeablePanel::SpawnComponents(UStaticMeshComponent::StaticClass(), PanelWidth, PanelHeight, UL, UC, CC, CCN, Con, this, RootComponent, Parts);
RootComponent->SetMobility(EComponentMobility::Movable);
for (UStaticMeshComponent* Part : Parts) {
Part->SetMobility(EComponentMobility::Movable);
Expand Down
33 changes: 33 additions & 0 deletions Source/FicsItNetworks/Private/FicsItNetworksModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "FGGameState.h"
#include "FicsItNetworksMisc.h"
#include "FicsItReflection.h"
#include "FINDependencies.h"
#include "ReflectionHelper.h"
#include "WrapBox.h"
#include "WrapBoxSlot.h"
#include "AssetRegistry/AssetRegistryModule.h"
#include "Components/VerticalBox.h"
#include "FicsItKernel/FicsItFS/FINItemStateFileSystem.h"
Expand Down Expand Up @@ -63,6 +67,30 @@ void InventorSlot_CreateWidgetSlider_Hook(FBlueprintHookHelper& HookHelper) {
}
}

void ResearchNodeInfoWidget_CanResearch_Hook(FBlueprintHookHelper& HookHelper) {
UObject* Widget = HookHelper.GetContext();
TSubclassOf<UFGSchematic> schematic = FReflectionHelper::GetObjectPropertyValue<UClass>(Widget, TEXT("mSchematic"));
bool& canResearch = *HookHelper.GetOutVariablePtr<TProperty<bool, FBoolProperty>>(TEXT("Can Research"));
canResearch = canResearch && UFGSchematic::AreSchematicDependenciesMet(schematic, Widget);;
}

void ResearchNodeInfoWidget_UpdateState_Hook(FBlueprintHookHelper& HookHelper) {
UUserWidget* Widget = Cast<UUserWidget>(HookHelper.GetContext());
TSubclassOf<UFGSchematic> schematic = FReflectionHelper::GetObjectPropertyValue<UClass>(Widget, TEXT("mSchematic"));
UWrapBox* wrapBox = FReflectionHelper::GetObjectPropertyValue<UWrapBox>(Widget, TEXT("mCostSlotsContainer"));
TArray<UFGAvailabilityDependency*> dependencies;
UFGSchematic::GetSchematicDependencies(schematic, dependencies);
TSubclassOf<UUserWidget> dependencyWidgetClass = LoadClass<UUserWidget>(nullptr, TEXT("/FicsItNetworks/UI/Misc/BPW_FIN_Dependency.BPW_FIN_Dependency_C"));
for (UFGAvailabilityDependency* dependency : dependencies) {
UFINDependency* FINDependency = Cast<UFINDependency>(dependency);
if (!IsValid(FINDependency)) continue;
UUserWidget* dependencyWidget = Widget->WidgetTree->ConstructWidget<UUserWidget>(dependencyWidgetClass);
FReflectionHelper::SetPropertyValue<FObjectProperty>(dependencyWidget, TEXT("Dependency"), FINDependency);
UWrapBoxSlot* slot = wrapBox->AddChildToWrapBox(dependencyWidget);
slot->SetFillEmptySpace(true);
}
}

#define FIN_CoreRedirect(Type, OldName, NewName) \
redirects.Add(FCoreRedirect{ECoreRedirectFlags:: Type, \
TEXT(OldName), \
Expand Down Expand Up @@ -348,6 +376,11 @@ void FFicsItNetworksModule::StartupModule(){
UFunction* Function = Slot->FindFunctionByName(TEXT("CreateSplitSlider"));
UBlueprintHookManager* HookManager = GEngine->GetEngineSubsystem<UBlueprintHookManager>();
HookManager->HookBlueprintFunction(Function, InventorSlot_CreateWidgetSlider_Hook, EPredefinedHookOffset::Return);
UClass* NodeInfo = LoadObject<UClass>(NULL, TEXT("/Game/FactoryGame/Interface/UI/InGame/MAMTree/Widget_MAMTree_NodeInfo.Widget_MAMTree_NodeInfo_C"));
Function = NodeInfo->FindFunctionByName(TEXT("Can Research"));
HookManager->HookBlueprintFunction(Function, &ResearchNodeInfoWidget_CanResearch_Hook, EPredefinedHookOffset::Return);
Function = NodeInfo->FindFunctionByName(TEXT("UpdateState"));
HookManager->HookBlueprintFunction(Function, &ResearchNodeInfoWidget_UpdateState_Hook, EPredefinedHookOffset::Return);
#endif
});
}
Expand Down
Loading

0 comments on commit 40f353c

Please sign in to comment.