Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
add moreoverseers and moremice
Browse files Browse the repository at this point in the history
  • Loading branch information
casheww committed Apr 10, 2022
0 parents commit 56da7fe
Show file tree
Hide file tree
Showing 17 changed files with 664 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
13 changes: 13 additions & 0 deletions MoreMice/.idea/.idea.MoreMice.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions MoreMice/.idea/.idea.MoreMice.dir/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions MoreMice/.idea/.idea.MoreMice.dir/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions MoreMice/.idea/.idea.MoreMice.dir/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<Reference Include="$(References)/BepInEx.dll" />
<Reference Include="$(References)/UnityEngine.dll" />
<Reference Include="$(References)/Assembly-CSharp.dll" />
<Reference Include="$(References)/HOOKS-Assembly-CSharp.dll" />
<Reference Include="$(References)/MonoMod.Utils.dll" />
<Reference Include="$(References)/Mono.Cecil.dll" />
</ItemGroup>

</Project>

<!--Include a <ProjectName>.csproj.user file that looks like the following:
<Project>
<PropertyGroup>
<References>C:/path/to/your/references/folder</References>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetDir)$(TargetName)$(TargetExt)" DestinationFolder="C:/path/to/your/BepInEx/plugins/folder" />
</Target>
</Project>
-->
8 changes: 8 additions & 0 deletions MoreMice/MoreMice.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<References>../../_references</References>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetDir)$(TargetName)$(TargetExt)" DestinationFolder="D:/Games/Steam/steamapps/common/Rain World/BepInEx/plugins" />
</Target>
</Project>
70 changes: 70 additions & 0 deletions MoreMice/MoreMicePlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using BepInEx;
using Mono.Cecil.Cil;
using MonoMod.Cil;

namespace MoreMice;

[BepInPlugin("casheww.more_mice", "MoreMice", "0.1.0")]
public class MoreMicePlugin : BaseUnityPlugin
{
private void OnEnable()
{
On.WorldLoader.GeneratePopulation += WorldLoader_GeneratePopulation;
On.LanternMouse.GenerateIVars += LanternMouse_GenerateIVars;
On.StaticWorld.EstablishRelationship += StaticWorld_EstablishRelationship;
}

private void OnDisable()
{
On.WorldLoader.GeneratePopulation -= WorldLoader_GeneratePopulation;
On.LanternMouse.GenerateIVars -= LanternMouse_GenerateIVars;
On.StaticWorld.EstablishRelationship -= StaticWorld_EstablishRelationship;
}

private void WorldLoader_GeneratePopulation(On.WorldLoader.orig_GeneratePopulation orig, object self, bool fresh)
{
orig(self, fresh);

if (self is not WorldLoader wl)
return;

foreach (World.CreatureSpawner spawner in wl.spawners)
{
AbstractRoom abstractRoom = wl.world.GetAbstractRoom(spawner.den);

for (int i = 0; i < 16; i++)
{
if (UnityEngine.Random.value < 0.125f)
break;

abstractRoom.MoveEntityToDen(new AbstractCreature(
wl.world,
StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.LanternMouse),
null,
spawner.den,
wl.world.game.GetNewID()));
}
}
}

private void LanternMouse_GenerateIVars(On.LanternMouse.orig_GenerateIVars orig, LanternMouse self)
{
if (UnityEngine.Random.value < 0.5f)
{
HSLColor color = new HSLColor(UnityEngine.Random.value, 1f, 0.6f);
self.iVars = new LanternMouse.IndividualVariations(UnityEngine.Random.value, color);
}
else
orig(self);
}

private void StaticWorld_EstablishRelationship(On.StaticWorld.orig_EstablishRelationship orig,
CreatureTemplate.Type a, CreatureTemplate.Type b, CreatureTemplate.Relationship relationship)
{
if (a == CreatureTemplate.Type.LanternMouse && b == CreatureTemplate.Type.Slugcat)
orig(a, b, new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.PlaysWith, 0.4f));
else
orig(a, b, relationship);
}

}
94 changes: 94 additions & 0 deletions MoreOverseers/BehaveHooks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;

using UnityEngine;
using System.Collections.Generic;
using RWCustom;

