Skip to content

Commit

Permalink
See v3 release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
SpectralPlatypus committed May 1, 2021
1 parent 0e86d0d commit 667a93b
Show file tree
Hide file tree
Showing 33 changed files with 601 additions and 29 deletions.
54 changes: 54 additions & 0 deletions ExampleMods/BGMute/BGMute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Pepperoni;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace BGMute
{
public class BGMute : Mod
{
private const string _modVersion = "1.0";
// private bool _muted;
public BGMute() : base("BGMute")
{
}

public override string GetVersion() => _modVersion;

public override void Initialize()
{
On.VoidMusic.Update += VoidMusic_Update;
On.BossRoomController.BossDialogueEnd += BossRoomController_BossDialogueEnd;
On.BossRoomController.KeepMusicGoing += BossRoomController_KeepMusicGoing;
On.TitleScreen.FixedUpdate += TitleScreen_FixedUpdate;
}

private void TitleScreen_FixedUpdate(On.TitleScreen.orig_FixedUpdate orig, TitleScreen self)
{
orig(self);
self.Music.volume = 0f;
self.YoNoidChant.volume = 0f;
}

private void VoidMusic_Update(On.VoidMusic.orig_Update orig, VoidMusic self)
{
orig(self);
self.Clear();
}

private void BossRoomController_KeepMusicGoing(On.BossRoomController.orig_KeepMusicGoing orig, BossRoomController self)
{
// Do nothing for now
}

private void BossRoomController_BossDialogueEnd(On.BossRoomController.orig_BossDialogueEnd orig, BossRoomController self)
{
orig(self);
if (BossController.State == BossStates.Intro)
{
self.transform.Find("Music").gameObject.GetComponent<AudioSource>().Stop();
self.Boss.StopSinging();
}
}

}
}
27 changes: 27 additions & 0 deletions ExampleMods/BGMute/BGMute.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
<Reference Include="OUTPUT_Assembly-CSharp">
<HintPath>..\..\Pepperoni\bin\Release\OUTPUT_Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\Vanilla\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\Vanilla\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\Vanilla\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetPath)&quot; &quot;F:\Games\Yo Noid 2 GOAY - Mod\noid_Data\Managed\Mods\$(TargetFileName)&quot;" />
</Target>

</Project>
146 changes: 146 additions & 0 deletions ExampleMods/BuilderNoid/BuilderNoid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using Pepperoni;
using System;
using System.IO;
using System.Reflection;
using UnityEngine;

namespace BuilderNoid
{
public class BuilderNoid : Pepperoni.Mod
{

internal static Texture2D blockTexture = null;
private GameObject[] blockList = new GameObject[5];
private int _blockIndex = 0;
private static readonly int BLAYER = 15;
GameObject protoBlock;

public BuilderNoid() : base("BuilderNoid")
{
}

public override string GetVersion() => "2.0";

public override void Initialize()
{
string fileName = "";
foreach (string fn in Assembly.GetExecutingAssembly().GetManifestResourceNames())
{
if (fn.Contains("pizza_box"))
{
fileName = fn;
break;
}
}

try
{
if (fileName == "")
throw new FileNotFoundException();

using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(fileName))
{
byte[] imageBuffer = new byte[imageStream.Length];
imageStream.Read(imageBuffer, 0, imageBuffer.Length);
imageStream.Flush();
blockTexture = new Texture2D(1, 1);
blockTexture.LoadImage(imageBuffer);
LogDebug("Loaded Block Texture");
ModHooks.Instance.OnPlayerEarlyUpdateHook += OnEarlyUpdate;
ModHooks.Instance.BeforeSceneLoad += Instance_BeforeSceneLoad;

protoBlock = new GameObject();
protoBlock.AddComponent<ProtoBlock>();
GameObject.DontDestroyOnLoad(protoBlock);
protoBlock.SetActive(false);
}
}
catch (Exception e)
{
LogError(e);
}
}

private void Instance_BeforeSceneLoad(string sceneName)
{
for (int i = 0; i < blockList.Length; ++i)
{
GameObject.Destroy(blockList[i]);
blockList[i] = null;
}
_blockIndex = 0;
}

enum BlockState
{
Idle,
Placing,
Over
}

BlockState state = BlockState.Idle;
private void OnEarlyUpdate(PlayerMachine playerMachine)
{
if (state != BlockState.Idle && playerMachine.currentState.Equals(PlayerStates.Loading))
{
protoBlock.SetActive(false);
state = BlockState.Idle;
}

switch (state)
{
case BlockState.Idle:
if (Kueido.Input.Dab.Pressed)
{
protoBlock.SetActive(true);

state = BlockState.Placing;
}
break;
case BlockState.Placing:
if (Kueido.Input.Dab.Held)
{
Vector3 normal =
(playerMachine.currentState.Equals(PlayerStates.Walk)) ? playerMachine.controller.currentGround.PrimaryNormal() : playerMachine.controller.up;
protoBlock.transform.position = playerMachine.transform.position +
(normal * 2f) +
(playerMachine.lookDirection * 5 * (playerMachine.Camera.zoom2+ 0.3f));
protoBlock.transform.up = normal;
}
else
{
// Place block etc
if(protoBlock.GetComponent<ProtoBlock>().IsFree())
{
PlaceBlock(protoBlock.transform.position, protoBlock.transform.rotation);
}
protoBlock.SetActive(false);
state = BlockState.Idle;
}
break;
}
}

private void PlaceBlock(Vector3 blockPos, Quaternion rotation)
{
int index = _blockIndex % blockList.Length;
if (blockList[index] == default(GameObject))
{
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);

go.layer = BLAYER;
go.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);

go.GetComponent<MeshRenderer>().material.SetTexture("_MainTex", blockTexture);
go.SetActive(true);

blockList[index] = go;

}

blockList[index].transform.position = blockPos;
blockList[index].transform.rotation = rotation;
_blockIndex = ++index % blockList.Length;
}
}
}
71 changes: 71 additions & 0 deletions ExampleMods/BuilderNoid/BuilderNoid.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{68FCC17D-26A0-4BE3-86D1-F644A1DF16AA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BuilderNoid</RootNamespace>
<AssemblyName>BuilderNoid</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</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>
<ItemGroup>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\Vanilla\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="OUTPUT_Assembly-CSharp">
<HintPath>..\..\Pepperoni\bin\Release\OUTPUT_Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\Vanilla\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\Vanilla\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>..\..\Vanilla\UnityEngine.ImageConversionModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\Vanilla\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BuilderNoid.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtoBlock.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="pizza_box.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetPath)" "F:\Games\Yo Noid 2 GOAY - Mod\noid_Data\Managed\Mods\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
</Project>
36 changes: 36 additions & 0 deletions ExampleMods/BuilderNoid/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BuilderNoid")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BuilderNoid")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("68fcc17d-26a0-4be3-86d1-f644a1df16aa")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 667a93b

Please sign in to comment.