This commit is contained in:
Lachlan Leone
2024-10-09 16:41:33 +11:00
parent 9f4ef51d41
commit 4259b35697
10 changed files with 177 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+4
View File
@@ -0,0 +1,4 @@
# Release Notes v0.3.2
- Fixed a bug preventing some players from being teleported in the lobby when they don't have a bedroom.
- Fixed a bug preventing players from sharing profile editor beds.
+4
View File
@@ -0,0 +1,4 @@
[h1]Release Notes v0.3.2[/h1]
- Fixed a bug preventing some players from being teleported in the lobby when they don't have a bedroom.
- Fixed a bug preventing players from sharing profile editor beds.
+1 -2
View File
@@ -1,5 +1,4 @@
using KitchenLib;
using KitchenLib.Logging;
using KitchenMods;
using System.Reflection;
using Kitchen;
@@ -14,7 +13,7 @@ namespace MMOKitchen
{
public const string MOD_GUID = "com.starfluxgames.mmokitchen";
public const string MOD_NAME = "MMO Kitchen";
public const string MOD_VERSION = "0.3.1";
public const string MOD_VERSION = "0.3.2";
public const string MOD_AUTHOR = "StarFluxGames";
public const string MOD_GAMEVERSION = ">=1.2.0";
+32
View File
@@ -0,0 +1,32 @@
using System.Reflection;
using HarmonyLib;
using Kitchen;
using KitchenLib.Utils;
using MMOKitchen.Systems;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
namespace MMOKitchen.Patches
{
[HarmonyPatch(typeof(CreateBedrooms), "OnUpdate")]
public class CreateBedroomsPatch
{
static void Postfix(CreateBedrooms __instance)
{
FieldInfo _Players = ReflectionUtils.GetField<CreateBedrooms>("Players");
EntityQuery Players = (EntityQuery)_Players.GetValue(__instance);
NativeArray<Entity> players = Players.ToEntityArray(Allocator.Temp);
foreach (Entity player in players)
{
if (PatchHelpers.instance._GetComponent<CPlayer>(player).Index > 3)
{
PatchHelpers.instance._SetComponentData(player, new CPosition(LobbyPositionAnchors.Office + new Vector3(0,0,-2)));
}
}
players.Dispose();
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.Reflection.Emit;
using HarmonyLib;
using Kitchen;
namespace MMOKitchen.Patches
{
[HarmonyPatch(typeof(Session), "GetInvite")]
public class SessionPatch
{
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
CodeMatcher matcher = new(instructions);
matcher.MatchForward(false, new CodeMatch(OpCodes.Ldloca_S), new CodeMatch(OpCodes.Ldc_I4_3), new CodeMatch(OpCodes.Ldc_I4_4))
.Advance(2)
.Set(OpCodes.Ldc_I4, Mod.MaxPlayers);
return matcher.InstructionEnumeration();
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using Kitchen;
using KitchenLib.References;
using KitchenMods;
namespace MMOKitchen.Systems
{
public class GlobalCosmeticEditors : InteractionSystem, IModSystem
{
protected override bool AllowActOrGrab => true;
protected override bool ShouldAct(ref InteractionData data)
{
if (!Require(data.Target, out Editor))
{
return false;
}
bool flag = data.Attempt.Type == InteractionType.Grab;
bool flag2 = base.ShouldAct(ref data);
return Editor.UseGrab == flag && flag2;
}
protected override bool IsPossible(ref InteractionData data)
{
return Require(data.Target, out Editor) && Require(data.Target, out CAppliance cAppliance) && cAppliance.ID == ApplianceReferences.BedroomOutfitSelector;
}
protected override void Perform(ref InteractionData data)
{
Editor.IsTriggered = true;
Editor.TriggerEntity = data.Interactor;
SetComponent(data.Target, Editor);
}
private CTriggerPlayerSpecificUI Editor;
}
}
+39
View File
@@ -0,0 +1,39 @@
using Kitchen;
using KitchenMods;
using Unity.Entities;
using UnityEngine;
namespace MMOKitchen.Systems
{
public class GlobalProfileEditors : InteractionSystem, IModSystem
{
protected override bool IsPossible(ref InteractionData data)
{
return Has<CPlayer>(data.Interactor) && Has<ManageProfileEditors.COpensProfileEditor>(data.Target) && Has<CPosition>(data.Target) && Require(data.Target, out COwnedByPlayer cOwnedByPlayer) && cOwnedByPlayer.Player != data.Interactor;
}
protected override void Perform(ref InteractionData data)
{
if (!Require(data.Target, out CPosition cPosition)) return;
if (!Require(data.Interactor, out CPlayer cPlayer)) return;
Entity entity = EntityManager.CreateEntity();
EntityManager.AddComponentData(entity, new CPosition(cPosition + new Vector3(-2f, 1f, 0f)));
EntityManager.AddComponentData(entity, new CRequiresView
{
Type = ViewType.ProfileEditor,
ViewMode = ViewMode.WorldToScreen
});
EntityManager.AddComponentData(entity, new ManageProfileEditors.CProfileEditor
{
Trigger = data.Target,
PlayerID = cPlayer.ID,
Player = data.Interactor
});
EntityManager.AddComponentData(data.Target, new ManageProfileEditors.CHasProfileEditor
{
Editor = entity
});
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using Kitchen;
using KitchenMods;
using Unity.Entities;
namespace MMOKitchen.Systems
{
public class PatchHelpers : GameSystemBase, IModSystem
{
public static PatchHelpers instance;
public T _GetComponent<T>(Entity entity) where T : struct, IComponentData
{
return GetComponent<T>(entity);
}
public void _SetComponentData<T>(Entity entity, T componentData) where T : struct, IComponentData
{
EntityManager.SetComponentData<T>(entity, componentData);
}
protected override void Initialise()
{
instance = this;
}
protected override void OnUpdate()
{
}
}
}
+1 -2
View File
@@ -1,9 +1,8 @@
using Kitchen;
using KitchenMods;
namespace MMOKitchen.Systems
{
public class ProfileEditorOverride : InteractionSystem, IModSystem
public class ProfileEditorOverride : InteractionSystem
{
protected override bool IsPossible(ref InteractionData data)
{