コード例 #1
0
        public async Task <IActionResult> SetBlueprintResources([FromBody] BlueprintResources aRessources)
        {
            try
            {
                if (aRessources.ReplaceExisting)
                {
                    var p = await FactoryManager.Request_Player_Info(aRessources.PlayerId.ToId());

                    var setRes = new List <ItemStack>();
                    aRessources.ItemStacks.ForEach(I => {
                        if (p.bpResourcesInFactory.TryGetValue(I.id, out var count))
                        {
                            if (count < I.count)
                            {
                                setRes.Add(new ItemStack(I.id, I.count - (int)count));
                            }
                        }
                        else
                        {
                            setRes.Add(I);
                        }
                    });
                    aRessources.ItemStacks      = setRes;
                    aRessources.ReplaceExisting = false;
                }

                await FactoryManager.Request_Blueprint_Resources(aRessources);

                return(Ok());
            }
            catch (Exception Error)
            {
                return(NotFound(Error.Message));
            }
        }
コード例 #2
0
        public async Task <ActionResult <BlueprintResources> > GetBlueprintResources(int aPlayerId)
        {
            try
            {
                var onlinePlayers = await FactoryManager.Request_Player_List();

                if (!onlinePlayers.list.Contains(aPlayerId))
                {
                    return(NotFound($"Player {aPlayerId} not online"));
                }

                var PlayerInfo = await FactoryManager.Request_Player_Info(aPlayerId.ToId());

                var Result = new BlueprintResources()
                {
                    PlayerId        = aPlayerId,
                    ItemStacks      = new List <ItemStack>(),
                    ReplaceExisting = true,
                };
                PlayerInfo.bpResourcesInFactory?.ForEach(I => Result.ItemStacks.Add(new ItemStack()
                {
                    id = I.Key, count = (int)I.Value
                }));
                return(Ok(Result));
            }
            catch (Exception Error)
            {
                return(NotFound(Error.Message));
            }
        }
コード例 #3
0
        public static void Request_Blueprint_Resources(BlueprintResources arg, Action callback = null, Action <ErrorInfo> onError = null)
        {
            Action <CmdId, object> wiredCallback = null;

            if (callback != null)
            {
                wiredCallback = (_, val) => callback();
            }

            var apiCmd = new GenericAPICommand(
                CmdId.Request_Blueprint_Resources,
                arg,
                wiredCallback,
                onError ?? noOpErrorHandler
                );

            Broker.Execute(apiCmd);
        }
コード例 #4
0
 public async Task <bool> Request_Blueprint_Resources(BlueprintResources arg, CancellationToken ct)
 {
     return(await Broker.SendRequestAsync(CmdId.Request_Blueprint_Resources, arg, ct));
 }
コード例 #5
0
 public async Task <bool> Request_Blueprint_Resources(BlueprintResources arg)
 {
     return(await Broker.SendRequestAsync(CmdId.Request_Blueprint_Resources, arg));
 }
コード例 #6
0
 public void Request_Blueprint_Resources(BlueprintResources arg, Action callback = null, Action <ErrorInfo> onError = null)
 {
     Broker.Request_Blueprint_Resources(arg, callback, onError);
 }
コード例 #7
0
 public static Task <object> Request_Blueprint_Resources(BlueprintResources param)
 {
     return(Broker.CreateCommandWithArgAndReturn <BlueprintResources, object>(CmdId.Request_Blueprint_Resources, param));
 }
コード例 #8
0
 public static Task <object> Request_Blueprint_Resources(BlueprintResources param, Action callback, Action <ErrorInfo> onError = null)
 {
     return(Broker.CreateCommandWithArgAndReturn <BlueprintResources, object>(CmdId.Request_Blueprint_Resources, param, callback, onError));
 }