示例#1
0
        void Update()
        {
            try
            {
                // Exit to the main menu unloads game scenes and interface objects. We must ensure that our mod remains active.
                // Recheck it every 10 seconds
                _recheckTimeSec += Time.deltaTime;
                if (_recheckTimeSec < 10.0 /*sec*/)
                {
                    return;
                }

                _recheckTimeSec = 0;

                // Don't use Awake()
                // Now the initialization of mods occurs before the initialization of the environment of the game.
                // We have to wait for it to be initialized.
                BarterHUD barterHud = Game.World?.HUD?.Barter;
                if (barterHud == null) // Not yet initialized
                {
                    return;
                }

                // Initialize our mod
                Initialize(barterHud);

                // We can destroy this component after initialization but this mod will be unloaded when the player exit to the main menu. Leave it active in the background.
                // Destroy(this.gameObject);
            }
            catch (Exception ex)
            {
                Debug.LogError("[AtomRPG.NuclearEdition] Something went wrong. Modification will be disabled. Error: " + ex);
                Destroy(this.gameObject);
            }
        }
示例#2
0
        private void Initialize(BarterHUD barterHud)
        {
            //foreach (var tabs in FindObjectsOfType<TeammateTabsHUD>())
            //{

            //}

            ExtendedBarterHUD extendedHud = barterHud.gameObject.GetComponent <ExtendedBarterHUD>();

            if (extendedHud == null)
            {
                InitializeExtendedBarterHUD(barterHud);
            }
        }
示例#3
0
        public BarterHUD_Proxy(BarterHUD barterHUD)
        {
            _instance = barterHUD;

            mLeftInventory       = new InstanceFieldAccessor <BarterHUD, Inventory>(_instance, nameof(mLeftInventory));
            mRightInventory      = new InstanceFieldAccessor <BarterHUD, Inventory>(_instance, nameof(mRightInventory));
            mLeftTradeInventory  = new InstanceFieldAccessor <BarterHUD, Inventory>(_instance, nameof(mLeftTradeInventory));
            mRightTradeInventory = new InstanceFieldAccessor <BarterHUD, Inventory>(_instance, nameof(mRightTradeInventory));

            _getSellDiscount    = InstanceMethodAccessor.GetDelegate <DGetSellDiscount>("GetSellDiscount");
            _calcSellCost       = InstanceMethodAccessor.GetDelegate <DCalcSellCost>("CalcSellCost");
            _calcBuyCost        = InstanceMethodAccessor.GetDelegate <DCalcBuyCost>("CalcBuyCost");
            _calcCostItem       = InstanceMethodAccessor.GetDelegate <DCalcCostItem>("CalcCostItem");
            _dropItemToBackpack = InstanceMethodAccessor.GetDelegate <DDropItemToBackpack>("DropItemToBackpack");
        }
示例#4
0
        private static void InitializeExtendedBarterHUD(BarterHUD barterHud)
        {
            ExtendedBarterHUD extendedHud;

            try
            {
                // Add our own component to an existing interface object.
                extendedHud = barterHud.gameObject.AddComponent <ExtendedBarterHUD>();
                extendedHud.Initialize(barterHud);

                Debug.Log("[AtomRPG.NuclearEdition] ExtendedBarterHUD is initialized.");
            }
            catch (Exception ex)
            {
                Debug.LogError("[AtomRPG.NuclearEdition] Failed to initialize ExtendedBarterHUD: " + ex);
            }
        }
 public void Initialize(BarterHUD originalHud)
 {
     _hud = new BarterHUD_Proxy(originalHud);
 }