Jump to content

Change the deconstruct time


Recommended Posts

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Door_Overhaul.STRINGS.BUILDINGS.PREFABS;
using static STRINGS.UI.ELEMENTAL;
using static Door_Overhaul.PneumaticTrapDoorManager;

namespace Door_Overhaul
{
    internal class MoveButton : KMonoBehaviour
    {
#pragma warning disable CS0649
        [MyCmpGet]
        private Deconstructable deconstructable;
#pragma warning restore CS0649

        protected override void OnPrefabInit()
        {
            base.OnPrefabInit();
            this.Subscribe((int)GameHashes.RefreshUserMenu, new System.Action<object>(OnRefreshUserMenu));
        }

        private void OnRefreshUserMenu(object data)
        {
            Game.Instance.userMenu.AddButton(
                go: this.gameObject,
                button: new KIconButtonMenu.ButtonInfo(
                    iconName: "action_mirror",
                    text: STRINGS.BUILDINGS.PREFABS.MOVEDOOR.NAME,
                    on_click: new System.Action(Destroy),
                    shortcutKey: Action.BuildingUtility1,
                    tooltipText: STRINGS.BUILDINGS.PREFABS.MOVEDOOR.TOOLTIP
                )
            );
        }

        private void Destroy()
        {
            deconstructable.SetWorkTime(5f);
            deconstructable.Trigger((int)GameHashes.MarkForDeconstruct, null);
            deconstructable.Trigger((int)GameHashes.RefreshUserMenu, null);           
        }
    }
}

Work for me

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...