Skip to content

Commit

Permalink
[v1.2.0] Added spawn strategies. Added spike traps. Reworked the conf…
Browse files Browse the repository at this point in the history
…ig with ranges. Added backwards compat to v49.
  • Loading branch information
snaketech-tu committed Apr 24, 2024
1 parent e1ce639 commit c86c470
Show file tree
Hide file tree
Showing 28 changed files with 808 additions and 558 deletions.
23 changes: 20 additions & 3 deletions LCLandmineOutside/Abstract/AbstractCompatibilityHandler.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
namespace LCHazardsOutside.Abstract
using System;

namespace LCHazardsOutside.Abstract
{
internal abstract class AbstractCompatibilityHandler
{
public abstract void Apply();
protected abstract void DoApply();

public abstract string GetModGUID();
protected abstract string GetModGUID();

public bool IsEnabled()
{
return BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey(GetModGUID());
}

public void Apply()
{
if (IsEnabled())
{
try
{
DoApply();
} catch (Exception e)
{
Plugin.GetLogger().LogError($"There was an error in patching {GetModGUID()}. Skipping... \n {e}\n");
}

}
}

public void LogApply()
{
Plugin.GetLogger().LogInfo($"Applying compatibility fixes for {GetModGUID()}.");
Expand Down
17 changes: 13 additions & 4 deletions LCLandmineOutside/Abstract/SpawnStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using System.Collections.Generic;
using LCHazardsOutside.Data;
using System.Collections.Generic;
using UnityEngine;

namespace LCHazardsOutside.Abstract
{
internal abstract class SpawnStrategy
public abstract class SpawnStrategy
{
public abstract void CalculateCenterPosition(Vector3 shipLandPosition, Vector3 mainEntrancePosition, List<Vector3> pointsOfInterest, float spawnRadiusMultiplier, out Vector3 centerPosition, out float spawnRadius);
public abstract List<SpawnPositionData> CalculateCenterPositions(Vector3 shipLandPosition, Vector3 mainEntrancePosition, List<Vector3> pointsOfInterest, float spawnRadiusMultiplier);

public abstract (Vector3, Quaternion) GetRandomGroundPositionAndRotation(Vector3 centerPoint, float radius = 10f, System.Random randomSeed = null, int layerMask = -1, int maxAttempts = 10);
protected SpawnPositionData CalculateCenterWithSpawnRadius(Vector3 shipLandPosition, Vector3 targetPosition, float spawnRadiusMultiplier)
{
float spawnRadius;
Vector3 centerPosition = (shipLandPosition + targetPosition) / 2;
spawnRadius = Vector3.Distance(targetPosition, centerPosition) * spawnRadiusMultiplier;
centerPosition.y = Mathf.Max(shipLandPosition.y, targetPosition.y);

return new SpawnPositionData(centerPosition, spawnRadius);
}
}
}
17 changes: 17 additions & 0 deletions LCLandmineOutside/Data/EntranceContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace LCHazardsOutside.Data
{
public class EntranceContainer(Vector3 mainEntrancePosition, List<Vector3> fireExitPositions)
{
public Vector3 MainEntrancePosition { get; set; } = mainEntrancePosition;
public List<Vector3> FireExitPositions { get; set; } = fireExitPositions;

public bool IsInitialized()
{
return MainEntrancePosition != Vector3.zero && FireExitPositions.All(x => x != Vector3.zero);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using UnityEngine;

namespace LCHazardsOutside
namespace LCHazardsOutside.Data
{
internal class HazardCalculationContainer(System.Random random, List<GameObject> spawnDenialPoints, SpawnableMapObject spawnableMapObject, int minSpawnRate, int maxSpawnRate)
internal class HazardCalculationContainer(System.Random random, List<GameObject> spawnDenialPoints, SpawnableMapObject spawnableMapObject, int minSpawnRate, int maxSpawnRate, int layerMask)
{
public System.Random Random { get; set; } = random;
public List<GameObject> SpawnDenialPoints { get; set; } = spawnDenialPoints;
Expand All @@ -12,6 +12,7 @@ internal class HazardCalculationContainer(System.Random random, List<GameObject>
public int MaxSpawnRate { get; set; } = maxSpawnRate;
public bool NeedsSafetyZone { get; set; } = false;
public float SpawnRatioMultiplier { get; set; } = 1.5f;
public int LayerMask { get; set; } = layerMask;

}
}
}
14 changes: 14 additions & 0 deletions LCLandmineOutside/Data/HazardConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using LCHazardsOutside.Abstract;
using System.Collections.Generic;

namespace LCHazardsOutside.Data
{
public class HazardConfiguration(bool enabled, int minSpawnRate, int maxSpawnRate, Dictionary<string, MoonMinMax> moonMap, SpawnStrategy spawnStrategy)
{
public bool Enabled { get; set; } = enabled;
public int MinSpawnRate { get; set; } = minSpawnRate;
public int MaxSpawnRate { get; set; } = maxSpawnRate;
public Dictionary<string, MoonMinMax> MoonMap { get; set; } = moonMap;
public SpawnStrategy SpawnStrategy { get; set; } = spawnStrategy;
}
}
14 changes: 14 additions & 0 deletions LCLandmineOutside/Data/HazardType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace LCHazardsOutside.Data
{
public enum HazardType
{
Landmine,
Turret,
SpikeRoofTrap,
CustomHazard
}
}
8 changes: 8 additions & 0 deletions LCLandmineOutside/Data/MoonMinMax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace LCHazardsOutside.Data
{
public class MoonMinMax(int min, int max)
{
public int Min { get; set; } = min;
public int Max { get; set; } = max;
}
}
16 changes: 16 additions & 0 deletions LCLandmineOutside/Data/SpawnPositionData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEngine;

namespace LCHazardsOutside.Data
{
public record struct SpawnPositionData
{
public SpawnPositionData(Vector3 centerPosition, float spawnRadius) : this()
{
CenterPosition = centerPosition;
SpawnRadius = spawnRadius;
}

public Vector3 CenterPosition { get; set; }
public float SpawnRadius{ get; set; }
}
}
9 changes: 9 additions & 0 deletions LCLandmineOutside/Data/SpawnStrategyType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace LCHazardsOutside.Data
{
public enum SpawnStrategyType
{
MainAndFireExit,
MainEntranceOnly,
FireExitsOnly
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LCHazardsOutside
namespace LCHazardsOutside.Data
{
internal enum VanillaMoon
{
Expand All @@ -9,6 +9,10 @@ internal enum VanillaMoon
march,
rend,
dine,
titan
titan,
adamance,
embrion,
artifice,
liquidation
}
}
53 changes: 0 additions & 53 deletions LCLandmineOutside/DefaultSpawnStrategy.cs

This file was deleted.

33 changes: 3 additions & 30 deletions LCLandmineOutside/LCHazardsOutside.csproj
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{37D46F81-33BF-4D3F-ADD0-6F1534843895}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LCHazardsOutside</RootNamespace>
<AssemblyName>LCHazardsOutside</AssemblyName>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp" Publicize="true">
<HintPath>E:\SteamLibrary\steamapps\common\Lethal Company\Lethal Company_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
Expand All @@ -50,8 +27,4 @@
<PackageReference Include="UnityEngine.Modules" Version="2022.3.9" IncludeAssets="compile" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>
</Project>
Loading

0 comments on commit c86c470

Please sign in to comment.