Skip to content

Commit

Permalink
Merge pull request #22 from jpw1991/21-new-features-requested
Browse files Browse the repository at this point in the history
21 new features requested
  • Loading branch information
jpw1991 authored Jul 5, 2024
2 parents edae731 + f060cfd commit 89d1fb4
Show file tree
Hide file tree
Showing 42 changed files with 570 additions and 2,246 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,55 @@ on:
tags:
- 'v*' # Trigger only if the tag matches eg. v1.0.0

workflow_run:
workflows: ["build"] # run if build.yml is successfully completed
types:
- completed

env:
name: ChebsMythicalWeapons
jsonf: manifest.json
dlpath: https://github.com/jpw1991/chebs-mythical-weapons/releases/download
dependencies: "ValheimModding-Jotunn@2.16.2" # dependencies separated by spaces
dependencies: "ValheimModding-Jotunn@2.20.1" # dependencies separated by spaces
categories: "Mods" # categories separated by spaces
namespace: ChebGonaz

jobs:
verify-manifest:
verify-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check that version matches
- name: Check tag
run: |
version=$(grep -Po "AssemblyVersion\(\"\K([0-9]+\.[0-9]+\.[0-9]+)" ${{env.name}}/Properties/AssemblyInfo.cs)
versionfrommanifest="$(jq -r '.version_number' $(find ./${{env.name}}/Package -name ${{env.jsonf}}))"
[ -z "$version" ] && echo "::error::version is empty!" && exit 1
[ -z "$versionfrommanifest" ] && echo "::error::versionfrommanifest is empty!" && exit 1
if [[ $versionfrommanifest != $version ]]; then
echo "::error::Version in ${{env.jsonf}} does not match assembly version"
# the tags check above doesn't seem to work properly, so a more rigorous check here
if [ "${{ github.event_name }}" == "release" ]; then
echo "This workflow was triggered by a release."
release_tag="${{ github.event.release.tag_name }}"
# Check if the tag matches semantic versioning pattern
if ! [[ $release_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+)?$ ]]; then
echo "Error: Release tag ($release_tag) does not match semantic versioning pattern."
exit 1
fi
exit 0
elif [ "${{ github.event_name }}" == "workflow_run" ]; then
echo "This workflow was triggered by a workflow run."
exit 0
else
echo "This workflow was triggered by an unknown event: ${{ github.event_name }}"
exit 1
fi
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Get Description
id: get_description
run: |
description=$(jq -r '.description' $(find ./${{env.name}}/Package -name ${{env.jsonf}}))
echo "DESCRIPTION=${description}" >> $GITHUB_ENV
publish:
needs: verify-tag
runs-on: ubuntu-latest
needs: verify-manifest
steps:
- uses: actions/checkout@v3
- run: wget ${{env.dlpath}}/${{github.ref_name}}/${{env.name}}.${{env.VERSION}}.zip
- name: Read manifest
run: |
version="$(jq -r '.version_number' ${{env.name}}/Package/${{env.jsonf}})"
description="$(jq -r '.description' ${{env.name}}/Package/${{env.jsonf}})"
echo "VERSION=${version}" >> $GITHUB_ENV
echo "DESCRIPTION=${description}" >> $GITHUB_ENV
- run: wget ${{env.dlpath}}/v${{env.VERSION}}/${{env.name}}.${{env.VERSION}}.zip
- name: Upload Thunderstore Package
uses: GreenTF/upload-thunderstore-package@v4
with:
Expand All @@ -53,3 +67,4 @@ jobs:
deps: ${{env.dependencies}}
categories: ${{env.categories}}
file: ${{env.name}}.${{env.VERSION}}.zip

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "chebs-sword-in-the-stone.wiki"]
path = chebs-sword-in-the-stone.wiki
url = [email protected]:jpw1991/chebs-sword-in-the-stone.wiki.git
[submodule "chebs-mythical-weapons-unity"]
path = chebs-mythical-weapons-unity
url = [email protected]:jpw1991/chebs-mythical-weapons-unity.git
54 changes: 47 additions & 7 deletions ChebsMythicalWeapons/ChebsMythicalWeapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ internal class ChebsMythicalWeapons : BaseUnityPlugin
{
public const string PluginGuid = "com.chebgonaz.chebsmythicalweapons";
public const string PluginName = "ChebsMythicalWeapons";
public const string PluginVersion = "4.5.0";
public const string PluginVersion = "4.5.2";

private const string ConfigFileName = PluginGuid + ".cfg";
private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, ConfigFileName);

public readonly System.Version ChebsValheimLibraryVersion = new("2.6.1");
public readonly System.Version ChebsValheimLibraryVersion = new("2.6.2");

private readonly Harmony _harmony = new(PluginGuid);

Expand Down Expand Up @@ -70,7 +70,7 @@ private void Awake()

