コード例 #1
0
        public static void Gathering(ResourceDispenser dispenser, BaseEntity to, ItemAmount itemAmt, int amount)
        {
            itemAmt.amount += amount;
            BaseEntity  from = (BaseEntity)dispenser.GetFieldValue("baseEntity");
            GatherEvent ge   = new GatherEvent(dispenser, from, to, itemAmt, amount);

            OnGathering.OnNext(ge);

            if (ge.Amount > 0)
            {
                amount = Mathf.RoundToInt(Mathf.Min((float)ge.Amount, itemAmt.amount));

                if (amount > 0)
                {
                    itemAmt.amount -= amount;
                    if (itemAmt.amount < 0)
                    {
                        itemAmt.amount = 0;
                    }

                    Item item = ItemManager.CreateByItemID(itemAmt.itemid, amount, false);
                    if (item == null)
                    {
                        return;
                    }
                    to.GiveItem(item);
                }
            }
        }
コード例 #2
0
ファイル: GatherLogic.cs プロジェクト: ping1994/yinghe
        public void OffSurfaceGather(string reportName, string WP4000IP) // 注销外部采集
        {
            GatherEvent e      = GatherFace.OffSurfaceGather(reportName);
            功率分析仪       _功率分析仪 = AnyWay类构造.获取功率分析仪(WP4000IP);

            _功率分析仪.解析完毕 -= e.外部采集处理函数;
        }
コード例 #3
0
 public void OnPlayerGathering(Player p, GatherEvent ge)
 {
     this.Invoke("On_PlayerGathering", new object[]
     {
         p,
         ge
     });
 }
コード例 #4
0
ファイル: GatherLogic.cs プロジェクト: ping1994/yinghe
        public void LoginSurfaceGather(string reportName, string WP4000IP) // 注册外部采集
        {
            功率分析仪       _功率分析仪 = AnyWay类构造.获取功率分析仪(WP4000IP);
            GatherEvent e      = new GatherEvent();

            _功率分析仪.解析完毕 += new 功率分析仪.解析完毕通知(e.外部采集处理函数);
            GatherFace.LoginSurfaceGather(reportName, e);
        }
コード例 #5
0
 void OnPlayerGathering(Fougerite.Player param0, GatherEvent param1)
 {
     foreach (KeyValuePair <string, V8Plugin> plugin in plugins)
     {
         plugin.Value.Invoke("On_PlayerGathering", param0, param1); // Deprecated
         plugin.Value.Invoke("OnPlayerGathering", param0, param1);
     }
 }
コード例 #6
0
        public static void On_PlayerGathering(ResourceDispenser dispenser, BaseEntity to, ItemAmount itemAmt, float gatherDamage, float destroyFraction)
        {
            BaseEntity from = (BaseEntity)dispenser.GetFieldValue("baseEntity");

            if (itemAmt.amount == 0)
            {
                return;
            }

            float num   = gatherDamage / from.MaxHealth();
            float num2  = itemAmt.startAmount / (float)dispenser.GetFieldValue("startingItemCounts");
            float value = itemAmt.startAmount * num / num2;
            float num3  = Mathf.Clamp(value, 0, itemAmt.amount);
            float num4  = num3 * destroyFraction * 2;

            if (itemAmt.amount < num3 + num4)
            {
                itemAmt.amount -= destroyFraction * num3;
                num3            = itemAmt.amount;
                num4            = 0;
            }
            float amount = itemAmt.amount;

            itemAmt.amount -= num3;
            if (itemAmt.amount < 0)
            {
                itemAmt.amount = 0;
            }
            int num5 = Mathf.Clamp(Mathf.RoundToInt(num3), 0, Mathf.CeilToInt(amount));

            itemAmt.amount -= num4;
            if (itemAmt.amount < 0)
            {
                itemAmt.amount = 0;
            }

            GatherEvent ge = new GatherEvent(dispenser, from, to, itemAmt, num5);

            OnNext("On_PlayerGathering", ge);

            if (ge.Amount <= 0)
            {
                return;
            }
            Item item = ItemManager.CreateByItemID(itemAmt.itemid, ge.Amount);

            if (item == null)
            {
                return;
            }

            to.GiveItem(item, BaseEntity.GiveItemReason.ResourceHarvested);
        }
コード例 #7
0
        public void PlayerGathering(Player player, GatherEvent ge)
        {
            string[] playerProperties = RankModule.TryToGetPlayerProperties(player);
            if (playerProperties == null)
            {
                return;
            }
            string str = playerProperties[1];
            double num = double.Parse(this.ds.Get("Rank++Gathering", (object)str).ToString());

            this.ds.Add("Rank++Gathering", (object)str, (object)(num + 1.0));
        }
コード例 #8
0
        public static async Task ProcessEvent(GatherEvent ev, UrlHelper url, HttpContextBase context, dynamic viewBag)
        {
            if (ev.State != "completed")
            {
                return;
            }
            var call = (Call)viewBag.Call;

            //make hangup on press any key
            if (ev.Tag == "stop-recording")
            {
                await call.HangUp();
            }
        }
