Exemplo n.º 1
0
        public static bool Prefix([HarmonyArgument(0)] byte CallId, [HarmonyArgument(1)] MessageReader reader)
        {
            if (CallId == (byte)CustomRPC.SetSpawnAirship)
            {
                List <byte> spawnPoints = reader.ReadBytesAndSize().ToList();
                SpawnInMinigamePatch.SpawnPoints = spawnPoints;

                return(false);
            }

            if (CallId == (byte)CustomRPC.DoorSyncToilet)
            {
                int Id = reader.ReadInt32();

                PlainDoor DoorToSync = Object.FindObjectsOfType <PlainDoor>().FirstOrDefault(door => door.Id == Id);
                DoorToSync.SetDoorway(true);

                return(false);
            }

            if (CallId == (byte)CustomRPC.SyncPlateform)
            {
                bool isLeft = reader.ReadBoolean();
                CallPlateform.SyncPlateform(isLeft);

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
            public static void Postfix(KeyboardJoystick __instance)
            {
                if (!PlayerControl.LocalPlayer.isRole(RoleType.Puppeteer))
                {
                    return;
                }

                if (stealthed)
                {
                    // 梯子を使う/ドアを開ける
                    if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.Space))
                    {
                        PlainDoor[] doors;
                        if (PlayerControl.GameOptions.MapId == 4)
                        {
                            doors = DestroyableSingleton <AirshipStatus> .Instance.GetComponentsInChildren <PlainDoor>();
                        }
                        else if (PlayerControl.GameOptions.MapId == 2)
                        {
                            doors = DestroyableSingleton <PolusShipStatus> .Instance.GetComponentsInChildren <PlainDoor>();
                        }
                        else if (PlayerControl.GameOptions.MapId == 1)
                        {
                            doors = DestroyableSingleton <MiraShipStatus> .Instance.GetComponentsInChildren <PlainDoor>();
                        }
                        else if (SubmergedCompatibility.isSubmerged())
                        {
                            // 遅いかも
                            doors = UnityEngine.GameObject.FindObjectsOfType <PlainDoor>();
                        }
                        else
                        {
                            doors = DestroyableSingleton <SkeldShipStatus> .Instance.GetComponentsInChildren <PlainDoor>();
                        }
                        PlainDoor t           = null;
                        float     minDistance = 9999;
                        foreach (var door in doors)
                        {
                            float distance = Vector2.Distance(door.transform.position, dummy.transform.position);
                            if (distance < 1.5f && distance < minDistance)
                            {
                                t           = door;
                                minDistance = distance;
                            }
                        }
                        if (t != null)
                        {
                            var deconSystem = t.transform.parent.gameObject.GetComponent <DeconSystem>();
                            if (deconSystem != null)
                            {
                                bool flag = true;
                                if (PlayerControl.GameOptions.MapId == 2)
                                {
                                    flag = t.name.Contains("Inner");
                                }
                                else if (SubmergedCompatibility.isSubmerged())
                                {
                                    flag = t.name.Contains("Upper");
                                }
                                var          consoles = t.GetComponentsInChildren <DeconControl>();
                                DeconControl inner    = null;
                                DeconControl outer    = null;
                                foreach (var console in consoles)
                                {
                                    if (console.name == "InnerConsole")
                                    {
                                        inner = console;
                                    }
                                    if (console.name == "OuterConsole")
                                    {
                                        outer = console;
                                    }
                                }
                                float distOuter = Vector2.Distance(outer.transform.position, dummy.transform.position);
                                float distInner = Vector2.Distance(inner.transform.position, dummy.transform.position);
                                if (distInner < distOuter)
                                {
                                    deconSystem.OpenFromInside(flag);
                                }
                                else
                                {
                                    deconSystem.OpenDoor(flag);
                                }
                            }
                            else
                            {
                                DestroyableSingleton <ShipStatus> .Instance.RpcRepairSystem(SystemTypes.Doors, t.Id | 64);

                                t.SetDoorway(true);
                            }
                        }


                        if (PlayerControl.GameOptions.MapId == 4)
                        {
                            Ladder[] ladders = DestroyableSingleton <AirshipStatus> .Instance.GetComponentsInChildren <Ladder>();

                            Ladder target = null;
                            foreach (var ladder in ladders)
                            {
                                float distance = Vector2.Distance(ladder.transform.position, dummy.transform.position);
                                if (distance < 0.5f)
                                {
                                    target = ladder;
                                    break;
                                }
                            }
                            if (target != null)
                            {
                                MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PuppeteerClimbRadder, Hazel.SendOption.Reliable, -1);
                                messageWriter.Write(dummy.PlayerId);
                                messageWriter.Write(target.Id);
                                AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
                                RPCProcedure.puppeteerClimbRadder(dummy.PlayerId, target.Id);
                            }
                        }

                        // エレベーター(サブマージド)
                        if (SubmergedCompatibility.isSubmerged())
                        {
                            var    elevators = Helpers.FindObjectsOfType(SubmarineElevatorType);
                            object elevator  = null;
                            minDistance = 9999;
                            foreach (var e in elevators)
                            {
                                var       pos = (e as UnityEngine.MonoBehaviour).transform.position;
                                FieldInfo lowerInnerDoorInfo = SubmarineElevatorType.GetField("LowerInnerDoor");
                                FieldInfo upperInnerDoorInfo = SubmarineElevatorType.GetField("UpperInnerDoor");
                                var       lowerInnerDoor     = lowerInnerDoorInfo.GetValue(e) as PlainDoor;
                                var       upperInnerDoor     = upperInnerDoorInfo.GetValue(e) as PlainDoor;
                                float     lowerDistance      = Vector2.Distance(dummy.transform.position, lowerInnerDoor.transform.position);
                                float     upperDistance      = Vector2.Distance(dummy.transform.position, upperInnerDoor.transform.position);
                                float     distance           = lowerDistance < upperDistance ? lowerDistance : upperDistance;
                                if (distance < 1.5 && distance < minDistance)
                                {
                                    minDistance = distance;
                                    elevator    = e;
                                }
                            }
                            if (elevator != null)
                            {
                                var use = SubmarineElevatorType.GetMethod("Use");
                                use.Invoke(elevator, new object[0]);
                            }
                        }
                    }

                    if (Input.GetKeyDown(KeyCode.D))
                    {
                        right = true;
                    }
                    if (Input.GetKeyUp(KeyCode.D))
                    {
                        right = false;
                    }
                    if (Input.GetKeyDown(KeyCode.A))
                    {
                        left = true;
                    }
                    if (Input.GetKeyUp(KeyCode.A))
                    {
                        left = false;
                    }
                    if (Input.GetKeyDown(KeyCode.W))
                    {
                        up = true;
                    }
                    if (Input.GetKeyUp(KeyCode.W))
                    {
                        up = false;
                    }
                    if (Input.GetKeyDown(KeyCode.S))
                    {
                        down = true;
                    }
                    if (Input.GetKeyUp(KeyCode.S))
                    {
                        down = false;
                    }

                    if (Puppeteer.dummy != null)
                    {
                        Vector2 pos    = Puppeteer.dummy.transform.position;
                        Vector2 offset = Vector2.zero;
                        if (up)
                        {
                            offset += new Vector2(0f, 0.5f);
                        }
                        if (down)
                        {
                            offset += new Vector2(0f, -0.5f);
                        }
                        if (left)
                        {
                            offset += new Vector2(-0.5f, 0.0f);
                        }
                        if (right)
                        {
                            offset += new Vector2(0.5f, 0.0f);
                        }
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.WalkDummy, Hazel.SendOption.Reliable, -1);
                        writer.Write(offset.x);
                        writer.Write(offset.y);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.walkDummy(offset);
                        if (!(up || down || right || left))
                        {
                            writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MoveDummy, Hazel.SendOption.Reliable, -1);
                            writer.Write(Puppeteer.dummy.transform.position.x);
                            writer.Write(Puppeteer.dummy.transform.position.y);
                            writer.Write(Puppeteer.dummy.transform.position.z);
                            writer.Write(false);
                            AmongUsClient.Instance.FinishRpcImmediately(writer);
                            // RPCProcedure.moveDummy(Puppeteer.dummy.transform.position);
                        }
                    }
                }
            }
