private void CreateRecycler(BasePlayer p) { Recycler r = GameManager.server.CreateEntity(Recycle.RecyclePrefab, p.transform.position + Vector3.up * 4000) as Recycler; r.recycleEfficiency = this.Data.Settings.RefundRatio; r.enableSaving = false; r.SetFlag(BaseEntity.Flags.Locked, true); r.UpdateNetworkGroup(); r.Spawn(); if (!r.isSpawned) { return; } r.gameObject.layer = 0; r.SendNetworkUpdateImmediate(true); this.Subscribe(nameof(CanNetworkTo)); this.OpenContainer(p, r); this.Recyclers.Add(r.net.ID, new EntityAndPlayer { Entity = r, Player = p }); }
private object CanAcceptItem(ItemContainer con, Item i, int target) { if (con.entityOwner is Recycler) { Recycler r = con.entityOwner as Recycler; if (this.IsRecycleBox(r)) { BasePlayer p = this.PlayerFromRecycler(r.net.ID); if (p == null) { return(null); } if (target < 6) { if (!this.Data.Settings.RecyclableTypes.Contains(Enum.GetName(typeof(ItemCategory), i.info.category)) || this.Data.Settings.Blacklist.Contains(i.info.shortname)) { if (p != null) { this.PrintToChat(p, this.GetMessage("Recycle", "Invalid", p)); } return(ItemContainer.CanAcceptResult.CannotAcceptRightNow); } else { NextFrame(() => { if (r == null || !r.HasRecyclable()) { return; } if (this.Data.Settings.InstantRecycling) { if (!r.IsOn()) { r.InvokeRepeating(new Action(r.RecycleThink), 0, 0); r.SetFlag(BaseEntity.Flags.On, true, false, true); r.SendNetworkUpdateImmediate(); } } else { r.StartRecycling(); } }); } } else if (this.Data.Settings.ToInventory) { NextFrame(() => { if (p == null || p.inventory == null || p.inventory.containerMain == null || p.inventory.containerBelt == null || i == null) { return; } bool flag = false; if (!p.inventory.containerMain.IsFull()) { flag = i.MoveToContainer(p.inventory.containerMain); } if (!flag && !p.inventory.containerBelt.IsFull()) { i.MoveToContainer(p.inventory.containerBelt); } }); } } } return(null); }