Пример #1
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);
            if (mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario && mode != LoadMode.LoadGame)
            {
                return;
            }
            Detours.Deploy();
            SimulationManager.instance.AddAction(() => Object.FindObjectOfType <RenderProperties>().m_edgeFogDistance = 2800f);
            SimulationManager.instance.AddAction(() => Object.FindObjectOfType <FogEffect>().m_edgeFogDistance        = 2800f);
            SimulationManager.instance.AddAction(() => Object.FindObjectOfType <FogProperties>().m_EdgeFogDistance    = 2800f);
            if (Util.IsModActive(Mod.ALL_TILES_START_MOD))
            {
                UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage(
                    "81 Tiles - Incompatible mod detected",
                    $"'81 Tiles' isn't compatible with 'All Tile Start' mod!\nPlease unsubscribe that mod and use '{Mod.UNLOCK_ALL_TILES_FOR_FREE}' button in '81 Tiles' options entry!",
                    false);
            }
            SimulationManager.instance.AddAction(FixNotInIndustryAreaProblem);
            SimulationManager.instance.AddAction(FixNotInCampusAreaProblem);

            if (Enum.GetNames(typeof(DistrictPark.ParkType)).Length > 14)
            {
                UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("81 Tiles self-check: new park types detected", "This new version of the game added new park types. 81 Tiles has to be updated in order to not get 'Not in X area' errors on save re-load", false);
            }

            if (Enum.GetNames(typeof(ImmaterialResourceManager.Resource)).Length > 28)
            {
                UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("81 Tiles self-check: new resource types detected", "This new version of the game added new resource types. 81 Tiles has to be updated!", false);
            }
        }
Пример #2
0
        private void InitializeHands()
        {
            var context = Object.FindObjectOfType <MetaContextBridge>().CurrentContext;

//            context.Get<HandsModule>().Init();
            _initializedHandsModule = true;
        }
        public IEnumerator SubScene_NotOpenedForEdit_RemainsClosedInPlayMode([Values(EnterPlayModeOptions.DisableDomainReload | EnterPlayModeOptions.DisableSceneReload)] EnterPlayModeOptions enterPlayModeOptions)
        {
            // Set editor settings
            EditorSettings.enterPlayModeOptionsEnabled = enterPlayModeOptions != EnterPlayModeOptions.None;
            EditorSettings.enterPlayModeOptions        = enterPlayModeOptions;
            var expectingDomainReload = !enterPlayModeOptions.HasFlag(EnterPlayModeOptions.DisableDomainReload);

            DisableSetupAndTearDown();

            EditorSceneManager.OpenScene("Assets/HelloCube/3. SubScene/SubScene.unity", OpenSceneMode.Single);
            var subScene = Object.FindObjectOfType <SubScene>();

            Assert.NotNull(subScene);
            Assert.IsFalse(subScene.IsLoaded);
            Assert.AreEqual(1, SceneManager.sceneCount);

            // Enter play mode
            yield return(new EnterPlayMode(expectingDomainReload));

            // Validate that subscene is still loaded
            subScene = Object.FindObjectOfType <SubScene>();
            Assert.NotNull(subScene);
            Assert.IsFalse(subScene.IsLoaded);
            Assert.AreEqual(1, SceneManager.sceneCount);

            yield return(new ExitPlayMode());

            EnableSetupAndTearDown();
        }
Пример #4
0
        public static SaveData.Heroine GetCurrentVisibleGirl()
        {
            var result = Object.FindObjectOfType <TalkScene>()?.targetHeroine;

            if (result != null)
            {
                return(result);
            }

            var nowScene = Game.Instance?.actScene?.AdvScene?.nowScene;

            if (nowScene != null)
            {
                var traverse = Traverse.Create(nowScene).Field("m_TargetHeroine");
                if (traverse.FieldExists())
                {
                    var girl = traverse.GetValue <SaveData.Heroine>();
                    if (girl != null)
                    {
                        return(girl);
                    }
                }
            }
            return(null);
        }
