Example #1
0
        private static Boolean ApplyPrefix(OpenContainerAbilityHandler __instance)
        {
            if (!The.InputManager.IsPressed(KeyCode.LeftShift))
            {
                return(HarmonyPrefix.CallOriginal);
            }

            ProxyAbilityHandler handler    = new ProxyAbilityHandler(__instance);
            ActionData          actionData = handler.ActionData;

            Entity    targetEntity = actionData.TargetEntity;
            Character performer    = actionData.Performer;

            String field = targetEntity.GetField <String>(CustomField.UseSound);

            if (!String.IsNullOrEmpty(field))
            {
                Singleton <AudioManager> .Instance.Play(field);
            }

            ContainerModule container = targetEntity.GetModule <ContainerModule>();

            var union = new UnionContainer(new InteractiveRange(), container);

            var window = Window.Create <ContainerWindow, BaseInventoryModule, BaseInventoryModule>(null, union.MergedContainer, performer.InventoryModule);

            WindowManager.Instance.RegisterOnClose(window, () => union.Commit());

            InteractiveRangeVisualizer.Deactivate();
            window.ShowModal(false);

            The.EventManager.ContainerOpened.Raise(targetEntity);

            return(HarmonyPrefix.SkipOriginal);
        }
Example #2
0
        private static void CollectLoot()
        {
            var merged = new UnionContainer(new InteractiveRange());

            if (merged.Count == 0)
            {
                return;
            }

            Entity nearestContainer = merged.SelectedContainer.Entity;

            String useSound = nearestContainer.GetField <String>(CustomField.UseSound);

            if (!String.IsNullOrEmpty(useSound))
            {
                Singleton <AudioManager> .Instance.Play(useSound);
            }

            var window = Window.Create <ContainerWindow, BaseInventoryModule, BaseInventoryModule>(null, merged.MergedContainer, The.World.Avatar.InventoryModule);

            WindowManager.Instance.RegisterOnClose(window, () => merged.Commit());

            InteractiveRangeVisualizer.Deactivate();
            window.ShowModal(false);

            The.EventManager.ContainerOpened.Raise(nearestContainer);
        }
Example #3
0
        private static Boolean ApplyPrefix(SearchAbilityHandler __instance)
        {
            if (!The.InputManager.IsPressed(KeyCode.LeftShift))
            {
                return(HarmonyPrefix.CallOriginal);
            }

            ProxyAbilityHandler handler    = new ProxyAbilityHandler(__instance);
            ActionData          actionData = handler.ActionData;

            Entity    targetEntity = actionData.TargetEntity;
            Character performer    = actionData.Performer;

            ContainerModule container = targetEntity.GetModule <ContainerModule>();

            if (container.AlreadySearched)
            {
                return(HarmonyPrefix.SkipOriginal);
            }

            container.AlreadySearched = true;
            container.Searchable      = false;

            // Idk why
            performer.EnsureModule <InventoryModule>();

            var merged = new UnionContainer(new InteractiveRange(), container);

            if (merged.Count < 2 && merged.MergedContainer.AllItems.Count == 0)
            {
                merged.Commit();

                The.NotificationsManager.ShowNotificationOnPlayer("[15376]Found nothing");
                return(HarmonyPrefix.SkipOriginal);
            }


            var window = Window.Create <ContainerWindow, BaseInventoryModule, BaseInventoryModule>(null, merged.MergedContainer, performer.InventoryModule);

            WindowManager.Instance.RegisterOnClose(window, () => merged.Commit());

            InteractiveRangeVisualizer.Deactivate();
            window.ShowModal(immediate: false);

            The.EventManager.ContainerOpened.Raise(targetEntity);

            return(HarmonyPrefix.SkipOriginal);
        }