diff --git a/.idea/.idea.MMOKitchen.dir/.idea/vcs.xml b/.idea/.idea.MMOKitchen.dir/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.MMOKitchen.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Changelogs/Github/v0.3.3.MD b/Changelogs/Github/v0.3.3.MD new file mode 100644 index 0000000..2afaadb --- /dev/null +++ b/Changelogs/Github/v0.3.3.MD @@ -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. \ No newline at end of file diff --git a/Changelogs/Workshop/v0.3.2.MD b/Changelogs/Workshop/v0.3.2.MD new file mode 100644 index 0000000..0117e2f --- /dev/null +++ b/Changelogs/Workshop/v0.3.2.MD @@ -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. \ No newline at end of file diff --git a/Mod.cs b/Mod.cs index bceb390..57d1248 100644 --- a/Mod.cs +++ b/Mod.cs @@ -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"; diff --git a/Patches/CreateBedroomsPatch.cs b/Patches/CreateBedroomsPatch.cs new file mode 100644 index 0000000..b08eb3b --- /dev/null +++ b/Patches/CreateBedroomsPatch.cs @@ -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("Players"); + EntityQuery Players = (EntityQuery)_Players.GetValue(__instance); + NativeArray players = Players.ToEntityArray(Allocator.Temp); + + foreach (Entity player in players) + { + if (PatchHelpers.instance._GetComponent(player).Index > 3) + { + PatchHelpers.instance._SetComponentData(player, new CPosition(LobbyPositionAnchors.Office + new Vector3(0,0,-2))); + } + } + + players.Dispose(); + } + } +} \ No newline at end of file diff --git a/Patches/SessionPatch.cs b/Patches/SessionPatch.cs new file mode 100644 index 0000000..416327a --- /dev/null +++ b/Patches/SessionPatch.cs @@ -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 Transpiler(IEnumerable 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(); + } + } +} \ No newline at end of file diff --git a/Systems/GlobalCosmeticEditors.cs b/Systems/GlobalCosmeticEditors.cs new file mode 100644 index 0000000..9030c32 --- /dev/null +++ b/Systems/GlobalCosmeticEditors.cs @@ -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; + } +} \ No newline at end of file diff --git a/Systems/GlobalProfileEditors.cs b/Systems/GlobalProfileEditors.cs new file mode 100644 index 0000000..0578b52 --- /dev/null +++ b/Systems/GlobalProfileEditors.cs @@ -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(data.Interactor) && Has(data.Target) && Has(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 + }); + } + } +} \ No newline at end of file diff --git a/Systems/PatchHelpers.cs b/Systems/PatchHelpers.cs new file mode 100644 index 0000000..8a1baa3 --- /dev/null +++ b/Systems/PatchHelpers.cs @@ -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(Entity entity) where T : struct, IComponentData + { + return GetComponent(entity); + } + + public void _SetComponentData(Entity entity, T componentData) where T : struct, IComponentData + { + EntityManager.SetComponentData(entity, componentData); + } + + protected override void Initialise() + { + instance = this; + } + + protected override void OnUpdate() + { + } + } +} \ No newline at end of file diff --git a/Systems/ProfileEditorOverride.cs b/Systems/ProfileEditorOverride.cs index 7a99267..03d477c 100644 --- a/Systems/ProfileEditorOverride.cs +++ b/Systems/ProfileEditorOverride.cs @@ -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) {