Пример #5
0
        public static void ProfileBiggestPath()
        {
            GameplayController gameplayController = Object.FindObjectOfType <GameplayController>();

            ProfileAction(100, () =>
            {
                gameplayController.PrintBiggestPath();
            });
        }
Пример #6
0
        public override void Use(Entity target)
        {
            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.SubscribeToEvent(GlobalHelper.TargetHit, this);

            base.Use(target);

            eventMediator.UnsubscribeFromEvent(GlobalHelper.TargetHit, this);
        }
        public override void Deserialize(NetworkReader reader)
        {
            ImageTargetIndex = reader.ReadInt32();
            StepOrder        = reader.ReadUInt32();

            var application = Object.FindObjectOfType <Base.Application>();

            Data = Object.Instantiate(application.Prefabs.StepModelPrefab);
            var data = new MemoryStream(reader.ReadBytes(reader.Length - 8));

            Data.Deserialize(new BinaryReader(data));
        }
        private void FindPhasePanel()
        {
            logger.Info("ES: Find Phase Panel");

            if (phasePanel != null)
            {
                return;
            }

            phasePanel      = UnityObject.FindObjectOfType <WarningPhasePanel>();
            evacuatingField = phasePanel.GetType().GetField("m_isEvacuating", BindingFlags.NonPublic | BindingFlags.Instance);
        }
Пример #9
0
        public IStateBehaviour Create(GameState gameState)
        {
            switch (gameState)
            {
            case GameState.Simulate:
                return(new GameSimulationState(_stateController, Object.FindObjectOfType <WorldData>()));

            case GameState.Initialize:
                return(new GameInitializeState(_stateController));

            default:
                throw new ArgumentOutOfRangeException("gameState", gameState, null);
            }
        }
        private static void Bootstrap()
        {
            Redirector <OptionsGraphicsPanelDetour> .Deploy();

            var panel = Object.FindObjectOfType <OptionsGraphicsPanel>();

            if (panel == null)
            {
                return;
            }
            OptionsGraphicsPanelDetour.InitAspectRatios(panel);
            OptionsGraphicsPanelDetour.InitResolutions(panel);
            OptionsGraphicsPanelDetour.InitDisplayModes(panel);
        }
Пример #11
0
        public EquipLocation GetAllowedEquipLocation()
        {
            if (ItemType.Slot == null)
            {
                ItemStore itemStore = Object.FindObjectOfType <ItemStore>();

                ItemType.Slot = itemStore.GetItemTypeByName(GetName()).Slot;
            }

            if (ItemType.Slot != null)
            {
                return((EquipLocation)ItemType.Slot);
            }

            throw new Exception($"Equipment location slot for {ItemType.Name} is null!");
        }
        public IEnumerator SubScene_OpenedForEdit_UnloadsSceneOnDestroyImmediate()
        {
            EditorSceneManager.OpenScene("Assets/HelloCube/3. SubScene/SubScene.unity", OpenSceneMode.Single);
            var subScene = Object.FindObjectOfType <SubScene>();

            Assert.NotNull(subScene);
            SubSceneInspectorUtility.EditScene(subScene);
            Assert.IsTrue(subScene.IsLoaded);
            Assert.AreEqual(2, SceneManager.sceneCount);

            Object.DestroyImmediate(subScene.gameObject);

            yield return(null);

            Assert.AreEqual(1, SceneManager.sceneCount);
        }
