Skip to content
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

Trenches - Make E-tool-placed fortifications slower to build #123

Open
wants to merge 4 commits into
base: trenches/enhance-placement
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions addons/trenches/Configs/ACE/Settings.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ACE_SettingsConfig {
m_aInitialModSettings {
ACE_Treches_Settings "{62733434AE513E1A}" {
}
}
}
17 changes: 17 additions & 0 deletions addons/trenches/Configs/ACE/Settings.conf.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{A305FEB7400A2965}Configs/ACE/Settings.conf"
Configurations {
CONFResourceClass PC {
}
CONFResourceClass XBOX_ONE : PC {
}
CONFResourceClass XBOX_SERIES : PC {
}
CONFResourceClass PS4 : PC {
}
CONFResourceClass PS5 : PC {
}
CONFResourceClass HEADLESS : PC {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ modded class SCR_CampaignBuildingLayoutComponent : ScriptComponent
ent.AddChild(m_PreviewEntity, -1, EAddChildFlags.RECALC_LOCAL_TRANSFORM);
m_PreviewEntity.Update();
}

//------------------------------------------------------------------------------------------------
void ACE_Trenches_SetToBuildValue(int value)
{
m_iToBuildValue = value;
Replication.BumpMe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ modded class SCR_CampaignBuildingNetworkComponent : ScriptComponent
return;

compositionComponent.SetBuilderId(playerController.GetPlayerId());

SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(asset.GetChildren().FindComponent(SCR_CampaignBuildingLayoutComponent));
if (!layoutComponent)
return;

ACE_Treches_Settings settings = ACE_SettingsHelperT<ACE_Treches_Settings>.GetModSettings();
if (!settings)
return;

layoutComponent.ACE_Trenches_SetToBuildValue(settings.m_fBuildTimeScale * layoutComponent.GetToBuildValue());
}

//------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//------------------------------------------------------------------------------------------------
//! Add mod settings to mission header
[BaseContainerProps()]
modded class ACE_MissionHeaderSettings
{
[Attribute()]
protected ref ACE_Treches_Settings m_ACE_Treches_Settings;

//------------------------------------------------------------------------------------------------
//! Applies settings from mission header to config
override void ApplyToSettingsConfig(notnull ACE_SettingsConfig config)
{
super.ApplyToSettingsConfig(config);

if (m_ACE_Treches_Settings)
config.SetModSettings(m_ACE_Treches_Settings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//------------------------------------------------------------------------------------------------
//! Settings for a mod
[BaseContainerProps()]
class ACE_Treches_Settings : ACE_ModSettings
{
[Attribute(defvalue: "2", desc: "How much more time it takes to build structures placed with the E-tool.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make it clear it's an coefficient?

float m_fBuildTimeScale;
}
19 changes: 19 additions & 0 deletions docs/src/content/docs/components/trenches.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,22 @@ ACE Trenches extends the E-tool with the ability to place dirt covers.

- Toggle building mode while having the E-tool in hand with the `Inspect` keybind in `Equipment` category (Default: Hold <kbd>R</kbd>).
- Place dirt cover while in building mode with the `Use Item` keybind in `Equipment` category (Default: <kbd>R</kbd>).

## Settings

Certain aspects of this mod can be configured in the mission header section of a server config file. An overview of available fields is given below in the table:

| Field | Type | Default | Description |
| ---------------------- | ----- | ------- | ----------------------------------------------------------------------- |
| m_fBuildTimeScale | float | 2.0 | How much more time it takes to build structures placed with the E-tool. |

Example for the `missionHeader` in a server config:
```
"missionHeader": {
"m_ACE_Settings": {
"m_ACE_Treches_Settings": {
"m_fBuildTimeScale": 2.0
}
}
}
```