Exemplo n.º 1
0
 private void CheckInventory(CraftingInventory inventory)
 {
     if (!_craftingRequests.ContainsKey(inventory))
     {
         _craftingRequests.Add(inventory, new Dictionary <CraftingResources, CraftingResourceRequest>());
     }
 }
 private void Start()
 {
     craftingInventory = FindObjectOfType <CraftingInventory>();
     itemDatabase      = FindObjectOfType <ItemDatabase>();
     uIItems           = GetComponent <SlotPanel>().uiItems;
     uIItems.ForEach(item => item.isCraftingSlot = true);
 }
Exemplo n.º 3
0
        public int GetRequestNumber(CraftingInventory inventory)
        {
            if (_craftingRequests.ContainsKey(inventory))
            {
                return(_craftingRequests[inventory].Count);
            }

            return(0);
        }
Exemplo n.º 4
0
        public static void CraftingEvent(CraftingInventory inv, BlueprintDataBlock blueprint, int amount, ulong startTime)
        {
            CraftingEvent e = new CraftingEvent(inv, blueprint, amount, startTime);

            if (OnCrafting != null)
            {
                OnCrafting(e);
            }
        }
Exemplo n.º 5
0
 protected void GetControllers()
 {
     inventoryController = FindObjectOfType <InventoryController>();
     craftingInventory   = FindObjectOfType <CraftingInventory>();
     consumableInventory = FindObjectOfType <ConsumableInventory>();
     characterController = FindObjectOfType <BattleSystem.CharacterController>();
     sceneController     = FindObjectOfType <SceneController>();
     questController     = FindObjectOfType <QuestController>();
 }
 void Awake()
 {
     craftingInventory   = FindObjectOfType <CraftingInventory>();
     consumableInventory = FindObjectOfType <ConsumableInventory>();
     characterController = FindObjectOfType <BattleSystem.CharacterController>();
     inventoryController = FindObjectOfType <InventoryController>();
     itemDatabase        = FindObjectOfType <ItemDatabase>();
     menuController      = FindObjectOfType <MenuController>();
     ClearSlots();
 }
Exemplo n.º 7
0
        private int GetRequestNumber(CraftingInventory inventory, CraftingResources resources)
        {
            if (_craftingRequests.ContainsKey(inventory))
            {
                if (_craftingRequests[inventory].ContainsKey(resources))
                {
                    return(_craftingRequests[inventory][resources].Number);
                }
            }

            return(0);
        }
Exemplo n.º 8
0
        public List <CraftingResourceRequest> GetAllCraftingRequests(CraftingInventory inventory)
        {
            var returnList = new List <CraftingResourceRequest>();

            if (_craftingRequests.ContainsKey(inventory))
            {
                foreach (var entry2 in _craftingRequests[inventory])
                {
                    returnList.Add(entry2.Value);
                }
            }

            return(returnList);
        }
Exemplo n.º 9
0
        public void RemoveRequest(CraftingResources resource, CraftingInventory inventory)
        {
            if (_craftingRequests.ContainsKey(inventory))
            {
                if (_craftingRequests[inventory].ContainsKey(resource))
                {
                    var request = _craftingRequests[inventory][resource];
                    _requestWallets[request].EarnMoney(request.Reward);
                    _craftingRequests[inventory].Remove(resource);
                    _requestWallets.Remove(request);

                    Refresh();
                }
            }
        }
Exemplo n.º 10
0
        /////////////////////////
        // OnItemCraft(CraftingInventory inventory, BlueprintDataBlock bp, int amount, ulong starttime)
        // Called when a player starts crafting an object
        /////////////////////////
        void OnItemCraft(CraftingInventory inventory, BlueprintDataBlock bp, int amount, ulong starttime)
        {
            if (!antiBlueprintUnlocker)
            {
                return;
            }
            var inv        = inventory.GetComponent <PlayerInventory>();
            var blueprints = (List <BlueprintDataBlock>)getblueprints.GetValue(inv);

            if (blueprints.Contains(bp))
            {
                return;
            }
            if (blueprintunlockerPunish)
            {
                Punish(inventory.GetComponent <Controllable>().playerClient, string.Format("rBlueprintUnlocker ({0})", bp.resultItem.name.ToString()));
            }
        }
Exemplo n.º 11
0
 public virtual bool CanWork(int amount, Inventory workbenchInv)
 {
     if (this.lastCanWorkResult != null)
     {
         this.lastCanWorkResult.Clear();
     }
     else
     {
         this.lastCanWorkResult = new List <int>();
     }
     if (this.lastCanWorkIngredientCount != null)
     {
         this.lastCanWorkIngredientCount.Clear();
     }
     else
     {
         this.lastCanWorkIngredientCount = new List <int>((int)this.ingredients.Length);
     }
     if (this.RequireWorkbench)
     {
         CraftingInventory component = workbenchInv.GetComponent <CraftingInventory>();
         if (!component || !component.AtWorkBench())
         {
             return(false);
         }
     }
     BlueprintDataBlock.IngredientEntry[] ingredientEntryArray = this.ingredients;
     for (int i = 0; i < (int)ingredientEntryArray.Length; i++)
     {
         BlueprintDataBlock.IngredientEntry ingredientEntry = ingredientEntryArray[i];
         if (ingredientEntry.amount != 0)
         {
             int num = workbenchInv.CanConsume(ingredientEntry.Ingredient, ingredientEntry.amount * amount, this.lastCanWorkResult);
             if (num <= 0)
             {
                 this.lastCanWorkResult.Clear();
                 this.lastCanWorkIngredientCount.Clear();
                 return(false);
             }
             this.lastCanWorkIngredientCount.Add(num);
         }
     }
     return(true);
 }
