Exemplo n.º 1
0
 public static void lootContainerOpened(TileEntityLootContainer _te, LocalPlayerUI _playerUI, int _entityIdThatOpenedIt)
 {
     if (_playerUI != null)
     {
         bool   flag = true;
         string lootContainerName = string.Empty;
         if (_te.entityId != -1)
         {
             Entity entity = GameManager.Instance.World.GetEntity(_te.entityId);
             if (entity != null)
             {
                 lootContainerName = Localization.Get(EntityClass.list[entity.entityClass].entityClassName, "");
                 if (entity is EntityVehicle)
                 {
                     flag = false;
                 }
             }
         }
         else
         {
             BlockValue block = GameManager.Instance.World.GetBlock(_te.ToWorldPos());
             lootContainerName = Localization.Get(Block.list[block.type].GetBlockName(), "");
         }
         if (flag)
         {
             ((XUiC_LootWindowGroup)((XUiWindowGroup)_playerUI.windowManager.GetWindow("looting")).Controller).SetTileEntityChest(lootContainerName, _te);
             _playerUI.windowManager.Open("looting", true, false, true);
         }
         LootContainer lootContainer = LootContainer.lootList[_te.lootListIndex];
         if (lootContainer != null && _playerUI.entityPlayer != null)
         {
             lootContainer.ExecuteBuffActions(_te.entityId, _playerUI.entityPlayer);
         }
     }
     if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
     {
         GameManager.Instance.lootManager.LootContainerOpened(_te, _entityIdThatOpenedIt);
         _te.bTouched = true;
         _te.SetModified();
     }
 }
