<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
        <Title>MuzikaGromche</Title>
        <PackageId>MuzikaGromche</PackageId>
        <RootNamespace>MuzikaGromche</RootNamespace>
        <AssemblyName>Ratijas.MuzikaGromche</AssemblyName>
        <Product>Muzika Gromche</Product>
        <Description>Add some content to your inverse teleporter experience on Titan!</Description>
        <Version>1337.9001.0</Version>
        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
        <LangVersion>latest</LangVersion>
        <Nullable>enable</Nullable>

        <!-- NetcodePatch requires anything but 'full' -->
        <DebugType>portable</DebugType>

        <PackageReadmeFile>../README.md</PackageReadmeFile>
        <PackageProjectUrl>https://git.vilunov.me/ratijas/muzika-gromche</PackageProjectUrl>
        <RepositoryUrl>https://git.vilunov.me/ratijas/muzika-gromche</RepositoryUrl>
        <RepositoryType>git</RepositoryType>

        <!-- NuGet Information -->
        <RestoreAdditionalProjectSources>
            https://api.nuget.org/v3/index.json;
            https://nuget.bepinex.dev/v3/index.json;
            https://nuget.windows10ce.com/nuget/v3/index.json
        </RestoreAdditionalProjectSources>

        <!-- Prevent Publicizer Warnings from Showing -->
        <NoWarn>$(NoWarn);CS0436</NoWarn>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" Private="false" />
        <PackageReference Include="BepInEx.Core" Version="5.*" PrivateAssets="all" Private="false" />
        <PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" PrivateAssets="all" Private="false" />
        <PackageReference Include="UnityEngine.Modules" Version="2022.3.9" PrivateAssets="all" Private="false" />
        <PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" Private="false" />
        <PackageReference Include="AinaVT-LethalConfig" Version="1.4.6" PrivateAssets="all" Private="false" />
        <PackageReference Include="TeamBMX.LobbyCompatibility" Version="1.*" PrivateAssets="all" Private="false" />
    </ItemGroup>

    <ItemGroup>
        <Reference Include="Assembly-CSharp" Publicize="true" Private="false">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\Assembly-CSharp.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Collections" Private="false">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\Unity.Collections.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Netcode.Runtime" Publicize="true" Private="false">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\Unity.Netcode.Runtime.dll</HintPath>
        </Reference>
        <Reference Include="Unity.TextMeshPro" Publicize="true" Private="False">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\Unity.TextMeshPro.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.UI" Publicize="true" Private="False">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\UnityEngine.UI.dll</HintPath>
        </Reference>
        <Reference Include="Unity.RenderPipelines.Core.Runtime" Publicize="true" Private="False">
            <HintPath>$(LethalCompanyDir)Lethal Company_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll</HintPath>
        </Reference>
    </ItemGroup>

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

    <Target Name="Bundle" AfterTargets="Build">
        <PropertyGroup>
            <DistDir>$(TargetDir)MuzikaGromche\</DistDir>
            <ZipBundle>$(TargetDir)MuzikaGromche-$(Configuration).zip</ZipBundle>
        </PropertyGroup>

        <ItemGroup>
            <PackagedResources Include="$(SolutionDir)README.md" />
            <PackagedResources Include="$(SolutionDir)CHANGELOG.md" />
            <PackagedResources Include="$(SolutionDir)icon.png" />
            <PackagedResources Include="$(SolutionDir)manifest.json" />
            <PackagedResources Include="$(ProjectDir)UnityAssets\muzikagromche_discoball" />
            <PackagedResources Include="$(ProjectDir)UnityAssets\muzikagromche_poweredlightsanimators" />
            <PackagedResources Include="$(TargetDir)$(AssemblyName).dll" />
        </ItemGroup>

        <ItemGroup>
            <AudioFiles Include="$(SolutionDir)Assets\*.mp3" />
            <AudioFiles Include="$(SolutionDir)Assets\*.ogg" />
            <AudioFiles Include="$(SolutionDir)Assets\*.wav" />
        </ItemGroup>

        <RemoveDir Directories="$(DistDir)" />
        <Copy
            SourceFiles="@(AudioFiles);@(PackagedResources)"
            DestinationFolder="$(DistDir)"
        />
        <ZipDirectory
            SourceDirectory="$(DistDir)"
            DestinationFile="$(TargetDir)MuzikaGromche-$(Configuration).zip"
            Overwrite="true"
        />
        <Copy
            SourceFiles="$(ZipBundle)"
            DestinationFolder="$(SolutionDir)dist\"
        />
    </Target>

    <!--
    Usage:
        Set WavExportDir in props.user file.
        Run
            > dotnet msbuild /t:wav2ogg /p:TrackName=GodMode
    -->
    <Target Name="wav2ogg">
        <ItemGroup>
            <TrackNames Include="$(TrackName)Intro" />
            <TrackNames Include="$(TrackName)Loop" />
        </ItemGroup>
        <Exec Command="ffmpeg -bitexact -y -i $(WavExportDir)%(TrackNames.Identity).wav $(SolutionDir)Assets\%(TrackNames.Identity).ogg" />
    </Target>

    <Target Name="wav2ogg1">
        <ItemGroup>
            <TrackNames Include="$(TrackName)" />
        </ItemGroup>
        <Exec Command="ffmpeg -bitexact -y -i $(WavExportDir)%(TrackNames.Identity).wav $(SolutionDir)Assets\%(TrackNames.Identity).ogg" />
    </Target>
</Project>
