static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started)
            {
                ReactorTask reactorTask = Object.FindObjectOfType <ReactorTask>();
                NoOxyTask   oxygenTask  = Object.FindObjectOfType <NoOxyTask>();
                if (reactorTask && ReactorSabotageShaking.GetValue() != 0)
                {
                    float reactorCountdown = reactorTask.reactor.Countdown;
                    __instance.PlayerCam.shakeAmount = ShakingValues[ReactorSabotageShaking.GetValue()];
                    __instance.PlayerCam.shakePeriod = 400;
                }
                else
                {
                    __instance.PlayerCam.shakeAmount = 0;
                    __instance.PlayerCam.shakePeriod = 0;
                }

                if (oxygenTask && OxygenSabotageSlowdown.GetValue())
                {
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        player.MyPhysics.Speed = Math.Max(1.5f,
                                                          Math.Min(2.5f,
                                                                   2.5f * oxygenTask.reactor.Countdown / oxygenTask.reactor.LifeSuppDuration));
                    }
                }
                else
                {
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        player.MyPhysics.Speed = 2.5f;
                    }
                }
            }
        }
Beispiel #2
0
        public bool PreBuild(MapAsset asset)
        {
            if (!SAB_SYSTEMS.ContainsKey(asset.type))
            {
                return(true);
            }
            SystemTypes sys = SAB_SYSTEMS[asset.type];

            // GameObject
            SabData    sabData = AssetDB.sabs[asset.type];
            GameObject obj     = new GameObject(asset.type);

            // Sprite Renderer
            SpriteRenderer spriteRenderer = obj.AddComponent <SpriteRenderer>();

            spriteRenderer.sprite   = sabData.SpriteRenderer.sprite;
            spriteRenderer.material = sabData.SpriteRenderer.material;
            obj.layer = (int)Layer.ShortObjects;

            // Console
            Console origConsole = sabData.GameObj.GetComponent <Console>();
            Console console     = obj.AddComponent <Console>();

            console.ConsoleId      = origConsole.ConsoleId;
            console.AllowImpostor  = true;
            console.checkWalls     = false;
            console.GhostsIgnored  = true;
            console.Image          = spriteRenderer;
            console.onlyFromBelow  = false;
            console.onlySameRoom   = false;
            console.usableDistance = 1;
            console.Room           = sys;
            console.TaskTypes      = origConsole.TaskTypes;
            console.ValidTasks     = origConsole.ValidTasks;

            polus.shipStatus.AllConsoles = AssetHelper.AddToArr(polus.shipStatus.AllConsoles, console);

            // Box Collider
            if (sabData.GameObj.GetComponent <CircleCollider2D>() != null)
            {
                CircleCollider2D origBox = sabData.GameObj.GetComponent <CircleCollider2D>();
                CircleCollider2D box     = obj.AddComponent <CircleCollider2D>();
                box.radius    = origBox.radius;
                box.offset    = origBox.offset;
                box.isTrigger = true;
            }
            else if (sabData.GameObj.GetComponent <BoxCollider2D>() != null)
            {
                BoxCollider2D origBox = sabData.GameObj.GetComponent <BoxCollider2D>();
                BoxCollider2D box     = obj.AddComponent <BoxCollider2D>();
                box.size      = origBox.size;
                box.offset    = origBox.offset;
                box.isTrigger = true;
            }
            else if (sabData.GameObj.GetComponent <PolygonCollider2D>() != null)
            {
                PolygonCollider2D origBox = sabData.GameObj.GetComponent <PolygonCollider2D>();
                PolygonCollider2D box     = obj.AddComponent <PolygonCollider2D>();
                box.points    = origBox.points;
                box.pathCount = origBox.pathCount;
                box.offset    = origBox.offset;
                box.isTrigger = true;
            }

            // Task
            SabotageTask task      = null;
            StringNames  name      = StringNames.ExitButton;
            GameObject   sabHolder = new GameObject(asset.id.ToString());

            sabHolder.transform.SetParent(sabMgr.transform);
            if (asset.type == "sab-comms")
            {
                task = sabHolder.AddComponent <HudOverrideTask>();
                HudOverrideTask castTask  = task.Cast <HudOverrideTask>();
                HudOverrideTask taskClone = sabData.Behavior.Cast <HudOverrideTask>();

                castTask.even       = taskClone.even;
                castTask.isComplete = taskClone.isComplete;
                castTask.system     = polus.shipStatus.Systems[sys].Cast <HudOverrideSystemType>();

                name = StringNames.FixComms;
            }
            else if (asset.type == "sab-electric")
            {
                task = sabHolder.AddComponent <ElectricTask>();
                ElectricTask castTask  = task.Cast <ElectricTask>();
                ElectricTask taskClone = sabData.Behavior.Cast <ElectricTask>();

                castTask.even       = taskClone.even;
                castTask.isComplete = taskClone.isComplete;
                castTask.system     = polus.shipStatus.Systems[sys].Cast <SwitchSystem>();

                name = StringNames.FixLights;
            }
            else if (asset.type == "sab-reactorleft")
            {
                task = sabHolder.AddComponent <ReactorTask>();
                ReactorTask castTask  = task.Cast <ReactorTask>();
                ReactorTask taskClone = sabData.Behavior.Cast <ReactorTask>();

                castTask.even       = taskClone.even;
                castTask.isComplete = taskClone.isComplete;
                castTask.reactor    = polus.shipStatus.Systems[sys].Cast <ICriticalSabotage>();

                name = StringNames.Laboratory;
            }
            if (name != StringNames.ExitButton)
            {
                SabotageTask origTask = sabData.Behavior.Cast <SabotageTask>();
                task.Arrows         = new UnhollowerBaseLib.Il2CppReferenceArray <ArrowBehaviour>(2);
                task.Arrows[0]      = sabArrow1;
                task.Arrows[1]      = sabArrow2;
                task.didContribute  = origTask.didContribute;
                task.Id             = origTask.Id;
                task.Index          = origTask.Index;
                task.LocationDirty  = origTask.LocationDirty;
                task.HasLocation    = origTask.HasLocation;
                task.MinigamePrefab = origTask.MinigamePrefab;
                task.StartAt        = sys;
                task.TaskType       = origTask.TaskType;
                task.Owner          = PlayerControl.LocalPlayer;

                polus.shipStatus.SpecialTasks = AssetHelper.AddToArr(polus.shipStatus.SpecialTasks, task);
                List <StringNames> list = new List <StringNames>(polus.shipStatus.SystemNames);
                list.Add(name);
                polus.shipStatus.SystemNames = list.ToArray();
                SabGenerator.AddSabotage(asset);
            }

            // Add to Polus
            AssetHelper.BuildColliders(asset, obj);
            polus.Add(obj, asset);

            return(true);
        }
Beispiel #3
0
 public static void Prefix(ReactorTask __instance)
 {
     __instance.StartAt = SystemTypes.Laboratory;
 }