Пример #13
0
        public override void Use(Entity target)
        {
            var message = $"{AbilityOwner.Name} attacks {target.Name} with {GlobalHelper.CapitalizeAllWords(Name)}!";

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.SendMessageToConsole, this, message);

            eventMediator.SubscribeToEvent(GlobalHelper.TargetHit, this);

            AbilityOwner.MeleeAttack(target, this);

            AbilityOwner.SubtractActionPoints(ApCost);

            eventMediator.UnsubscribeFromEvent(GlobalHelper.TargetHit, this);
        }
        public void OnLevelLoaded(LoadMode mode)
        {
            if (!mode.IsGameOrScenario())
            {
                return;
            }

            logger.Info("Changing max disaster spawn intensity");

            var optionPanel = UnityObject.FindObjectOfType <DisastersOptionPanel>();
            var slider      = optionPanel.GetComponentInChildren <UISlider>();

            slider.maxValue = byte.MaxValue;
            slider.minValue = byte.MinValue;

            logger.Info("Max disaster spawn intensity changed to 25.5");
        }
 private void Update()
 {
     if (!_sensorsInitialized)
     {
         Internal.SensorMetaData sensorMetaData = new Internal.SensorMetaData();
         if (HandKernelInterop.GetSensorMetaData(ref sensorMetaData))
         {
             OnSensorInitialized();
             _sensorsInitialized = true;
         }
     }
     else if (!_initializedHandsModule)
     {
         var context = Object.FindObjectOfType <MetaContextBridge>().CurrentContext;
         context.Get <HandsModule>().Initialized = true;
         _initializedHandsModule = true;
     }
 }
Пример #16
0
        public void OnNotify(string eventName, object broadcaster, object parameter = null)
        {
            if (eventName.Equals(GlobalHelper.TargetHit))
            {
                var target = parameter as Entity;

                if (target == null)
                {
                    return;
                }

                target.ApplyEffect(_bleedingEffect);

                var message = $"{target.Name} is bleeding!";

                var eventMediator = Object.FindObjectOfType <EventMediator>();
                eventMediator.Broadcast(GlobalHelper.SendMessageToConsole, this, message);
            }
        }
Пример #17
0
        public void OnNotify(string eventName, object broadcaster, object parameter = null)
        {
            if (eventName.Equals(GlobalHelper.TargetHit))
            {
                if (!(parameter is Entity target))
                {
                    return;
                }

                var direction = Direction.GetDirection(AbilityOwner.Position, target.Position);

                var combatManager = Object.FindObjectOfType <CombatManager>();

                var map = combatManager.Map;

                var targetTile = map.GetTileAt(target.Position);

                var destination = targetTile.GetAdjacentTileByDirection(direction);

                GlobalHelper.InvokeAfterDelay(() => target.MoveTo(destination, 0, false), 1f);
            }
        }
Пример #18
0
        public void PreInitialize()
        {
            var worldConfig = Object.FindObjectOfType <WorldConfigBehaviour>();

            if (worldConfig == null)
            {
                throw new Exception("WorldConfigBehaviour must be created!");
            }

            var world = _ecsWorld.CreateEntityWith <WorldComponent>();

            world.WorldField = new HashSet <int> [worldConfig.SizeX][];
            for (int xIndex = 0, xMax = worldConfig.SizeX; xIndex < xMax; xIndex++)
            {
                var yFields = new HashSet <int> [worldConfig.SizeY];
                for (int yIndex = 0, yMax = worldConfig.SizeY; yIndex < yMax; yIndex++)
                {
                    yFields[yIndex] = new HashSet <int>();
                }

                world.WorldField[xIndex] = yFields;
            }
        }
Пример #19
0
        public static SaveData.Heroine GetCurrentVisibleGirl()
        {
            if (!Game.IsInstance())
            {
                return(null);
            }

            if (Game.Instance.actScene != null &&
                Game.Instance.actScene.AdvScene != null)
            {
                var advScene = Game.Instance.actScene.AdvScene;
                if (advScene.Scenario?.currentHeroine != null)
                {
                    return(advScene.Scenario.currentHeroine);
                }
                if (advScene.nowScene is TalkScene s && s.targetHeroine != null)
                {
                    return(s.targetHeroine);
                }
            }

            return(Object.FindObjectOfType <TalkScene>()?.targetHeroine);
        }
