예제 #1
0
 // Token: 0x0600284A RID: 10314 RVA: 0x000F4490 File Offset: 0x000F2890
 private bool respawnItems()
 {
     if (Level.info == null || Level.info.type == ELevelType.ARENA)
     {
         return(false);
     }
     if (LevelItems.spawns[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].Count > 0)
     {
         if (Time.realtimeSinceStartup - ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].lastRespawn > Provider.modeConfigData.Items.Respawn_Time && (float)ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].items.Count < (float)LevelItems.spawns[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].Count * Provider.modeConfigData.Items.Spawn_Chance)
         {
             ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].lastRespawn = Time.realtimeSinceStartup;
             ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y][UnityEngine.Random.Range(0, LevelItems.spawns[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].Count)];
             if (!SafezoneManager.checkPointValid(itemSpawnpoint.point))
             {
                 return(false);
             }
             ushort num = 0;
             while ((int)num < ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].items.Count)
             {
                 if ((ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].items[(int)num].point - itemSpawnpoint.point).sqrMagnitude < 4f)
                 {
                     return(false);
                 }
                 num += 1;
             }
             ushort    item      = LevelItems.getItem(itemSpawnpoint);
             ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, item);
             if (itemAsset != null)
             {
                 Item     item2    = new Item(item, EItemOrigin.WORLD);
                 ItemData itemData = new ItemData(item2, ItemManager.instanceCount += 1u, itemSpawnpoint.point, false);
                 ItemManager.regions[(int)ItemManager.respawnItems_X, (int)ItemManager.respawnItems_Y].items.Add(itemData);
                 ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                 {
                     ItemManager.respawnItems_X,
                     ItemManager.respawnItems_Y,
                     item2.id,
                     item2.quality,
                     item2.state,
                     itemSpawnpoint.point,
                     itemData.instanceID
                 });
             }
             else
             {
                 CommandWindow.LogError(string.Concat(new object[]
                 {
                     "Failed to respawn an item with ID ",
                     item,
                     " from type ",
                     itemSpawnpoint.type,
                     "!"
                 }));
             }
         }
         return(false);
     }
     return(true);
 }
예제 #2
0
        // Token: 0x060024E7 RID: 9447 RVA: 0x000D38C0 File Offset: 0x000D1CC0
        public static void save()
        {
            Block block = new Block();

            block.writeByte(LevelItems.SAVEDATA_VERSION);
            block.writeByte((byte)LevelItems.tables.Count);
            byte b = 0;

            while ((int)b < LevelItems.tables.Count)
            {
                ItemTable itemTable = LevelItems.tables[(int)b];
                block.writeColor(itemTable.color);
                block.writeString(itemTable.name);
                block.writeUInt16(itemTable.tableID);
                block.write((byte)itemTable.tiers.Count);
                byte b2 = 0;
                while ((int)b2 < itemTable.tiers.Count)
                {
                    ItemTier itemTier = itemTable.tiers[(int)b2];
                    block.writeString(itemTier.name);
                    block.writeSingle(itemTier.chance);
                    block.writeByte((byte)itemTier.table.Count);
                    byte b3 = 0;
                    while ((int)b3 < itemTier.table.Count)
                    {
                        ItemSpawn itemSpawn = itemTier.table[(int)b3];
                        block.writeUInt16(itemSpawn.item);
                        b3 += 1;
                    }
                    b2 += 1;
                }
                b += 1;
            }
            ReadWrite.writeBlock(Level.info.path + "/Spawns/Items.dat", false, false, block);
            River river = new River(Level.info.path + "/Spawns/Jars.dat", false);

            river.writeByte(LevelItems.SAVEDATA_VERSION);
            for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1)
            {
                for (byte b5 = 0; b5 < Regions.WORLD_SIZE; b5 += 1)
                {
                    List <ItemSpawnpoint> list = LevelItems.spawns[(int)b4, (int)b5];
                    river.writeUInt16((ushort)list.Count);
                    ushort num = 0;
                    while ((int)num < list.Count)
                    {
                        ItemSpawnpoint itemSpawnpoint = list[(int)num];
                        river.writeByte(itemSpawnpoint.type);
                        river.writeSingleVector3(itemSpawnpoint.point);
                        num += 1;
                    }
                }
            }
            river.closeRiver();
        }
