protected override void OnSpawn()
    {
        base.OnSpawn();
        OverlayScreen instance = OverlayScreen.Instance;

        instance.OnOverlayChanged = (Action <HashedString>)Delegate.Combine(instance.OnOverlayChanged, new Action <HashedString>(OnOverlayChanged));
    }
    protected override void OnCleanUp()
    {
        OverlayScreen instance = OverlayScreen.Instance;

        instance.OnOverlayChanged = (Action <HashedString>)Delegate.Remove(instance.OnOverlayChanged, new Action <HashedString>(OnOverlayChanged));
        base.OnCleanUp();
    }
 private static void ToggleOverlayWrapper(OverlayScreen instance, HashedString newMode, bool allowSound)
 {
     if (Options.Opts.Overlay == Options.ClickNum.One)
     {
         instance.ToggleOverlay(newMode, allowSound);
     }
 }
Esempio n. 4
0
 protected override void OnLoadLevel()
 {
     harvestableNotificationPrefab = null;
     powerLabelParent = null;
     Instance         = null;
     OverlayModes.Mode.Clear();
     modeInfos       = null;
     currentModeInfo = default(ModeInfo);
     base.OnLoadLevel();
 }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        cell = -1;
        OverlayScreen instance = OverlayScreen.Instance;

        instance.OnOverlayChanged = (Action <HashedString>)Delegate.Combine(instance.OnOverlayChanged, new Action <HashedString>(OnOverlayChanged));
        OnOverlayChanged(OverlayScreen.Instance.mode);
        Subscribe(-1643076535, OnRotatedDelegate);
    }
Esempio n. 6
0
 public void ChangeCurrentActiveScreen(OverlayScreen screen = null)
 {
     if (_currentActiveScreen != null)
     {
         _currentActiveScreen.SetVisibility(false);
     }
     if (screen != null)
     {
         screen.SetVisibility(true);
     }
     _currentActiveScreen = screen;
 }
Esempio n. 7
0
    protected override void OnCleanUp()
    {
        OverlayScreen instance = OverlayScreen.Instance;

        instance.OnOverlayChanged = (Action <HashedString>)Delegate.Remove(instance.OnOverlayChanged, new Action <HashedString>(OnOverlayChanged));
        DestroyVisualizers();
        if (isPhysical)
        {
            DestroyPhysicalPorts();
        }
        base.OnCleanUp();
    }
 // add our overlay screen to the list of overlays
 public static void Postfix(OverlayScreen __instance)
 {
     AccessTools
     .Method(
         typeof(OverlayScreen),
         "RegisterMode",
         new Type[] { typeof(OverlayModes.Mode) }
         )
     .Invoke(
         __instance,
         new object[] { new Network.SignalOverlayMode() }
         );
 }
    protected override void OnCleanUp()
    {
        OverlayScreen instance = OverlayScreen.Instance;

        instance.OnOverlayChanged = (Action <HashedString>)Delegate.Remove(instance.OnOverlayChanged, new Action <HashedString>(OnViewModeChanged));
        base.OnCleanUp();
        Components.DiseaseSourceVisualizers.Remove(this);
        if ((UnityEngine.Object)visualizer != (UnityEngine.Object)null)
        {
            UnityEngine.Object.Destroy(visualizer);
            visualizer = null;
        }
    }
Esempio n. 10
0
        public void ReceiveMessage(NetIncomingMessage msg)
        {
            if (overlay != null && overlay.TakeControl && overlay is ICanReceive ics)
            {
                ics.ReceiveMessage(msg);
            }
            else
            {
                var messageType = (MessageType)msg.ReadByte();

                if (messageType == MessageType.RESIGN)
                {
                    var optionOverlay = new OptionsOverlay("Your opponent requested to quit the game." + Environment.NewLine + Environment.NewLine + "Do you accept?", new string[] { "Yes", "No" });
                    optionOverlay.action += (string ret) =>
                    {
                        var newMsg = Networking.CreateMessage();
                        newMsg.Write((byte)MainScreen.Side.GAME_SIDE);

                        if (ret == "Yes")
                        {
                            newMsg.Write(true);

                            if (Networking.IsServer)
                            {
                                mainScreen.gameSide = new GameChoose(mainScreen);
                            }
                            else
                            {
                                mainScreen.gameSide = new WaitForChoose(mainScreen);
                            }
                        }
                        else
                        {
                            newMsg.Write(false);
                        }


                        Networking.SendMessage(newMsg);
                    };

                    overlay = optionOverlay;
                }
                else
                {
                    RelayMessage2(msg);
                }
            }
        }