Exemplo n.º 2
0
 private static void Penalty(PlayerDataFile _pdf, ClientInfo _cInfo)
 {
     try
     {
         Chunk chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos((int)_pdf.ecd.pos.x, (int)_pdf.ecd.pos.y, (int)_pdf.ecd.pos.z);
         if (chunk != null)
         {
             BlockValue _blockValue = Block.GetBlockValue("cntStorageChest");
             if (_blockValue.Block != null)
             {
                 Vector3i _pos = new Vector3i((int)_pdf.ecd.pos.x, (int)_pdf.ecd.pos.y, (int)_pdf.ecd.pos.z);
                 GameManager.Instance.World.SetBlockRPC(chunk.ClrIdx, _pos, _blockValue);
                 TileEntityLootContainer tileEntityLootContainer = GameManager.Instance.World.GetTileEntity(chunk.ClrIdx, _pos) as TileEntityLootContainer;
                 if (tileEntityLootContainer != null)
                 {
                     if (All || Bag)
                     {
                         for (int i = 0; i < _pdf.bag.Length; i++)
                         {
                             if (!_pdf.bag[i].IsEmpty())
                             {
                                 tileEntityLootContainer.AddItem(_pdf.bag[i]);
                                 _pdf.bag[i] = ItemStack.Empty.Clone();
                             }
                         }
                     }
                     if (All || Belt)
                     {
                         for (int i = 0; i < _pdf.inventory.Length; i++)
                         {
                             if (!_pdf.inventory[i].IsEmpty())
                             {
                                 tileEntityLootContainer.AddItem(_pdf.inventory[i]);
                                 _pdf.inventory[i] = ItemStack.Empty.Clone();
                             }
                         }
                     }
                     if (All || Equipment)
                     {
                         ItemValue[] _equipmentValues = _pdf.equipment.GetItems();
                         for (int i = 0; i < _equipmentValues.Length; i++)
                         {
                             if (!_equipmentValues[i].IsEmpty())
                             {
                                 ItemStack _itemStack = new ItemStack(_equipmentValues[i], 1);
                                 tileEntityLootContainer.AddItem(_itemStack);
                                 _equipmentValues[i].Clear();
                             }
                         }
                     }
                     if (tileEntityLootContainer.IsEmpty())
                     {
                         GameManager.Instance.World.SetBlockRPC(chunk.ClrIdx, _pos, BlockValue.Air);
                     }
                     else
                     {
                         tileEntityLootContainer.SetModified();
                     }
                     PersistentOperations.SavePlayerDataFile(_cInfo.playerId, _pdf);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BattleLogger.Penalty: {0}", e.Message));
     }
 }
Exemplo n.º 3
0
 private static void Penalty(ClientInfo _cInfo)
 {
     try
     {
         PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId);
         if (_pdf != null)
         {
             Vector3i _pos = new Vector3i((int)_pdf.ecd.pos.x, (int)_pdf.ecd.pos.y, (int)_pdf.ecd.pos.z);
             if (GameManager.Instance.World.IsChunkAreaLoaded(_pos.x, _pos.y, _pos.z))
             {
                 Chunk chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(_pos.x, _pos.y, _pos.z);
                 if (chunk != null)
                 {
                     BlockValue _blockValue = Block.GetBlockValue("cntStorageChest");
                     if (_blockValue.Block != null)
                     {
                         GameManager.Instance.World.SetBlockRPC(chunk.ClrIdx, _pos, _blockValue);
                         TileEntityLootContainer tileEntityLootContainer = GameManager.Instance.World.GetTileEntity(chunk.ClrIdx, _pos) as TileEntityLootContainer;
                         if (tileEntityLootContainer != null)
                         {
                             if (All || Bag)
                             {
                                 for (int i = 0; i < _pdf.bag.Length; i++)
                                 {
                                     if (!_pdf.bag[i].IsEmpty())
                                     {
                                         tileEntityLootContainer.AddItem(_pdf.bag[i]);
                                         _pdf.bag[i] = ItemStack.Empty.Clone();
                                     }
                                 }
                             }
                             if (All || Belt)
                             {
                                 for (int i = 0; i < _pdf.inventory.Length; i++)
                                 {
                                     if (!_pdf.inventory[i].IsEmpty())
                                     {
                                         tileEntityLootContainer.AddItem(_pdf.inventory[i]);
                                         _pdf.inventory[i] = ItemStack.Empty.Clone();
                                     }
                                 }
                             }
                             if (All || Equipment)
                             {
                                 ItemValue[] _equipmentValues = _pdf.equipment.GetItems();
                                 for (int i = 0; i < _equipmentValues.Length; i++)
                                 {
                                     if (!_equipmentValues[i].IsEmpty())
                                     {
                                         ItemStack _itemStack = new ItemStack(_equipmentValues[i], 1);
                                         tileEntityLootContainer.AddItem(_itemStack);
                                         _equipmentValues[i].Clear();
                                     }
                                 }
                             }
                             if (tileEntityLootContainer.IsEmpty())
                             {
                                 GameManager.Instance.World.SetBlockRPC(chunk.ClrIdx, _pos, BlockValue.Air);
                             }
                             else
                             {
                                 tileEntityLootContainer.SetModified();
                             }
                             PersistentOperations.SavePlayerDataFile(_cInfo.playerId, _pdf);
                         }
                     }
                 }
             }
             else
             {
                 ChunkManager.ChunkObserver _observer = GameManager.Instance.AddChunkObserver(_pos.ToVector3(), false, 2, -1);
                 if (_observer != null)
                 {
                     Thread.Sleep(1000);
                     Chunk _chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(_pos.x, _pos.y, _pos.z);
                     if (_chunk != null)
                     {
                         EntityBackpack entityBackpack = new EntityBackpack();
                         entityBackpack               = EntityFactory.CreateEntity("Backpack".GetHashCode(), _pdf.ecd.pos + Vector3.up * 2f) as EntityBackpack;
                         entityBackpack.RefPlayerId   = _pdf.ecd.clientEntityId;
                         entityBackpack.lootContainer = new TileEntityLootContainer(null);
                         entityBackpack.lootContainer.SetUserAccessing(true);
                         entityBackpack.lootContainer.SetEmpty();
                         entityBackpack.lootContainer.lootListIndex = entityBackpack.GetLootList();
                         entityBackpack.lootContainer.SetContainerSize(LootContainer.lootList[entityBackpack.GetLootList()].size, true);
                         if (All || Bag)
                         {
                             for (int i = 0; i < _pdf.bag.Length; i++)
                             {
                                 if (!_pdf.bag[i].IsEmpty())
                                 {
                                     entityBackpack.lootContainer.AddItem(_pdf.bag[i]);
                                     _pdf.bag[i] = ItemStack.Empty.Clone();
                                 }
                             }
                         }
                         if (All || Belt)
                         {
                             for (int i = 0; i < _pdf.inventory.Length; i++)
                             {
                                 if (!_pdf.inventory[i].IsEmpty())
                                 {
                                     entityBackpack.lootContainer.AddItem(_pdf.inventory[i]);
                                     _pdf.inventory[i] = ItemStack.Empty.Clone();
                                 }
                             }
                         }
                         if (All || Equipment)
                         {
                             ItemValue[] _equipmentValues = _pdf.equipment.GetItems();
                             for (int i = 0; i < _equipmentValues.Length; i++)
                             {
                                 if (!_equipmentValues[i].IsEmpty())
                                 {
                                     ItemStack _itemStack = new ItemStack(_equipmentValues[i], 1);
                                     entityBackpack.lootContainer.AddItem(_itemStack);
                                     _equipmentValues[i].Clear();
                                 }
                             }
                         }
                         _pdf.droppedBackpackPosition = new Vector3i(_pdf.ecd.pos);
                         entityBackpack.lootContainer.bPlayerBackpack = true;
                         entityBackpack.lootContainer.SetUserAccessing(false);
                         entityBackpack.lootContainer.SetModified();
                         entityBackpack.entityId    = -1;
                         entityBackpack.RefPlayerId = _pdf.ecd.clientEntityId;
                         EntityCreationData entityCreationData = new EntityCreationData(entityBackpack);
                         entityCreationData.entityName    = string.Format(Localization.Get("playersBackpack"), _pdf.ecd.entityName);
                         entityCreationData.id            = -1;
                         entityCreationData.lootContainer = entityBackpack.lootContainer.Clone();
                         PersistentOperations.SavePlayerDataFile(_cInfo.playerId, _pdf);
                         GameManager.Instance.RequestToSpawnEntityServer(entityCreationData);
                         entityBackpack.OnEntityUnload();
                     }
                     GameManager.Instance.RemoveChunkObserver(_observer);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ExitCommand.Penalty: {0}", e.Message));
     }
 }