Exemple #1
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");
        }
        private static void MultiplyDesiredSpeed(CharacterComponent character, Single factor)
        {
            const String fieldName = "_moveSpeedDesired";

            if (_getMoveSpeedDesired == null)
            {
                _getMoveSpeedDesired = InstanceFieldAccessor.GetValueDelegate <CharacterComponent, Single>(fieldName);
            }
            if (_setMoveSpeedDesired == null)
            {
                _setMoveSpeedDesired = InstanceFieldAccessor.SetValueDelegate <CharacterComponent, Single>(fieldName);
            }

            Single value = _getMoveSpeedDesired(character);

            _setMoveSpeedDesired(character, value * factor);
        }