StartCoroutine(WatchConfigFile());
}

#region ConfigUpdate
private byte[] GetFileHash(string fileName)
{
Expand Down Expand Up @@ -101,12 +101,50 @@ private void ReadConfigValues()
var adminOrLocal = ZNet.instance.IsServerInstance() || ZNet.instance.IsLocalInstance();
Logger.LogInfo($"Read updated config values (admin/local={adminOrLocal})");
if (adminOrLocal) Config.Reload();
// apply new values from config to the weapons
Aegis.UpdateItemValues();
ApolloBow.UpdateItemValues();
BladeOfOlympus.UpdateItemValues();
Excalibur.UpdateItemValues();
GreatswordOfOlympus.UpdateItemValues();
Joyce.UpdateItemValues();
SunArrow.UpdateItemValues();
// update whatever stuff the player's currently got equipped/in inventory
UpdateItemsInScene();
}
catch (Exception exc)
{
Logger.LogError($"There was an issue loading your {ConfigFileName}: {exc}");
}
}

private void UpdateItemsInScene()
{
// update local player's equipment
if (Player.m_localPlayer == null)
{
Logger.LogWarning("Attempted to update items in scene with new values from config but player is " +
"null. This is ok if you're in the menus or something.");
return;
}
var playerInventory = Player.m_localPlayer.GetInventory();
if (playerInventory?.m_inventory == null)
{
Logger.LogError("Failed to get player inventory.");
return;
}
foreach (var item in playerInventory.m_inventory)
{
var updatedItem = PrefabManager.Instance.GetPrefab(item.m_dropPrefab?.name);
if (updatedItem == null)
{
Logger.LogInfo("Failed to update because item is null");
continue;
}
item.m_shared = updatedItem.GetComponent<ItemDrop>().m_itemData.m_shared;
}
}

#endregion

private void CreateConfigValues()
Expand Down Expand Up @@ -171,7 +209,8 @@ private void LoadAssetBundle()
var swordInTheStonePickablePrefab =
chebgonazAssetBundle.LoadAsset<GameObject>(SwordInTheStonePickable.PickablePrefabName);
swordInTheStonePickablePrefab.AddComponent<SwordInTheStonePickable>();
PrefabManager.Instance.AddPrefab(swordInTheStonePickablePrefab);
var swordInTheStoneCustomPrefab = new CustomPrefab(swordInTheStonePickablePrefab, true);
PrefabManager.Instance.AddPrefab(swordInTheStoneCustomPrefab);

// stone location
var swordInTheStoneLocationPrefab =
Expand All @@ -186,7 +225,7 @@ private void LoadAssetBundle()
ClearArea = true,
};
var customLocation =
new CustomLocation(swordInTheStoneLocationPrefab, false, swordInTheStoneConfig);
new CustomLocation(swordInTheStoneLocationPrefab, true, swordInTheStoneConfig);
ZoneManager.Instance.AddCustomLocation(customLocation);
}
{
Expand All @@ -199,7 +238,8 @@ private void LoadAssetBundle()
var bowPickablePrefab =
chebgonazAssetBundle.LoadAsset<GameObject>(ApolloStatuePickable.PickablePrefabName);
bowPickablePrefab.AddComponent<ApolloStatuePickable>();
PrefabManager.Instance.AddPrefab(bowPickablePrefab);
var bowPickableCustomPrefab = new CustomPrefab(bowPickablePrefab, true);
PrefabManager.Instance.AddPrefab(bowPickableCustomPrefab);

// bow location
var bowLocationPrefab = chebgonazAssetBundle.LoadAsset<GameObject>(ApolloStatueLocation.PrefabName);
Expand All @@ -212,7 +252,7 @@ private void LoadAssetBundle()
ExteriorRadius = 2f,
ClearArea = true,
};
var customLocation = new CustomLocation(bowLocationPrefab, false, config);
var customLocation = new CustomLocation(bowLocationPrefab, true, config);
ZoneManager.Instance.AddCustomLocation(customLocation);
}
{
Expand Down
7 changes: 4 additions & 3 deletions ChebsMythicalWeapons/ChebsMythicalWeapons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Guid>e3243d22-4307-4008-ba36-9f326008cde5</Guid>

<!-- Version Information -->
<Version>4.5.0.0</Version>
<Version>4.5.2.0</Version>
<FileVersion>$(Version)</FileVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

Expand All @@ -40,8 +40,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ChebsValheimLibrary" Version="2.6.1" />
<PackageReference Include="JotunnLib" Version="2.19.3" />
<PackageReference Include="ChebsValheimLibrary" Version="2.6.2" />
<PackageReference Include="HarmonyX" Version="2.9.0" />
<PackageReference Include="JotunnLib" Version="2.20.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading

0 comments on commit 89d1fb4

Please sign in to comment.