예제 #3
0
        // Token: 0x0600284B RID: 10315 RVA: 0x000F475C File Offset: 0x000F2B5C
        private void generateItems(byte x, byte y)
        {
            if (Level.info == null || Level.info.type == ELevelType.ARENA)
            {
                return;
            }
            List <ItemData> list = new List <ItemData>();

            if (LevelItems.spawns[(int)x, (int)y].Count > 0)
            {
                List <ItemSpawnpoint> list2 = new List <ItemSpawnpoint>();
                for (int i = 0; i < LevelItems.spawns[(int)x, (int)y].Count; i++)
                {
                    ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)x, (int)y][i];
                    if (SafezoneManager.checkPointValid(itemSpawnpoint.point))
                    {
                        list2.Add(itemSpawnpoint);
                    }
                }
                while ((float)list.Count < (float)LevelItems.spawns[(int)x, (int)y].Count * Provider.modeConfigData.Items.Spawn_Chance && list2.Count > 0)
                {
                    int            index           = UnityEngine.Random.Range(0, list2.Count);
                    ItemSpawnpoint itemSpawnpoint2 = list2[index];
                    list2.RemoveAt(index);
                    ushort    item      = LevelItems.getItem(itemSpawnpoint2);
                    ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, item);
                    if (itemAsset != null)
                    {
                        Item newItem = new Item(item, EItemOrigin.WORLD);
                        list.Add(new ItemData(newItem, ItemManager.instanceCount += 1u, itemSpawnpoint2.point, false));
                    }
                    else
                    {
                        CommandWindow.LogError(string.Concat(new object[]
                        {
                            "Failed to generate an item with ID ",
                            item,
                            " from type ",
                            itemSpawnpoint2.type,
                            "!"
                        }));
                    }
                }
            }
            for (int j = 0; j < ItemManager.regions[(int)x, (int)y].items.Count; j++)
            {
                if (ItemManager.regions[(int)x, (int)y].items[j].isDropped)
                {
                    list.Add(ItemManager.regions[(int)x, (int)y].items[j]);
                }
            }
            ItemManager.regions[(int)x, (int)y].items = list;
        }
예제 #4
0
 // Token: 0x060024E1 RID: 9441 RVA: 0x000D3130 File Offset: 0x000D1530
 public static void removeTable()
 {
     LevelItems.tables.RemoveAt((int)EditorSpawns.selectedItem);
     for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
     {
         for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
         {
             List <ItemSpawnpoint> list = new List <ItemSpawnpoint>();
             for (int i = 0; i < LevelItems.spawns[(int)b, (int)b2].Count; i++)
             {
                 ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)b, (int)b2][i];
                 if (itemSpawnpoint.type == EditorSpawns.selectedItem)
                 {
                     UnityEngine.Object.Destroy(itemSpawnpoint.node.gameObject);
                 }
                 else
                 {
                     if (itemSpawnpoint.type > EditorSpawns.selectedItem)
                     {
                         ItemSpawnpoint itemSpawnpoint2 = itemSpawnpoint;
                         itemSpawnpoint2.type -= 1;
                     }
                     list.Add(itemSpawnpoint);
                 }
             }
             LevelItems._spawns[(int)b, (int)b2] = list;
         }
     }
     for (int j = 0; j < LevelZombies.tables.Count; j++)
     {
         ZombieTable zombieTable = LevelZombies.tables[j];
         if (zombieTable.lootIndex > EditorSpawns.selectedItem)
         {
             ZombieTable zombieTable2 = zombieTable;
             zombieTable2.lootIndex -= 1;
         }
     }
     EditorSpawns.selectedItem = 0;
     if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
     {
         EditorSpawns.itemSpawn.GetComponent <Renderer>().material.color = LevelItems.tables[(int)EditorSpawns.selectedItem].color;
     }
 }
예제 #5
0
 // Token: 0x060024E3 RID: 9443 RVA: 0x000D32F4 File Offset: 0x000D16F4
 public static void removeSpawn(Vector3 point, float radius)
 {
     radius *= radius;
     for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
     {
         for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
         {
             List <ItemSpawnpoint> list = new List <ItemSpawnpoint>();
             for (int i = 0; i < LevelItems.spawns[(int)b, (int)b2].Count; i++)
             {
                 ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)b, (int)b2][i];
                 if ((itemSpawnpoint.point - point).sqrMagnitude < radius)
                 {
                     UnityEngine.Object.Destroy(itemSpawnpoint.node.gameObject);
                 }
                 else
                 {
                     list.Add(itemSpawnpoint);
                 }
             }
             LevelItems._spawns[(int)b, (int)b2] = list;
         }
     }
 }