Esempio n. 11
0
        public BoredGame(MainScreen _mainScreen, int _seed)
        {
            mainScreen = _mainScreen;
            seed       = _seed;

            Button resignBtn = new Button(this)
            {
                Position = new Point(412, 512),
                Size     = new Point(100, 50),
                Font     = Main.MediumFont,
                Text     = "Quit Game"
            };

            resignBtn.ClickEvent += (object s) =>
            {
                resignBtn.active = false;

                var msg = Networking.CreateMessage();
                msg.Write((byte)MainScreen.Side.GAME_SIDE);
                msg.Write((byte)MessageType.RESIGN);
                Networking.SendMessage(msg);

                var wait = new WaitingOverlay("You requested to quit the game. Waiting for a response...");

                wait.action += (bool quit) =>
                {
                    if (quit)
                    {
                        if (Networking.IsServer)
                        {
                            mainScreen.gameSide = new GameChoose(mainScreen);
                        }
                        else
                        {
                            mainScreen.gameSide = new WaitForChoose(mainScreen);
                        }
                    }
                    else
                    {
                        resignBtn.active = true;
                    }
                };

                overlay = wait;
            };

            components.Add(resignBtn);
        }
Esempio n. 12
0
        public void GameEnd(string message)
        {
            if (Networking.IsServer)
            {
                var yesNo = new OptionsOverlay(message + Environment.NewLine + Environment.NewLine + "Play again?", new string[] { "Yes", "No" });
                yesNo.action += (string s) =>
                {
                    var msg = Networking.CreateMessage();
                    msg.Write((byte)MainScreen.Side.GAME_SIDE);

                    if (s == "Yes")
                    {
                        msg.Write(true);

                        ResetGame();
                    }
                    else
                    {
                        msg.Write(false);

                        mainScreen.gameSide = new GameChoose(mainScreen);
                    }

                    Networking.SendMessage(msg);
                };
                overlay = yesNo;
            }
            else
            {
                var waiting = new WaitingOverlay(message + Environment.NewLine + Environment.NewLine + "Waiting for host to make a decision...");

                waiting.action += (bool s) =>
                {
                    if (s)
                    {
                        ResetGame();
                        //overlay = null;
                    }
                    else
                    {
                        mainScreen.gameSide = new WaitForChoose(mainScreen);
                    }
                };

                overlay = waiting;
            }
        }
Esempio n. 13
0
        public override void Update(GameTime gameTime)
        {
            if (overlay != null)
            {
                overlay.Update(gameTime);
                if (overlay.Finished)
                {
                    overlay = null;
                }
            }

            if (overlay == null || !overlay.TakeControl)
            {
                base.Update(gameTime);

                AfterUpdate(gameTime);
            }
        }
Esempio n. 14
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     isPhysical = ((UnityEngine.Object)GetComponent <BuildingComplete>() != (UnityEngine.Object)null);
     if (!isPhysical && (UnityEngine.Object)GetComponent <BuildingUnderConstruction>() == (UnityEngine.Object)null)
     {
         OverlayScreen instance = OverlayScreen.Instance;
         instance.OnOverlayChanged = (Action <HashedString>)Delegate.Combine(instance.OnOverlayChanged, new Action <HashedString>(OnOverlayChanged));
         OnOverlayChanged(OverlayScreen.Instance.mode);
         CreateVisualizers();
         SimAndRenderScheduler.instance.Add(this, false);
     }
     else if (isPhysical)
     {
         UpdateMissingWireIcon();
         CreatePhysicalPorts();
     }
     else
     {
         CreateVisualizers();
     }
 }
Esempio n. 15
0
 public void SetParentScreen(OverlayScreen parentScreen)
 {
     ParentScreen = parentScreen;
 }
Esempio n. 16
0
 public static void Postfix(OverlayScreen __instance)
 {
     Traverse.Create(__instance).Method("RegisterMode", new MapOverlay()).GetValue();
 }
Esempio n. 17
0
 public void ToggleOverlayScreen(OverlayScreen overlayScreen)
 {
     overlayScreen.SetVisibility(!overlayScreen.IsVisible);
 }
Esempio n. 18
0
            public static void Prefix(HashedString newMode, ref OverlayScreen __instance, out bool __state)
            {
                var val = Traverse.Create(__instance).Field("currentModeInfo").Field("mode").Method("ViewMode").GetValue <HashedString>();

                __state = val == OverlayModes.Decor.ID && newMode != OverlayModes.Decor.ID;
            }
Esempio n. 19
0
 /// <summary>
 /// Applied after RegisterModes runs.
 /// </summary>
 internal static void Postfix(OverlayScreen __instance)
 {
     PUtil.LogDebug("Creating PipPlantOverlay");
     REGISTER_MODE.Invoke(__instance, new PipPlantOverlay());
 }
Esempio n. 20
0
 protected override void OnPrefabInit()
 {
     Debug.Assert((UnityEngine.Object)Instance == (UnityEngine.Object)null);
     Instance         = this;
     powerLabelParent = GameObject.Find("WorldSpaceCanvas").GetComponent <Canvas>();
 }