コード例 #9
0
        public static void PlayerGatherWood(IMeleeWeaponItem rec, ResourceTarget rt, ref ItemDataBlock db, ref int amount, ref string name)
        {
            Magma.Player player = Magma.Player.FindByNetworkPlayer(rec.inventory.networkView.owner);
            GatherEvent  ge     = new GatherEvent(rt, db, amount)
            {
                Item = "Wood"
            };

            if (OnPlayerGathering != null)
            {
                OnPlayerGathering(player, ge);
            }
            db     = Magma.Server.GetServer().Items.Find(ge.Item);
            amount = ge.Quantity;
            name   = ge.Item;
        }
コード例 #10
0
        public static void PlayerGather(Inventory rec, ResourceTarget rt, ResourceGivePair rg, ref int amount)
        {
            Magma.Player player = Magma.Player.FindByNetworkPlayer(rec.networkView.owner);
            GatherEvent  ge     = new GatherEvent(rt, rg, amount);

            if (OnPlayerGathering != null)
            {
                OnPlayerGathering(player, ge);
            }
            amount = ge.Quantity;
            if (!ge.Override)
            {
                amount = Mathf.Min(amount, rg.AmountLeft());
            }
            rg._resourceItemDatablock = ge.Item;
            rg.ResourceItemName       = ge.Item;
        }
コード例 #11
0
ファイル: Hooks.cs プロジェクト: slavagmail/Fougerite
 public static void PlayerGatherWood(IMeleeWeaponItem rec, ResourceTarget rt, ref ItemDataBlock db, ref int amount, ref string name)
 {
     try
     {
         Fougerite.Player player = Fougerite.Player.FindByNetworkPlayer(rec.inventory.networkView.owner);
         //Fougerite.Player player = Fougerite.Server.Cache[rec.inventory.networkView.owner.id];
         GatherEvent ge = new GatherEvent(rt, db, amount);
         ge.Item = "Wood";
         if (OnPlayerGathering != null)
         {
             OnPlayerGathering(player, ge);
         }
         db     = Fougerite.Server.GetServer().Items.Find(ge.Item);
         amount = ge.Quantity;
         name   = ge.Item;
     }
     catch { }
 }
コード例 #12
0
 public void OnPlayerGathering(Player player, GatherEvent evt)
 {
     Invoke("On_PlayerGathering", player, evt);
 }
コード例 #13
0
        public static async Task ProcessEvent(GatherEvent ev, UrlHelper url, HttpContextBase context, dynamic viewBag)
        {
            var call      = (Call)viewBag.Call;
            var user      = (ApplicationUser)viewBag.User;
            var dbContext = context.GetOwinContext().Get <ApplicationDbContext>();

            if (ev.State != "completed")
            {
                return;
            }
            var tags = ev.Tag.Split(':');
            var tag  = tags.FirstOrDefault();

            if (string.IsNullOrEmpty(tag))
            {
                return;
            }
            switch (tag)
            {
            case "recording":
                await call.RecordingOff();

                await call.SpeakSentence("Your greeting has been recorded. Thank you.", "stop-recording");

                break;

            case "main-menu":
                switch (ev.Digits)
                {
                case "1":
                    await PlayVoiceMailMessage(user, call, user.VoiceMessages.Count - 1);

                    break;

                case "2":
                    await VoiceMailMenu(call);

                    break;

                default:
                    await MainMenu(call);

                    break;
                }
                break;

            case "voice-mail-menu":
                switch (ev.Digits)
                {
                case "0":
                    await MainMenu(call);

                    break;

                case "1":
                    await
                    call.SpeakSentence("Say your greeting now. Press # to stop recording.",
                                       "start-recording");

                    break;

                case "2":
                    await call.SpeakSentence("Your greating", "listen-to-recording");

                    break;

                case "3":
                    await call.SpeakSentence("Your greating will be set to default", "remove-recording");

                    break;

                default:
                    await VoiceMailMenu(call);

                    break;
                }
                break;

            case "voice-message-menu":
                var index = int.Parse(tags[1]);
                switch (ev.Digits)
                {
                case "0":
                    await MainMenu(call);

                    break;

                case "1":
                    await PlayVoiceMailMessage(user, call, index - 1);

                    break;

                case "2":
                    dbContext.VoiceMessages.Remove(user.VoiceMessages[index]);
                    await dbContext.SaveChangesAsync();
                    await PlayVoiceMailMessage(user, call, index - 1);

                    break;

                case "3":
                    await PlayVoiceMailMessage(user, call, index);

                    break;

                default:
                    await VoiceMessageMenu(call, index);

                    break;
                }
                break;
            }
        }
コード例 #14
0
ファイル: Pawn.cs プロジェクト: bytecode0101/WarGame
 /// <summary>
 /// GatherEvent invoker
 /// </summary>
 public void GatherResources()
 {
     GatherEvent?.Invoke();
 }