예제 #6
0
 // Token: 0x060024E4 RID: 9444 RVA: 0x000D33B7 File Offset: 0x000D17B7
 public static ushort getItem(ItemSpawnpoint spawn)
 {
     return(LevelItems.getItem(spawn.type));
 }
예제 #7
0
        // Token: 0x0600287A RID: 10362 RVA: 0x000F56AC File Offset: 0x000F3AAC
        private void arenaSpawn()
        {
            for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
            {
                for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
                {
                    if (LevelItems.spawns[(int)b, (int)b2].Count > 0)
                    {
                        for (int i = 0; i < LevelItems.spawns[(int)b, (int)b2].Count; i++)
                        {
                            ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)b, (int)b2][i];
                            ushort         item           = LevelItems.getItem(itemSpawnpoint);
                            if (item != 0)
                            {
                                Item item2 = new Item(item, EItemOrigin.ADMIN);
                                ItemManager.dropItem(item2, itemSpawnpoint.point, false, false, false);
                            }
                        }
                    }
                }
            }
            List <VehicleSpawnpoint> spawns = LevelVehicles.spawns;

            for (int j = 0; j < spawns.Count; j++)
            {
                VehicleSpawnpoint vehicleSpawnpoint = spawns[j];
                ushort            vehicle           = LevelVehicles.getVehicle(vehicleSpawnpoint);
                if (vehicle != 0)
                {
                    Vector3 point = vehicleSpawnpoint.point;
                    point.y += 1f;
                    VehicleManager.spawnVehicle(vehicle, point, Quaternion.Euler(0f, vehicleSpawnpoint.angle, 0f));
                }
            }
            List <PlayerSpawnpoint> altSpawns = LevelPlayers.getAltSpawns();
            float num = LevelManager.arenaCurrentRadius - SafezoneNode.MIN_SIZE;

            num *= num;
            for (int k = altSpawns.Count - 1; k >= 0; k--)
            {
                PlayerSpawnpoint playerSpawnpoint = altSpawns[k];
                float            num2             = Mathf.Pow(playerSpawnpoint.point.x - LevelManager.arenaCurrentCenter.x, 2f) + Mathf.Pow(playerSpawnpoint.point.z - LevelManager.arenaCurrentCenter.z, 2f);
                if (num2 > num)
                {
                    altSpawns.RemoveAt(k);
                }
            }
            for (int l = 0; l < Provider.clients.Count; l++)
            {
                if (altSpawns.Count == 0)
                {
                    break;
                }
                SteamPlayer steamPlayer = Provider.clients[l];
                if (steamPlayer != null && !(steamPlayer.player == null) && !steamPlayer.player.life.isDead)
                {
                    int index = UnityEngine.Random.Range(0, altSpawns.Count);
                    PlayerSpawnpoint playerSpawnpoint2 = altSpawns[index];
                    altSpawns.RemoveAt(index);
                    ArenaPlayer arenaPlayer = new ArenaPlayer(steamPlayer);
                    arenaPlayer.steamPlayer.player.life.sendRevive();
                    arenaPlayer.steamPlayer.player.sendTeleport(playerSpawnpoint2.point, MeasurementTool.angleToByte(playerSpawnpoint2.angle));
                    LevelManager.arenaPlayers.Add(arenaPlayer);
                    foreach (ArenaLoadout arenaLoadout in Level.info.configData.Arena_Loadouts)
                    {
                        for (ushort num3 = 0; num3 < arenaLoadout.Amount; num3 += 1)
                        {
                            ushort newID = SpawnTableTool.resolve(arenaLoadout.Table_ID);
                            arenaPlayer.steamPlayer.player.inventory.forceAddItemAuto(new Item(newID, true), true, false, true, false);
                        }
                    }
                }
            }
            this.arenaAirdrop();
            LevelManager.arenaState = EArenaState.PLAY;
            base.channel.send("tellLevelNumber", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
            {
                (byte)LevelManager.arenaPlayers.Count
            });
        }