namespace MoreOverseers
{
class BehaveHooks
{
public static void Apply()
{
On.RainWorldGame.Update += RainWorldGame_Update;
On.OverseerAbstractAI.AbstractBehavior += OverseerAbstractAI_AbstractBehavior;
On.OverseerAI.LikeOfPlayer += OverseerAI_LikeOfPlayer;
}
public static void UnApply()
{
On.RainWorldGame.Update -= RainWorldGame_Update;
On.OverseerAbstractAI.AbstractBehavior -= OverseerAbstractAI_AbstractBehavior;
On.OverseerAI.LikeOfPlayer -= OverseerAI_LikeOfPlayer;
}

static void RainWorldGame_Update(On.RainWorldGame.orig_Update orig, RainWorldGame self)
{
orig(self);

if (self.Players.Count < 1) return;

AbstractWorldEntity[] entities = self.world.offScreenDen.entitiesInDens.ToArray();

foreach (AbstractWorldEntity aEntity in entities)
{
if (aEntity is AbstractCreature aCreature && aCreature.creatureTemplate.type == CreatureTemplate.Type.Overseer)
{
OverseersPlugin.Logger_.LogInfo($"moving overseer {aCreature.ID} " +
$"from offscreen den to {self.Players[0].Room.name}");
aCreature.ChangeRooms(new WorldCoordinate(self.Players[0].Room.index, 1, 1, 0));

self.world.offScreenDen.entitiesInDens.Remove(aCreature);
}
}
}

static void OverseerAbstractAI_AbstractBehavior(On.OverseerAbstractAI.orig_AbstractBehavior orig,
OverseerAbstractAI self, int time)
{
if (self.world.singleRoomWorld && self.parent.pos.room == 0 ||
self.world.game.Players.Count == 0)
{
return;
}

int playerNum = 0;
self.targetCreature = self.world.game.Players[playerNum];

// occurs for newly spawned or unrealized overseers
if (self.parent.realizedCreature == null || self.lastRoom == new WorldCoordinate(0, 0, 0, 0))
{
OverseersPlugin.Logger_.LogInfo("overseer null or invalid OverseerAbstractAI.lastRoom");

if (self.targetCreature.Room.realizedRoom == null) return;

OverseersPlugin.Logger_.LogInfo(" ... so overseer will Move");

self.parent.Move(self.targetCreature.pos);
self.parent.RealizeInRoom();
}

else if (self.parent.Room != self.targetCreature.Room)
{
OverseersPlugin.Logger_.LogInfo($"overseer {self.parent.ID} " +
$"going to player {playerNum} in {self.targetCreature.Room.name}");

Overseer overseer = self.parent.realizedCreature as Overseer;

if (self.targetCreature.Room.realizedRoom.readyForAI)
{
OverseersPlugin.Logger_.LogWarning($"lastRoom : {self.lastRoom}");
overseer.TeleportingIntoRoom(self.targetCreature.Room.realizedRoom);
}
else
{
OverseersPlugin.Logger_.LogInfo($"room {self.targetCreature.Room.name} not ready for AI - dest NoPathing");
self.SetDestinationNoPathing(new WorldCoordinate(self.targetCreature.Room.index, 1, 1, 0), false);
}
}
}

static float OverseerAI_LikeOfPlayer(On.OverseerAI.orig_LikeOfPlayer orig, OverseerAI self, AbstractCreature player)
=> 1;

}
}
72 changes: 72 additions & 0 deletions MoreOverseers/BigBrothersAreWatchingYou.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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>{ACB9F0D1-8617-4805-88BB-8973B8889A09}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MoreOverseers</RootNamespace>
<AssemblyName>MoreOverseers</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">
<HintPath>..\..\safe\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\..\Games\Steam\steamapps\common\Rain World\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="ConfigMachine">
<HintPath>..\..\..\..\Games\Steam\steamapps\common\Rain World\BepInEx\plugins\ConfigMachine.dll</HintPath>
</Reference>
<Reference Include="HOOKS-Assembly-CSharp">
<HintPath>..\..\safe\HOOKS-Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="MonoMod.RuntimeDetour">
<HintPath>..\..\..\..\Games\Steam\steamapps\common\Rain World\BepInEx\core\MonoMod.RuntimeDetour.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>..\..\safe\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BehaveHooks.cs" />
<Compile Include="ConversationHooks.cs" />
<Compile Include="GraphicsHooks.cs" />
<Compile Include="OverseersPlugin.cs" />
<Compile Include="ConfigMenu.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpawnHooks.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y $(TargetPath) "D:\Games\Steam\steamapps\common\Rain World\Mods"</PostBuildEvent>
</PropertyGroup>
</Project>
Loading

0 comments on commit 56da7fe

Please sign in to comment.