Пример #20
0
        public IEnumerator CheckUltralightBrowserDemo()
        {
            if (SceneManager.GetActiveScene().name != "TestsScene")
            {
                SceneManager.LoadScene("TestsScene");
            }
            yield return(null);

            var browser = Object.FindObjectOfType <UltralightBrowserDemo>();

            Assert.IsNotNull(browser, "Browser should exist.");

            Assert.AreNotEqual("UltralightSharp Demo", browser.Title, "Browser should not be pre-loaded.");

            browser.Url = "file:///index.html";

            Assert.AreNotEqual("UltralightSharp Demo", browser.Title, "Browser should not be load immediately.");

            do
            {
                yield return(null);

                if (!browser.WillRender)
                {
                    browser.OnWillRenderObject();
                }

                Assert.IsTrue(browser.WillRender, "Should update and render.");
            } while (browser.IsLoading);

            Assert.IsFalse(browser.Failed, "Should not fail to load.");
            Assert.IsTrue(browser.IsLoaded, "Should be loaded.");
            Assert.IsTrue(browser.IsDomReady, "DOM should be ready.");

            Assert.AreEqual("UltralightSharp Demo", browser.Title);
        }
Пример #21
0
        protected IEnumerator RunAssert(string sceneName, Action <EventMessages> assertCallback, Action beforeAssertCallback, double waitBeforeAssert = 0, int invokeCount = 1)
        {
            PreInstall();
            yield return(SceneManager.LoadSceneAsync($"{ScenePath}{sceneName}", LoadSceneMode.Additive));

            yield return(Observable.TimerFrame(10).StartAsCoroutine());

            for (var i = 0; i < invokeCount; i++)
            {
                beforeAssertCallback?.Invoke();
                if (waitBeforeAssert > 0)
                {
                    yield return(Observable.Timer(TimeSpan.FromSeconds(waitBeforeAssert)).StartAsCoroutine());
                }
                assertCallback(Object.FindObjectOfType <TestReceiver>().SentEventMessages);
            }
            Assert.GreaterOrEqual(Object.FindObjectOfType <TestReceiver>().ReceiveCount, invokeCount);
            Assert.True(HasAssert);


            yield return(SceneManager.UnloadSceneAsync($"{ScenePath}{sceneName}"));

            PostInstall();
        }
Пример #22
0
        private void SetupData()
        {
            var game   = Object.FindObjectOfType <GameManager>();
            var config = InspectorUtil.GetPrivateValue <GameConfig, GameManager>("config", game);
            var cells  = Object.FindObjectOfType <Cells>();

            config.Init(cells);
            playerData = new PlayerData(null);

            playerData.Init(config);

            var homeCell = (BuildingCell)cells.GetPrefab(Cells.CellTypes.Home);

            buildings.Add(homeCell);

            playerData.TurnNumber = 1;
            playerData.TechnologyData.AddTechnology(homeCell.Technology);
            playerData.CurrencyData.Supplies           = config.startingSupply;
            playerData.CurrencyData.Production.maximum = homeCell.GetCurrencyBonus().production;
            playerData.CurrencyData.Population.maximum = homeCell.GetCurrencyBonus().population;

            DisplayCurrency();
            turnLabel.text = $"Turn {playerData.TurnNumber}";
        }
Пример #23
0
        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;
                    }
                }
            }
        }
Пример #24
0
        public WellFed(Entity abilityOwner) : base("Well Fed", $"+{MaxApMod} Max Action Points", -1, -1, abilityOwner, TargetType.Friendly, true)
        {
            var spriteStore = Object.FindObjectOfType <SpriteStore>();

            Icon = spriteStore.GetAbilitySprite(this);
        }
