Exemple #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);
 }
 private static void onClickedRemoveTableButton(SleekButton button)
 {
     if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
     {
         LevelItems.removeTable();
         EditorSpawnsItemsUI.updateTables();
         EditorSpawnsItemsUI.updateSelection();
         EditorSpawnsItemsUI.tableScrollBox.state = new Vector2(0f, float.MaxValue);
     }
 }
 private static void onClickedAddTableButton(SleekButton button)
 {
     if (EditorSpawnsItemsUI.tableNameField.text != string.Empty)
     {
         LevelItems.addTable(EditorSpawnsItemsUI.tableNameField.text);
         EditorSpawnsItemsUI.tableNameField.text = string.Empty;
         EditorSpawnsItemsUI.updateTables();
         EditorSpawnsItemsUI.tableScrollBox.state = new Vector2(0f, float.MaxValue);
     }
 }
Exemple #4
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;
        }
Exemple #5
0
		public static void save()
		{
			LevelObjects.save();
			LevelLighting.save();
			LevelGround.save();
			LevelRoads.save();
			if (!Level.isVR)
			{
				LevelNavigation.save();
				LevelNodes.save();
				LevelItems.save();
				LevelPlayers.save();
				LevelZombies.save();
				LevelVehicles.save();
				LevelAnimals.save();
				LevelVisibility.save();
			}
			Editor.save();
		}
Exemple #6
0
 // Token: 0x060024E4 RID: 9444 RVA: 0x000D33B7 File Offset: 0x000D17B7
 public static ushort getItem(ItemSpawnpoint spawn)
 {
     return(LevelItems.getItem(spawn.type));
 }