Exemplo n.º 3
0
        static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
        {
            byte packetId = callId;

            switch (packetId)
            {
            // Main Controls

            case (byte)CustomRPC.ResetVaribles:
                RPCProcedure.resetVariables();
                break;

            case (byte)CustomRPC.ShareOptionSelection:
                uint id        = reader.ReadPackedUInt32();
                uint selection = reader.ReadPackedUInt32();
                RPCProcedure.shareOptionSelection(id, selection);
                break;

            case (byte)CustomRPC.ForceEnd:
                RPCProcedure.forceEnd();
                break;

            case (byte)CustomRPC.SetRole:
                byte roleId   = reader.ReadByte();
                byte playerId = reader.ReadByte();
                RPCProcedure.setRole(roleId, playerId);
                break;

            case (byte)CustomRPC.SetUncheckedColor:
                byte c = reader.ReadByte();
                byte p = reader.ReadByte();
                RPCProcedure.setUncheckedColor(c, p);
                break;

            case (byte)CustomRPC.VersionHandshake:
                byte major          = reader.ReadByte();
                byte minor          = reader.ReadByte();
                byte patch          = reader.ReadByte();
                int  versionOwnerId = reader.ReadPackedInt32();
                RPCProcedure.versionHandshake(major, minor, patch, versionOwnerId);
                break;

            case (byte)CustomRPC.UseUncheckedVent:
                int  ventId        = reader.ReadPackedInt32();
                byte ventingPlayer = reader.ReadByte();
                byte isEnter       = reader.ReadByte();
                RPCProcedure.useUncheckedVent(ventId, ventingPlayer, isEnter);
                break;

            case (byte)CustomRPC.UncheckedMurderPlayer:
                byte source = reader.ReadByte();
                byte target = reader.ReadByte();
                RPCProcedure.uncheckedMurderPlayer(source, target);
                break;

            // Fixes

            case (byte)CustomRPC.OpenToiletDoor:
                int       doorId = reader.ReadInt32();
                PlainDoor door   = UnityEngine.Object.FindObjectsOfType <PlainDoor>().FirstOrDefault(door => door.Id == doorId);
                door.SetDoorway(true);
                break;

            // Role functionality

            case (byte)CustomRPC.EngineerFixLights:
                RPCProcedure.engineerFixLights();
                break;

            case (byte)CustomRPC.EngineerUsedRepair:
                RPCProcedure.engineerUsedRepair();
                break;

            case (byte)CustomRPC.CleanBody:
                RPCProcedure.cleanBody(reader.ReadByte());
                break;

            case (byte)CustomRPC.SheriffKill:
                RPCProcedure.sheriffKill(reader.ReadByte());
                break;

            case (byte)CustomRPC.TimeMasterRewindTime:
                RPCProcedure.timeMasterRewindTime();
                break;

            case (byte)CustomRPC.TimeMasterShield:
                RPCProcedure.timeMasterShield();
                break;

            case (byte)CustomRPC.MedicSetShielded:
                RPCProcedure.medicSetShielded(reader.ReadByte());
                break;

            case (byte)CustomRPC.ShieldedMurderAttempt:
                RPCProcedure.shieldedMurderAttempt();
                break;

            case (byte)CustomRPC.ShifterShift:
                RPCProcedure.shifterShift(reader.ReadByte());
                break;

            case (byte)CustomRPC.SwapperSwap:
                byte playerId1 = reader.ReadByte();
                byte playerId2 = reader.ReadByte();
                RPCProcedure.swapperSwap(playerId1, playerId2);
                break;

            case (byte)CustomRPC.MorphlingMorph:
                RPCProcedure.morphlingMorph(reader.ReadByte());
                break;

            case (byte)CustomRPC.CamouflagerCamouflage:
                RPCProcedure.camouflagerCamouflage();
                break;

            case (byte)CustomRPC.LoverSuicide:
                RPCProcedure.loverSuicide(reader.ReadByte());
                break;

            case (byte)CustomRPC.VampireSetBitten:
                byte bittenId = reader.ReadByte();
                byte reset    = reader.ReadByte();
                RPCProcedure.vampireSetBitten(bittenId, reset);
                break;

            case (byte)CustomRPC.VampireTryKill:
                RPCProcedure.vampireTryKill();
                break;

            case (byte)CustomRPC.PlaceGarlic:
                RPCProcedure.placeGarlic(reader.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.TrackerUsedTracker:
                RPCProcedure.trackerUsedTracker(reader.ReadByte());
                break;

            case (byte)CustomRPC.JackalKill:
                RPCProcedure.jackalKill(reader.ReadByte());
                break;

            case (byte)CustomRPC.SidekickKill:
                RPCProcedure.sidekickKill(reader.ReadByte());
                break;

            case (byte)CustomRPC.JackalCreatesSidekick:
                RPCProcedure.jackalCreatesSidekick(reader.ReadByte());
                break;

            case (byte)CustomRPC.SidekickPromotes:
                RPCProcedure.sidekickPromotes();
                break;

            case (byte)CustomRPC.ErasePlayerRole:
                RPCProcedure.erasePlayerRole(reader.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureErased:
                RPCProcedure.setFutureErased(reader.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureShifted:
                RPCProcedure.setFutureShifted(reader.ReadByte());
                break;

            case (byte)CustomRPC.PlaceJackInTheBox:
                RPCProcedure.placeJackInTheBox(reader.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.LightsOut:
                RPCProcedure.lightsOut();
                break;

            case (byte)CustomRPC.WarlockCurseKill:
                RPCProcedure.warlockCurseKill(reader.ReadByte());
                break;

            case (byte)CustomRPC.PlaceCamera:
                RPCProcedure.placeCamera(reader.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.SealVent:
                RPCProcedure.sealVent(reader.ReadPackedInt32());
                break;

            case (byte)CustomRPC.ArsonistWin:
                RPCProcedure.arsonistWin();
                break;
            }
        }