Пример #25
0
        /// <summary>
        /// Sets the option's value.
        /// </summary>
        /// <remarks>
        /// Does nothing when the value type differs or when the value matches the current value.
        /// </remarks>
        /// <param name="value">The new value</param>
        /// <param name="raiseEvents">Whether or not to raise events</param>
        protected virtual void SetValue(object value, bool raiseEvents)
        {
            if (value?.GetType() != Value?.GetType() || Value == value)
            {
                return;                                                         // Refuse value updates that don't match the option type.
            }
            if (raiseEvents && OnValueChanged != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer)
            {
                object lastValue = value;

                OptionOnValueChangedEventArgs args = OnValueChangedEventArgs(value, Value);
                foreach (EventHandler <OptionOnValueChangedEventArgs> handler in OnValueChanged.GetInvocationList())
                {
                    handler(this, args);

                    if (args.Value.GetType() != value.GetType())
                    {
                        args.Value  = lastValue;
                        args.Cancel = false;

                        EssentialsPlugin.Logger.LogWarning($"A handler for option \"{Name}\" attempted to change value type, ignored.");
                    }

                    lastValue = args.Value;

                    if (args.Cancel)
                    {
                        return;              // Handler cancelled value change.
                    }
                }

                value = args.Value;
            }

            if (OldValue != Value)
            {
                OldValue = Value;
            }

            Value = value;

            //if (SendRpc && GameSetting != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer) Rpc.Send(new (string, CustomOptionType, object)[] { this });
            if (SendRpc && GameObject != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer)
            {
                Rpc.Instance.Send(this);
            }

            UpdateGameObject();

            if (raiseEvents)
            {
                ValueChanged?.SafeInvoke(this, ValueChangedEventArgs(value, Value), nameof(ValueChanged));
            }

            if (GameObject == null)
            {
                return;                     // Game object does not exist, menu is closed
            }
            // Refresh the value of all options in the menu, in case an option affects another.
            try
            {
                GameOptionsMenu optionsMenu = Object.FindObjectOfType <GameOptionsMenu>();

                if (optionsMenu == null)
                {
                    return;
                }

                for (int i = 0; i < optionsMenu.Children.Length; i++)
                {
                    OptionBehaviour optionBehaviour = optionsMenu.Children[i];
                    optionBehaviour.enabled = false;
                    optionBehaviour.enabled = true;
                }
            }
            catch
            {
            }
        }
 protected override void OnStartRunning()
 {
     _player = Object.FindObjectOfType <Player>();
 }