Exemplo n.º 12
0
        public CraftingEvent(CraftingInventory inv, BlueprintDataBlock blueprint, int amount, ulong startTime)
        {
            this._inv       = inv;
            this._block     = blueprint;
            this._amount    = amount;
            this._startTime = startTime;
            var netUser = inv.GetComponent <Character>().netUser;

            this._player = Fougerite.Server.Cache[netUser.userID];
            this._user   = netUser;
            if (!_player.HasBlueprint(blueprint))
            {
                _legit = false;
                Cancel();
                Logger.LogWarning("[CraftingHack] Detected: " + _player.Name + " | " + _player.SteamID + " | " + _player.IP);
                Fougerite.Server.GetServer().Broadcast("CraftingHack Detected: " + _player.Name);
                Fougerite.Server.GetServer().BanPlayer(_player, "Console", "CraftingHack");
            }
        }
Exemplo n.º 13
0
        public void MakeRequest(CraftingResources resources, CraftingInventory inventory, EconomyWallet wallet)
        {
            void CheckExchange(CraftingResourceRequest request)
            {
                if (request.Price <= wallet.Money)
                {
                    if (_craftingRequests[inventory].ContainsKey(resources))
                    {
                        _craftingRequests[inventory][resources].Number++;
                    }
                    else
                    {
                        _craftingRequests[inventory].Add(resources, request);
                    }
                    wallet.SpendMoney(request.Price);
                }
            }

            CheckInventory(inventory);

            var requestNumber = GetRequestNumber(inventory, resources);
            var canRequest    = requestNumber < 10;

            if (canRequest)
            {
                var containsKey = _craftingRequests[inventory].ContainsKey(resources);

                if (!containsKey)
                {
                    Sprite icon        = GetIconByResource(resources);
                    var    newResource = new CraftingResourceRequest(resources, inventory, defaultResourcePrices[resources], icon);
                    _requestWallets.Add(newResource, wallet);
                    CheckExchange(newResource);
                }
                else
                {
                    CheckExchange(_craftingRequests[inventory][resources]);
                }
            }

            Refresh();
        }
Exemplo n.º 14
0
        public void ChangePrice(CraftingResources resources, CraftingInventory inventory, EconomyWallet wallet, int change)
        {
            CheckInventory(inventory);
            var craftingInventory = _craftingRequests[inventory];
            var containsKey       = craftingInventory.ContainsKey(resources);

            if (containsKey)
            {
                if (craftingInventory.ContainsKey(resources))
                {
                    var newPrice  = craftingInventory[resources].Price + change;
                    var newReward = craftingInventory[resources].GetReward(newPrice);

                    var rewardDifference = newReward - craftingInventory[resources].Reward;
                    var validTransaction = false;
                    if (rewardDifference > 0)
                    {
                        if (rewardDifference <= wallet.Money)
                        {
                            wallet.SpendMoney(rewardDifference);
                            validTransaction = true;
                        }
                    }
                    else
                    {
                        wallet.EarnMoney(Mathf.Abs(rewardDifference));
                        validTransaction = true;
                    }

                    if (validTransaction)
                    {
                        craftingInventory[resources].Price = newPrice;
                    }
                }
            }
            Refresh();
        }
Exemplo n.º 15
0
 void Start()
 {
     inv = transform.parent.parent.GetComponent <CraftingInventory>();
 }
Exemplo n.º 16
0
 private void OnItemCraft(CraftingInventory inventory, BlueprintDataBlock blueprint, int amount, ulong startTime)
 {
     HookCalled("OnItemCraft");
     // TODO: Print item crafting
 }
Exemplo n.º 17
0
 protected void CRFU(float start, float dur, float progresspersec, float progress, int blueprintUniqueID, int amount)
 {
     this.UpdateCrafting(CraftingInventory.FindBlueprint(blueprintUniqueID), amount, start, dur, progress, progresspersec);
 }
Exemplo n.º 18
0
 private void OnItemCraft(CraftingInventory inventory, BlueprintDataBlock blueprint, int amount, ulong startTime)
 {
     HookCalled("OnItemCraft");
     // Print item crafting
     var netUser = inventory.GetComponent<Character>().netUser;
     Puts(netUser.displayName + " started crafting " + blueprint.resultItem.name + " x " + amount.ToString());
 }
Exemplo n.º 19
0
 public CraftingInfo(CraftingMap craftingMap, CraftingInventory craftingInventory)
 {
     this.craftingMap       = craftingMap;
     this.craftingInventory = craftingInventory;
 }