Exemple #7
0
		public IEnumerator init(int id)
		{
			if (!Level.isVR)
			{
				LevelNavigation.load();
			}
			LoadingUI.updateProgress(1f / Level.STEPS);
			yield return null;
			LevelObjects.load();
			LoadingUI.updateProgress(2f / Level.STEPS);
			yield return null;
			LevelLighting.load(Level.size);
			LoadingUI.updateProgress(3f / Level.STEPS);
			yield return null;
			LevelGround.load(Level.size);
			LoadingUI.updateProgress(4f / Level.STEPS);
			yield return null;
			LevelRoads.load();
			LoadingUI.updateProgress(5f / Level.STEPS);
			yield return null;
			if (!Level.isVR)
			{
				LevelNodes.load();
				LoadingUI.updateProgress(6f / Level.STEPS);
				yield return null;
				LevelItems.load();
				LoadingUI.updateProgress(7f / Level.STEPS);
				yield return null;
			}
			LevelPlayers.load();
			LoadingUI.updateProgress(8f / Level.STEPS);
			yield return null;
			if (!Level.isVR)
			{
				LevelZombies.load();
				LoadingUI.updateProgress(9f / Level.STEPS);
				yield return null;
				LevelVehicles.load();
				LoadingUI.updateProgress(10f / Level.STEPS);
				yield return null;
				LevelAnimals.load();
				LoadingUI.updateProgress(11f / Level.STEPS);
				yield return null;
			}
			LevelVisibility.load();
			LoadingUI.updateProgress(12f / Level.STEPS);
			yield return null;
			if (Level.loadingSteps != null)
			{
				Level.loadingSteps();
			}
			yield return null;
			LevelBarricades.load();
			yield return null;
			LevelStructures.load();
			Level._hash = Hash.combine(new byte[][]
			{
				Level.getLevelHash(Level.info.path),
				LevelGround.hash,
				LevelLighting.hash,
				LevelObjects.hash
			});
			Physics.gravity = new Vector3(0f, Level.info.configData.Gravity, 0f);
			yield return null;
			Resources.UnloadUnusedAssets();
			GC.Collect();
			yield return null;
			Level._editing = new GameObject().transform;
			Level.editing.name = "Editing";
			Level.editing.parent = Level.level;
			if (Level.isEditor)
			{
				Level.mapper = ((GameObject)Object.Instantiate(Resources.Load("Edit/Mapper"))).transform;
				Level.mapper.name = "Mapper";
				Level.mapper.parent = Level.editing;
				Level.mapper.position = new Vector3(0f, 1028f, 0f);
				Level.mapper.rotation = Quaternion.Euler(90f, 0f, 0f);
				Level.mapper.GetComponent<Camera>().orthographicSize = (float)(Level.size / 2 - Level.border);
				if (Level.isDevkit)
				{
					GameObject gameObject = Object.Instantiate<GameObject>(Resources.Load<GameObject>("Edit2/Editor"));
					if (gameObject != null)
					{
						gameObject.name = "Editor";
						gameObject.transform.parent = Level.editing;
					}
				}
				else
				{
					Transform transform = ((GameObject)Object.Instantiate(Resources.Load((!Level.isVR) ? "Edit/Editor" : "Edit/VR"))).transform;
					transform.name = "Editor";
					transform.parent = Level.editing;
					transform.tag = "Logic";
					transform.gameObject.layer = LayerMasks.LOGIC;
				}
			}
			yield return null;
			if (Level.onPrePreLevelLoaded != null)
			{
				Level.onPrePreLevelLoaded(id);
			}
			yield return null;
			if (Level.onPreLevelLoaded != null)
			{
				Level.onPreLevelLoaded(id);
			}
			yield return null;
			if (Level.onLevelLoaded != null)
			{
				Level.onLevelLoaded(id);
			}
			yield return null;
			if (Level.onPostLevelLoaded != null)
			{
				Level.onPostLevelLoaded(id);
			}
			yield return null;
			if (!Level.isEditor && Level.info != null && Level.info.hasTriggers)
			{
				Transform transform2 = null;
				string text = Level.info.name.ToLower();
				if (text != null)
				{
					if (!(text == "germany"))
					{
						if (!(text == "pei"))
						{
							if (!(text == "russia"))
							{
								if (text == "tutorial")
								{
									transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Tutorial"))).transform;
								}
							}
							else
							{
								transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Russia"))).transform;
							}
						}
						else
						{
							transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_PEI"))).transform;
						}
					}
					else
					{
						transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Germany"))).transform;
					}
				}
				if (transform2 != null)
				{
					transform2.position = Vector3.zero;
					transform2.rotation = Quaternion.identity;
					transform2.name = "Triggers";
					transform2.parent = Level.clips;
				}
			}
			yield return null;
			Level._isLoaded = true;
			Level.isLoadingContent = false;
			yield break;
		}
Exemple #8
0
 private void Update()
 {
     if (!EditorSpawns.isSpawning)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ANIMAL;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ANIMAL;
             }
         }
         if (EditorInteract.worldHit.transform != null)
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.itemSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.playerSpawn.position    = EditorInteract.worldHit.point;
                 EditorSpawns.playerSpawnAlt.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.zombieSpawn.position = EditorInteract.worldHit.point + Vector3.up;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.vehicleSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.animalSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM || EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.remove.position = EditorInteract.worldHit.point;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.primary) && EditorInteract.worldHit.transform != null)
         {
             Vector3 point = EditorInteract.worldHit.point;
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 if ((int)EditorSpawns.selectedResource < LevelGround.resources.Length)
                 {
                     LevelGround.addSpawn(point, EditorSpawns.selectedResource, false);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 LevelGround.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
                 {
                     LevelItems.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 LevelItems.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 LevelPlayers.addSpawn(point, EditorSpawns.rotation, EditorSpawns.selectedAlt);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 LevelPlayers.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
                 {
                     LevelZombies.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 LevelZombies.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 LevelVehicles.addSpawn(point, EditorSpawns.rotation);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 LevelVehicles.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 LevelAnimals.addSpawn(point);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 LevelAnimals.removeSpawn(point, (float)EditorSpawns.radius);
             }
         }
     }
 }
Exemple #9
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
            });
        }