Пример #27
0
        /// <summary>
        /// Sets the option's value, it's not recommended to call this directly, call derivatives instead.
        /// </summary>
        /// <remarks>
        /// Does nothing when the value type differs or when the value matches the current value.
        /// </remarks>
        /// <param name="value">The new value</param>
        /// <param name="raiseEvents">Whether or not to raise events</param>
        private protected void SetValue(object value, bool raiseEvents)
        {
            if (value?.GetType() != Value?.GetType() || Value == value)
            {
                return;                                                         // Refuse value updates that don't match the option type
            }
            if (raiseEvents && OnValueChanged != null && AmongUsClient.Instance && PlayerControl.LocalPlayer && AmongUsClient.Instance.AmHost)
            {
                object lastValue = value;

                OptionOnValueChangedEventArgs args = OnValueChangedEventArgs(value, Value);
                foreach (EventHandler <OptionOnValueChangedEventArgs> handler in OnValueChanged.GetInvocationList())
                {
                    handler(this, args);

                    if (args.Value.GetType() != value.GetType())
                    {
                        args.Value  = lastValue;
                        args.Cancel = false;

                        EssentialsPlugin.Logger.LogWarning($"A handler for option \"{Name}\" attempted to change value type, ignored.");
                    }

                    lastValue = args.Value;

                    if (args.Cancel)
                    {
                        return;              // Handler cancelled value change.
                    }
                }

                value = args.Value;
            }

            if (OldValue != Value)
            {
                OldValue = Value;
            }

            Value = value;

            if (GameSetting != null && AmongUsClient.Instance && PlayerControl.LocalPlayer && AmongUsClient.Instance.AmHost)
            {
                PlayerControl.LocalPlayer.Send <Rpc>(new Rpc.Data(this));
            }

            try
            {
                if (GameSetting is ToggleOption toggle)
                {
                    bool newValue = (bool)Value;

                    toggle.CheckMark.enabled = toggle.oldValue = newValue;
                }
                else if (GameSetting is NumberOption number)
                {
                    float newValue = (float)Value;

                    number.Value          = number.oldValue = newValue;
                    number.ValueText.Text = ToString();
                }
                else if (GameSetting is StringOption str)
                {
                    int newValue = (int)Value;

                    str.Value          = str.oldValue = newValue;
                    str.ValueText.Text = ToString();
                }
                else if (GameSetting is KeyValueOption kv)
                {
                    int newValue = (int)Value;

                    kv.Selected       = kv.oldValue = newValue;
                    kv.ValueText.Text = ToString();
                }
            }
            catch (Exception e)
            {
                EssentialsPlugin.Logger.LogWarning($"Failed to update game setting value for option \"{Name}\": {e}");
            }

            if (raiseEvents)
            {
                ValueChanged?.Invoke(this, ValueChangedEventArgs(value, Value));
            }

            /*{
             *  OptionValueChangedEventArgs args = ValueChangedEventArgs(value, Value);
             *  foreach (EventHandler<OptionValueChangedEventArgs> handler in ValueChanged.GetInvocationList()) handler(this, args);
             * }*/

            try
            {
                if (GameSetting != null)
                {
                    Object.FindObjectOfType <GameOptionsMenu>()?.Method_16();                     // RefreshChildren();
                }
            }
            catch
            {
            }
        }
Пример #28
0
        private static bool CardSavePatch(CustomControl __instance)
        {
            if (!MakerAPI.InsideMaker || !_modifiers.Any(x => x.Key != null || x.Value != null))
            {
                return(true);
            }

            try
            {
                Utils.Sound.Play(SystemSE.ok_s);

                var instanceChaCtrl = Singleton <CustomBase> .Instance.chaCtrl;

                var isMale = instanceChaCtrl.sex == 0;

                var folder = UserData.Path + (isMale ? "chara/male/" : "chara/female/");

                var fileName = __instance.saveNew ?
#if KK
                               $"Koikatu_{(isMale ? "M" : "F")}_{DateTime.Now:yyyyMMddHHmmssfff}"
#elif EC
                               $"Emocre_{(isMale ? "M" : "F")}_{DateTime.Now:yyyyMMddHHmmssfff}"
#endif
                    : __instance.saveFileName;

                foreach (var kvp in _modifiers)
                {
                    if (kvp.Key != null)
                    {
                        folder = kvp.Key(folder);
                    }
                    // Keep old filename if not saving as new file
                    if (kvp.Value != null && __instance.saveNew)
                    {
                        fileName = kvp.Value(fileName);
                    }
                }

                var fullPath = Path.Combine(folder, fileName);

                instanceChaCtrl.chaFile.SaveCharaFile(fullPath);

                if (__instance.saveFileListCtrl != null)
                {
                    var listCtrl = Object.FindObjectOfType <CustomCharaFile>();
                    if (listCtrl != null)
                    {
                        RefreshThumbs(listCtrl);
                    }
                }

                __instance.saveMode = false;

                return(false);
            }
            catch (Exception ex)
            {
                KoikatuAPI.Logger.LogError(ex);
                return(true);
            }
        }
        public static void StopTimer(bool enable)
        {
            var timer = Object.FindObjectOfType <MazeGenerationTimer>();

            timer.StopTimer();
        }
Пример #30
0
 public static Menu GetCurrentMenu()
 {
     return((Menu)Object.FindObjectOfType(typeof(Menu)));
 }