コード例 #15
0
 private async Task ProcessCalledToOwnerEvent(GatherEvent ev, TinyIoCContainer container)
 {
     var call = new Call {Id = ev.CallId};
     if (ev.State == "completed")
     {
         if (AgentPhoneNumber != null)
         {
             await
                 CurrentConferenceMember
                     .Update(new Dictionary<string, object> {{"hold", true}});
             var digits = ev.Digits;
             if (digits[0] == '1')
             {
                 await
                     call.SpeakSentence(
                         "Leave you message after signal. Press # to complete recording.",
                         "start-recording-message");
             }
             if (digits[0] == '2')
             {
                 Trace.WriteLine("Play voice messages");
                 await PlayVoiceMessage(container, call);
             }
         }
     }
 }
コード例 #16
0
 private async Task ProcessCalledToAgentEvent(GatherEvent ev, TinyIoCContainer container)
 {
     var call = new Call {Id = ev.CallId};
     if (ev.State == "completed")
     {
         if (ev.Digits == "1")
         {
             var conference = CurrentConference;
             if (conference != null)
             {
                 await conference.CreateMember(new Dictionary<string, object> {{"callId", ev.CallId}});
             }
         }
         if (ev.Digits == "2")
         {
             await call.HangUp();
             call = CurrentCall;
             if (call != null && CurrentConferenceMember != null)
             {
                 await call.CreateGather("Press 1 to leave a message. Press 2 to listen to messages.");
             }
         }
     }
 }
コード例 #17
0
ファイル: Hooks.cs プロジェクト: Notulp/Pluton.Rust
        /// <summary>
        /// Called from <c>ResourceDispenser.GiveResourceFromItem(BaseEntity, ItemAmount, float, float, AttackEntity)</c> .
        /// </summary>
        public static void On_PlayerGathering(ResourceDispenser dispenser,
                                              BaseEntity to,
                                              ItemAmount itemAmount,
                                              float gatherDamage,
                                              float destroyFraction)
        {
            BaseEntity from = (BaseEntity)dispenser.GetFieldValue("baseEntity");

            if (itemAmount.amount == 0)
                return;

            float num = gatherDamage / from.MaxHealth();
            float num2 = itemAmount.startAmount / (float)dispenser.GetFieldValue("startingItemCounts");
            float value = itemAmount.startAmount * num / num2;
            float num3 = Mathf.Clamp(value, 0, itemAmount.amount);
            float num4 = num3 * destroyFraction * 2;

            if (itemAmount.amount < num3 + num4) {
                itemAmount.amount -= destroyFraction * num3;
                num3 = itemAmount.amount;
                num4 = 0;
            }

            float amount = itemAmount.amount;

            itemAmount.amount -= num3;

            if (itemAmount.amount < 0) {
                itemAmount.amount = 0;
            }

            int num5 = Mathf.Clamp(Mathf.RoundToInt(num3), 0, Mathf.CeilToInt(amount));

            itemAmount.amount -= num4;

            if (itemAmount.amount < 0) {
                itemAmount.amount = 0;
            }

            GatherEvent ge = new GatherEvent(dispenser, from, to, itemAmount, num5);

            OnNext("On_PlayerGathering", ge);

            if (ge.Amount <= 0)
                return;

            Item item = ItemManager.CreateByItemID(itemAmount.itemid, ge.Amount);

            if (item == null)
                return;

            to.GiveItem(item, BaseEntity.GiveItemReason.ResourceHarvested);
        }
コード例 #18
0
        static void OnPlayerGathering(Fougerite.Player player, GatherEvent ge)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (!UserIsLogged(player))
            {
                char ch = '☢';
                player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                ge.Quantity = 0;
                return;
            }
            User           user     = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
            ResourceTarget resource = ge.ResourceTarget;
            int            quantity = ge.Quantity;

            if (resource != null)
            {
                if (resource.type == ResourceTarget.ResourceTargetType.WoodPile)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (((quantity * user.LumberjackLevel - 1) / 2) * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity = ((quantity * user.LumberjackLevel - 1) / 2) - clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        user.AddWoodExp(quantity);
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
                else if (resource.type == ResourceTarget.ResourceTargetType.Rock1 || resource.type == ResourceTarget.ResourceTargetType.Rock2 || resource.type == ResourceTarget.ResourceTargetType.Rock3)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;

                        quantity = (quantity * user.MinerLevel - 1) / 2;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (quantity * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity -= clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        if (ge.Item == "Metal Ore")
                        {
                            user.AddMetalExp(quantity);
                        }
                        else if (ge.Item == "Sulfur Ore")
                        {
                            user.AddSulfureExp(quantity);
                        }
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
            }
        }
コード例 #19
0
ファイル: HookTester.cs プロジェクト: Notulp/HookTester
 public void On_PlayerGathering(GatherEvent ge)
 {
     SetHookWorking("On_PlayerGathering");
     Broadcast(ge.Gatherer.Name + " collected " + ge.Amount + "x" + ge.Resource.baseEntity.ShortPrefabName);
 }
コード例 #20
0
 public void OnPlayerGathering(Fougerite.Player player, GatherEvent evt)
 {
     this.Invoke("On_PlayerGathering", new object[] { player, evt });
 }
コード例 #21
0
ファイル: BasePlugin.cs プロジェクト: ICodeMaster/Pluton
 public void OnPlayerGathering(GatherEvent ge)
 {
     this.Invoke("On_PlayerGathering", ge);
 }