// Token: 0x0600284E RID: 10318 RVA: 0x000F4AEC File Offset: 0x000F2EEC private void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex) { if (step == 0) { for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (player.channel.isOwner && ItemManager.regions[(int)b, (int)b2].isNetworked && !Regions.checkArea(b, b2, new_x, new_y, ItemManager.ITEM_REGIONS)) { ItemManager.regions[(int)b, (int)b2].destroy(); ItemManager.regions[(int)b, (int)b2].isNetworked = false; } if (Provider.isServer && player.movement.loadedRegions[(int)b, (int)b2].isItemsLoaded && !Regions.checkArea(b, b2, new_x, new_y, ItemManager.ITEM_REGIONS)) { player.movement.loadedRegions[(int)b, (int)b2].isItemsLoaded = false; } } } } if (step == 5 && Provider.isServer && Regions.checkSafe((int)new_x, (int)new_y)) { for (int i = (int)(new_x - ItemManager.ITEM_REGIONS); i <= (int)(new_x + ItemManager.ITEM_REGIONS); i++) { for (int j = (int)(new_y - ItemManager.ITEM_REGIONS); j <= (int)(new_y + ItemManager.ITEM_REGIONS); j++) { if (Regions.checkSafe((int)((byte)i), (int)((byte)j)) && !player.movement.loadedRegions[i, j].isItemsLoaded) { if (player.channel.isOwner) { this.generateItems((byte)i, (byte)j); } player.movement.loadedRegions[i, j].isItemsLoaded = true; this.askItems(player.channel.owner.playerID.steamID, (byte)i, (byte)j); } } } } }
public void calculateBounds() { this.cullMagnitude = 64f * this.bias; this.sqrCullMagnitude = this.cullMagnitude * this.cullMagnitude; if (this.lod == EObjectLOD.MESH) { ObjectsLOD.meshes.Clear(); base.GetComponentsInChildren <MeshFilter>(true, ObjectsLOD.meshes); if (ObjectsLOD.meshes.Count == 0) { base.enabled = false; return; } Bounds item = default(Bounds); for (int i = 0; i < ObjectsLOD.meshes.Count; i++) { Mesh sharedMesh = ObjectsLOD.meshes[i].sharedMesh; if (!(sharedMesh == null)) { Bounds bounds = sharedMesh.bounds; item.Encapsulate(bounds.min); item.Encapsulate(bounds.max); } } item.Expand(-1f); item.center += this.center; item.size += this.size; if (item.size.x < 1f || item.size.y < 1f || item.size.z < 1f) { base.enabled = false; return; } this.bounds = new List <Bounds>(); this.bounds.Add(item); } else if (this.lod == EObjectLOD.AREA) { ObjectsLOD.areas.Clear(); base.GetComponentsInChildren <OcclusionArea>(true, ObjectsLOD.areas); if (ObjectsLOD.areas.Count == 0) { base.enabled = false; return; } this.bounds = new List <Bounds>(); for (int j = 0; j < ObjectsLOD.areas.Count; j++) { OcclusionArea occlusionArea = ObjectsLOD.areas[j]; Bounds item2; item2..ctor(occlusionArea.transform.localPosition + occlusionArea.center, new Vector3(occlusionArea.size.x, occlusionArea.size.z, occlusionArea.size.y)); this.bounds.Add(item2); } } this.objects = new List <LevelObject>(); for (int k = 0; k < this.bounds.Count; k++) { Bounds bounds2 = this.bounds[k]; this.cullCenter += bounds2.center; } this.cullCenter /= (float)this.bounds.Count; this.cullCenter = base.transform.TransformPoint(this.cullCenter); byte b; byte b2; Regions.tryGetCoordinate(this.cullCenter, out b, out b2); for (int l = (int)(b - 1); l <= (int)(b + 1); l++) { for (int m = (int)(b2 - 1); m <= (int)(b2 + 1); m++) { for (int n = 0; n < LevelObjects.objects[l, m].Count; n++) { LevelObject levelObject = LevelObjects.objects[l, m][n]; if (levelObject.asset != null && !(levelObject.transform == null) && levelObject.asset.type != EObjectType.LARGE) { if (!levelObject.isSpeciallyCulled) { Vector3 vector = base.transform.InverseTransformPoint(levelObject.transform.position); bool flag = false; for (int num = 0; num < this.bounds.Count; num++) { if (this.bounds[num].Contains(vector)) { flag = true; break; } } if (flag) { levelObject.isSpeciallyCulled = true; this.objects.Add(levelObject); } } } } } } if (this.objects.Count == 0) { base.enabled = false; return; } }
public void send(ESteamCall mode, byte x, byte y, byte area, ESteamPacket type, int size, byte[] packet) { if (mode == ESteamCall.SERVER) { if (Provider.isServer) { this.receive(Provider.server, packet, 0, size); } else { Provider.send(Provider.server, type, packet, size, this.id); } } else if (mode == ESteamCall.ALL) { if (!Provider.isServer) { Provider.send(Provider.server, type, packet, size, this.id); } for (int i = 0; i < Provider.clients.Count; i++) { if (Provider.clients[i].playerID.steamID != Provider.client && Provider.clients[i].player != null && Regions.checkArea(x, y, Provider.clients[i].player.movement.region_x, Provider.clients[i].player.movement.region_y, area)) { Provider.send(Provider.clients[i].playerID.steamID, type, packet, size, this.id); } } if (Provider.isServer) { this.receive(Provider.server, packet, 0, size); } else { this.receive(Provider.client, packet, 0, size); } } else if (mode == ESteamCall.OTHERS) { if (!Provider.isServer) { Provider.send(Provider.server, type, packet, size, this.id); } for (int j = 0; j < Provider.clients.Count; j++) { if (Provider.clients[j].playerID.steamID != Provider.client && Provider.clients[j].player != null && Regions.checkArea(x, y, Provider.clients[j].player.movement.region_x, Provider.clients[j].player.movement.region_y, area)) { Provider.send(Provider.clients[j].playerID.steamID, type, packet, size, this.id); } } } else if (mode == ESteamCall.OWNER) { if (this.isOwner) { this.receive(this.owner.playerID.steamID, packet, 0, size); } else { Provider.send(this.owner.playerID.steamID, type, packet, size, this.id); } } else if (mode == ESteamCall.NOT_OWNER) { if (!Provider.isServer) { Provider.send(Provider.server, type, packet, size, this.id); } for (int k = 0; k < Provider.clients.Count; k++) { if (Provider.clients[k].playerID.steamID != this.owner.playerID.steamID && Provider.clients[k].player != null && Regions.checkArea(x, y, Provider.clients[k].player.movement.region_x, Provider.clients[k].player.movement.region_y, area)) { Provider.send(Provider.clients[k].playerID.steamID, type, packet, size, this.id); } } } else if (mode == ESteamCall.CLIENTS) { for (int l = 0; l < Provider.clients.Count; l++) { if (Provider.clients[l].playerID.steamID != Provider.client && Provider.clients[l].player != null && Regions.checkArea(x, y, Provider.clients[l].player.movement.region_x, Provider.clients[l].player.movement.region_y, area)) { Provider.send(Provider.clients[l].playerID.steamID, type, packet, size, this.id); } } if (Provider.isClient) { this.receive(Provider.client, packet, 0, size); } } else if (mode == ESteamCall.PEERS) { for (int m = 0; m < Provider.clients.Count; m++) { if (Provider.clients[m].playerID.steamID != Provider.client && Provider.clients[m].player != null && Regions.checkArea(x, y, Provider.clients[m].player.movement.region_x, Provider.clients[m].player.movement.region_y, area)) { Provider.send(Provider.clients[m].playerID.steamID, type, packet, size, this.id); } } } }
public void askTakeItem(CSteamID steamID, byte x, byte y, uint instanceID, byte to_x, byte to_y, byte to_rot, byte to_page) { if (Provider.isServer) { if (!Regions.checkSafe((int)x, (int)y)) { return; } Player player = PlayerTool.getPlayer(steamID); if (player == null) { return; } if (player.life.isDead) { return; } if (!player.tryToPerformRateLimitedAction()) { return; } if (player.animator.gesture == EPlayerGesture.ARREST_START) { return; } ItemRegion itemRegion = ItemManager.regions[(int)x, (int)y]; ushort num = 0; while ((int)num < itemRegion.items.Count) { if (itemRegion.items[(int)num].instanceID == instanceID) { if (Dedicator.isDedicated && (itemRegion.items[(int)num].point - player.transform.position).sqrMagnitude > 400f) { return; } bool flag; if (to_page == 255) { flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, true); } else { flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, to_x, to_y, to_page, to_rot); } if (flag) { if (!player.equipment.wasTryingToSelect && !player.equipment.isSelected) { player.animator.sendGesture(EPlayerGesture.PICKUP, true); } EffectManager.sendEffect(7, EffectManager.SMALL, ItemManager.regions[(int)x, (int)y].items[(int)num].point); ItemManager.regions[(int)x, (int)y].items.RemoveAt((int)num); player.sendStat(EPlayerStat.FOUND_ITEMS); base.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { x, y, instanceID }); } else { player.sendMessage(EPlayerMessage.SPACE); } return; } else { num += 1; } } } }
private void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex) { if (step == 0) { for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (Provider.isServer) { if (player.movement.loadedRegions[(int)b, (int)b2].isResourcesLoaded && !Regions.checkArea(b, b2, new_x, new_y, ResourceManager.RESOURCE_REGIONS)) { player.movement.loadedRegions[(int)b, (int)b2].isResourcesLoaded = false; } } else if (player.channel.isOwner && ResourceManager.regions[(int)b, (int)b2].isNetworked && !Regions.checkArea(b, b2, new_x, new_y, ResourceManager.RESOURCE_REGIONS)) { ResourceManager.regions[(int)b, (int)b2].isNetworked = false; } } } } if (step == 3 && Dedicator.isDedicated && Regions.checkSafe((int)new_x, (int)new_y)) { for (int i = (int)(new_x - ResourceManager.RESOURCE_REGIONS); i <= (int)(new_x + ResourceManager.RESOURCE_REGIONS); i++) { for (int j = (int)(new_y - ResourceManager.RESOURCE_REGIONS); j <= (int)(new_y + ResourceManager.RESOURCE_REGIONS); j++) { if (Regions.checkSafe((int)((byte)i), (int)((byte)j)) && !player.movement.loadedRegions[i, j].isResourcesLoaded) { player.movement.loadedRegions[i, j].isResourcesLoaded = true; this.askResources(player.channel.owner.playerID.steamID, (byte)i, (byte)j); } } } } }
private static void update(int x, int y) { for (int i = 0; i < (int)EditorLevelVisibilityUI.DEBUG_SIZE; i++) { for (int j = 0; j < (int)EditorLevelVisibilityUI.DEBUG_SIZE; j++) { int num = i * (int)EditorLevelVisibilityUI.DEBUG_SIZE + j; int num2 = x - (int)(EditorLevelVisibilityUI.DEBUG_SIZE / 2) + i; int num3 = y - (int)(EditorLevelVisibilityUI.DEBUG_SIZE / 2) + j; SleekLabel sleekLabel = EditorLevelVisibilityUI.regionLabels[num]; if (Regions.checkSafe(num2, num3)) { int num4 = LevelObjects.objects[num2, num3].Count + LevelGround.trees[num2, num3].Count; int num5 = LevelObjects.total + LevelGround.total; double num6 = Math.Round((double)num4 / (double)num5 * 1000.0) / 10.0; int num7 = 0; for (int k = 0; k < LevelObjects.objects[num2, num3].Count; k++) { LevelObject levelObject = LevelObjects.objects[num2, num3][k]; if (levelObject.transform) { levelObject.transform.GetComponents <MeshFilter>(EditorLevelVisibilityUI.meshes); if (EditorLevelVisibilityUI.meshes.Count == 0) { Transform transform = levelObject.transform.FindChild("Model_0"); if (transform) { transform.GetComponentsInChildren <MeshFilter>(true, EditorLevelVisibilityUI.meshes); } } if (EditorLevelVisibilityUI.meshes.Count != 0) { for (int l = 0; l < EditorLevelVisibilityUI.meshes.Count; l++) { Mesh sharedMesh = EditorLevelVisibilityUI.meshes[l].sharedMesh; if (sharedMesh) { num7 += sharedMesh.triangles.Length; } } } } } for (int m = 0; m < LevelGround.trees[num2, num3].Count; m++) { ResourceSpawnpoint resourceSpawnpoint = LevelGround.trees[num2, num3][m]; if (resourceSpawnpoint.model) { resourceSpawnpoint.model.GetComponents <MeshFilter>(EditorLevelVisibilityUI.meshes); if (EditorLevelVisibilityUI.meshes.Count == 0) { Transform transform2 = resourceSpawnpoint.model.FindChild("Model_0"); if (transform2) { transform2.GetComponentsInChildren <MeshFilter>(true, EditorLevelVisibilityUI.meshes); } } if (EditorLevelVisibilityUI.meshes.Count != 0) { for (int n = 0; n < EditorLevelVisibilityUI.meshes.Count; n++) { Mesh sharedMesh2 = EditorLevelVisibilityUI.meshes[n].sharedMesh; if (sharedMesh2) { num7 += sharedMesh2.triangles.Length; } } } } } long num8 = (long)num4 * (long)num7; float quality = Mathf.Clamp01((float)(1.0 - (double)num8 / 50000000.0)); sleekLabel.text = EditorLevelVisibilityUI.localization.format("Point", new object[] { num2, num3 }); SleekLabel sleekLabel2 = sleekLabel; sleekLabel2.text = sleekLabel2.text + "\n" + EditorLevelVisibilityUI.localization.format("Objects", new object[] { num4, num6 }); SleekLabel sleekLabel3 = sleekLabel; sleekLabel3.text = sleekLabel3.text + "\n" + EditorLevelVisibilityUI.localization.format("Triangles", new object[] { num7 }); if (num4 == 0 && num7 == 0) { sleekLabel.foregroundColor = Color.white; } else { sleekLabel.foregroundColor = ItemTool.getQualityColor(quality); } } } } }
public void askForage(CSteamID steamID, byte x, byte y, ushort index) { if (Provider.isServer) { if (!Regions.checkSafe((int)x, (int)y)) { return; } Player player = PlayerTool.getPlayer(steamID); if (player == null) { return; } if (player.life.isDead) { return; } List <ResourceSpawnpoint> list = LevelGround.trees[(int)x, (int)y]; if ((int)index >= list.Count) { return; } if (list[(int)index].isDead) { return; } ResourceAsset resourceAsset = (ResourceAsset)Assets.find(EAssetType.RESOURCE, LevelGround.resources[(int)list[(int)index].type].id); if (resourceAsset == null || !resourceAsset.isForage) { return; } list[(int)index].askDamage(1); if (resourceAsset.explosion != 0) { EffectManager.sendEffect(resourceAsset.explosion, x, y, ResourceManager.RESOURCE_REGIONS, list[(int)index].point); } ushort num; if (resourceAsset.rewardID != 0) { num = SpawnTableTool.resolve(resourceAsset.rewardID); } else { num = resourceAsset.log; } if (num != 0) { player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true); if (Random.value < player.skills.mastery(2, 5)) { player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true); } } player.sendStat(EPlayerStat.FOUND_PLANTS); player.skills.askPay(1u); ResourceManager.manager.channel.send("tellResourceDead", ESteamCall.ALL, x, y, ResourceManager.RESOURCE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { x, y, index, Vector3.zero }); } }
public static void damage(Transform resource, Vector3 direction, float damage, float times, float drop, out EPlayerKill kill, out uint xp) { xp = 0u; kill = EPlayerKill.NONE; byte b; byte b2; if (Regions.tryGetCoordinate(resource.position, out b, out b2)) { List <ResourceSpawnpoint> list = LevelGround.trees[(int)b, (int)b2]; ushort num = 0; while ((int)num < list.Count) { if (resource == list[(int)num].model) { if (!list[(int)num].isDead) { ushort num2 = (ushort)(damage * times); list[(int)num].askDamage(num2); if (list[(int)num].isDead) { kill = EPlayerKill.RESOURCE; ResourceAsset asset = list[(int)num].asset; if (list[(int)num].asset != null) { if (asset.explosion != 0) { if (asset.hasDebris) { EffectManager.sendEffect(asset.explosion, b, b2, ResourceManager.RESOURCE_REGIONS, resource.position + Vector3.up * 8f); } else { EffectManager.sendEffect(asset.explosion, b, b2, ResourceManager.RESOURCE_REGIONS, resource.position); } } if (asset.rewardID != 0) { direction.y = 0f; direction.Normalize(); int num3 = (int)((float)Random.Range((int)asset.rewardMin, (int)(asset.rewardMax + 1)) * drop); for (int i = 0; i < num3; i++) { ushort num4 = SpawnTableTool.resolve(asset.rewardID); if (num4 != 0) { if (asset.hasDebris) { ItemManager.dropItem(new Item(num4, EItemOrigin.NATURE), resource.position + direction * (float)(2 + i) + new Vector3(0f, 2f, 0f), false, Dedicator.isDedicated, true); } else { ItemManager.dropItem(new Item(num4, EItemOrigin.NATURE), resource.position + new Vector3(Random.Range(-2f, 2f), 2f, Random.Range(-2f, 2f)), false, Dedicator.isDedicated, true); } } } } else { if (asset.log != 0) { int num5 = (int)((float)Random.Range(3, 7) * drop); for (int j = 0; j < num5; j++) { ItemManager.dropItem(new Item(asset.log, EItemOrigin.NATURE), resource.position + direction * (float)(2 + j * 2) + Vector3.up, false, Dedicator.isDedicated, true); } } if (asset.stick != 0) { int num6 = (int)((float)Random.Range(2, 5) * drop); for (int k = 0; k < num6; k++) { float num7 = Random.Range(0f, 6.28318548f); ItemManager.dropItem(new Item(asset.stick, EItemOrigin.NATURE), resource.position + new Vector3(Mathf.Sin(num7) * 3f, 1f, Mathf.Cos(num7) * 3f), false, Dedicator.isDedicated, true); } } } xp = asset.rewardXP; } ResourceManager.manager.channel.send("tellResourceDead", ESteamCall.ALL, b, b2, ResourceManager.RESOURCE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { b, b2, num, direction * (float)num2 }); } } break; } num += 1; } } }
private static void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex) { if (step != 0) { return; } for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (LevelObjects.regions[(int)b, (int)b2] && !Regions.checkArea(b, b2, new_x, new_y, LevelObjects.OBJECT_REGIONS)) { LevelObjects.regions[(int)b, (int)b2] = false; if (LevelObjects.shouldInstantlyLoad) { List <LevelObject> list = LevelObjects.objects[(int)b, (int)b2]; for (int i = 0; i < list.Count; i++) { list[i].disableCollision(); if (!list[i].isSpeciallyCulled) { list[i].disableVisual(); if (list[i].isLandmarkQualityMet) { list[i].enableSkybox(); } } } } else { LevelObjects.loads[(int)b, (int)b2] = 0; } if (Level.isEditor) { List <LevelBuildableObject> list2 = LevelObjects.buildables[(int)b, (int)b2]; for (int j = 0; j < list2.Count; j++) { list2[j].disable(); } } } } } if (Regions.checkSafe((int)new_x, (int)new_y)) { for (int k = (int)(new_x - LevelObjects.OBJECT_REGIONS); k <= (int)(new_x + LevelObjects.OBJECT_REGIONS); k++) { for (int l = (int)(new_y - LevelObjects.OBJECT_REGIONS); l <= (int)(new_y + LevelObjects.OBJECT_REGIONS); l++) { if (Regions.checkSafe((int)((byte)k), (int)((byte)l)) && !LevelObjects.regions[k, l]) { LevelObjects.regions[k, l] = true; if (LevelObjects.shouldInstantlyLoad) { List <LevelObject> list3 = LevelObjects.objects[k, l]; for (int m = 0; m < list3.Count; m++) { list3[m].enableCollision(); if (!list3[m].isSpeciallyCulled) { list3[m].enableVisual(); list3[m].disableSkybox(); } } } else { LevelObjects.loads[k, l] = 0; } if (Level.isEditor) { List <LevelBuildableObject> list4 = LevelObjects.buildables[k, l]; for (int n = 0; n < list4.Count; n++) { list4[n].enable(); } } } } } } Level.isLoadingArea = false; LevelObjects.shouldInstantlyLoad = false; }
// Token: 0x060033E3 RID: 13283 RVA: 0x00151418 File Offset: 0x0014F818 public static void explode(Vector3 point, float damageRadius, EDeathCause cause, CSteamID killer, float playerDamage, float zombieDamage, float animalDamage, float barricadeDamage, float structureDamage, float vehicleDamage, float resourceDamage, float objectDamage, out List <EPlayerKill> kills, EExplosionDamageType damageType = EExplosionDamageType.CONVENTIONAL, float alertRadius = 32f, bool playImpactEffect = true, bool penetrateBuildables = false) { DamageTool.explosionKills.Clear(); kills = DamageTool.explosionKills; DamageTool.explosionRangeComparator.point = point; float num = damageRadius * damageRadius; DamageTool.regionsInRadius.Clear(); Regions.getRegionsInRadius(point, damageRadius, DamageTool.regionsInRadius); int layerMask; if (penetrateBuildables) { layerMask = RayMasks.BLOCK_EXPLOSION_PENETRATE_BUILDABLES; } else { layerMask = RayMasks.BLOCK_EXPLOSION; } if (structureDamage > 0.5f) { DamageTool.structuresInRadius.Clear(); StructureManager.getStructuresInRadius(point, num, DamageTool.regionsInRadius, DamageTool.structuresInRadius); DamageTool.structuresInRadius.Sort(DamageTool.explosionRangeComparator); for (int i = 0; i < DamageTool.structuresInRadius.Count; i++) { Transform transform = DamageTool.structuresInRadius[i]; if (!(transform == null)) { ushort id; if (ushort.TryParse(transform.name, out id)) { ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id); if (itemStructureAsset != null && !itemStructureAsset.proofExplosion) { Vector3 a = transform.transform.position - point; float magnitude = a.magnitude; Vector3 direction = a / magnitude; if (magnitude > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, direction), out raycastHit, magnitude - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != transform.transform) { goto IL_17D; } } StructureManager.damage(transform, a.normalized, structureDamage, 1f - magnitude / damageRadius, true); } } } IL_17D :; } } if (resourceDamage > 0.5f) { DamageTool.resourcesInRadius.Clear(); ResourceManager.getResourcesInRadius(point, num, DamageTool.regionsInRadius, DamageTool.resourcesInRadius); DamageTool.resourcesInRadius.Sort(DamageTool.explosionRangeComparator); for (int j = 0; j < DamageTool.resourcesInRadius.Count; j++) { Transform transform2 = DamageTool.resourcesInRadius[j]; if (!(transform2 == null)) { Vector3 a2 = transform2.transform.position - point; float magnitude2 = a2.magnitude; Vector3 direction2 = a2 / magnitude2; if (magnitude2 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, direction2), out raycastHit, magnitude2 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != transform2.transform) { goto IL_2A2; } } EPlayerKill eplayerKill; uint num2; ResourceManager.damage(transform2, a2.normalized, resourceDamage, 1f - magnitude2 / damageRadius, 1f, out eplayerKill, out num2); if (eplayerKill != EPlayerKill.NONE) { kills.Add(eplayerKill); } } IL_2A2 :; } } if (objectDamage > 0.5f) { DamageTool.objectsInRadius.Clear(); ObjectManager.getObjectsInRadius(point, num, DamageTool.regionsInRadius, DamageTool.objectsInRadius); DamageTool.objectsInRadius.Sort(DamageTool.explosionRangeComparator); for (int k = 0; k < DamageTool.objectsInRadius.Count; k++) { Transform transform3 = DamageTool.objectsInRadius[k]; if (!(transform3 == null)) { InteractableObjectRubble component = transform3.GetComponent <InteractableObjectRubble>(); if (!(component == null)) { if (!component.asset.rubbleProofExplosion) { for (byte b = 0; b < component.getSectionCount(); b += 1) { Transform section = component.getSection(b); Vector3 a3 = section.position - point; if (a3.sqrMagnitude < num) { float magnitude3 = a3.magnitude; Vector3 direction3 = a3 / magnitude3; if (magnitude3 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, direction3), out raycastHit, magnitude3 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != transform3.transform) { goto IL_40B; } } EPlayerKill eplayerKill; uint num2; ObjectManager.damage(transform3, a3.normalized, b, objectDamage, 1f - magnitude3 / damageRadius, out eplayerKill, out num2); if (eplayerKill != EPlayerKill.NONE) { kills.Add(eplayerKill); } } IL_40B :; } } } } } } if (barricadeDamage > 0.5f) { DamageTool.barricadesInRadius.Clear(); BarricadeManager.getBarricadesInRadius(point, num, DamageTool.regionsInRadius, DamageTool.barricadesInRadius); BarricadeManager.getBarricadesInRadius(point, num, DamageTool.barricadesInRadius); DamageTool.barricadesInRadius.Sort(DamageTool.explosionRangeComparator); for (int l = 0; l < DamageTool.barricadesInRadius.Count; l++) { Transform transform4 = DamageTool.barricadesInRadius[l]; if (!(transform4 == null)) { Vector3 a4 = transform4.transform.position - point; float magnitude4 = a4.magnitude; Vector3 direction4 = a4 / magnitude4; if (magnitude4 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, direction4), out raycastHit, magnitude4 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != transform4.transform) { goto IL_568; } } ushort id2; if (ushort.TryParse(transform4.name, out id2)) { ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id2); if (itemBarricadeAsset != null && !itemBarricadeAsset.proofExplosion) { BarricadeManager.damage(transform4, barricadeDamage, 1f - magnitude4 / damageRadius, true); } } } IL_568 :; } } if ((Provider.isPvP || damageType == EExplosionDamageType.ZOMBIE_ACID || damageType == EExplosionDamageType.ZOMBIE_FIRE || damageType == EExplosionDamageType.ZOMBIE_ELECTRIC) && playerDamage > 0.5f) { DamageTool.playersInRadius.Clear(); PlayerTool.getPlayersInRadius(point, num, DamageTool.playersInRadius); for (int m = 0; m < DamageTool.playersInRadius.Count; m++) { Player player = DamageTool.playersInRadius[m]; if (!(player == null) && !player.life.isDead) { if (damageType != EExplosionDamageType.ZOMBIE_FIRE || player.clothing.shirtAsset == null || !player.clothing.shirtAsset.proofFire || player.clothing.pantsAsset == null || !player.clothing.pantsAsset.proofFire) { Vector3 a5 = player.transform.position - point; float magnitude5 = a5.magnitude; Vector3 vector = a5 / magnitude5; if (magnitude5 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector), out raycastHit, magnitude5 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != player.transform) { goto IL_7AA; } } if (playImpactEffect) { EffectManager.sendEffect(5, EffectManager.SMALL, player.transform.position + Vector3.up, -vector); EffectManager.sendEffect(5, EffectManager.SMALL, player.transform.position + Vector3.up, Vector3.up); } float num3 = 1f - Mathf.Pow(magnitude5 / damageRadius, 2f); if (player.movement.getVehicle() != null && player.movement.getVehicle().asset != null) { num3 *= player.movement.getVehicle().asset.passengerExplosionArmor; } EPlayerKill eplayerKill; DamageTool.damage(player, cause, ELimb.SPINE, killer, vector, playerDamage, num3, out eplayerKill); if (eplayerKill != EPlayerKill.NONE) { kills.Add(eplayerKill); } } } IL_7AA :; } } if (damageType == EExplosionDamageType.ZOMBIE_FIRE || zombieDamage > 0.5f) { DamageTool.zombiesInRadius.Clear(); ZombieManager.getZombiesInRadius(point, num, DamageTool.zombiesInRadius); for (int n = 0; n < DamageTool.zombiesInRadius.Count; n++) { Zombie zombie = DamageTool.zombiesInRadius[n]; if (!(zombie == null) && !zombie.isDead) { if (damageType == EExplosionDamageType.ZOMBIE_FIRE) { if (zombie.speciality == EZombieSpeciality.NORMAL) { ZombieManager.sendZombieSpeciality(zombie, EZombieSpeciality.BURNER); } } else { Vector3 a6 = zombie.transform.position - point; float magnitude6 = a6.magnitude; Vector3 vector2 = a6 / magnitude6; if (magnitude6 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector2), out raycastHit, magnitude6 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != zombie.transform) { goto IL_964; } } if (playImpactEffect) { EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, zombie.transform.position + Vector3.up, -vector2); EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, zombie.transform.position + Vector3.up, Vector3.up); } EPlayerKill eplayerKill; uint num2; DamageTool.damage(zombie, vector2, zombieDamage, 1f - magnitude6 / damageRadius, out eplayerKill, out num2); if (eplayerKill != EPlayerKill.NONE) { kills.Add(eplayerKill); } } } IL_964 :; } } if (animalDamage > 0.5f) { DamageTool.animalsInRadius.Clear(); AnimalManager.getAnimalsInRadius(point, num, DamageTool.animalsInRadius); for (int num4 = 0; num4 < DamageTool.animalsInRadius.Count; num4++) { Animal animal = DamageTool.animalsInRadius[num4]; if (!(animal == null) && !animal.isDead) { Vector3 a7 = animal.transform.position - point; float magnitude7 = a7.magnitude; Vector3 vector3 = a7 / magnitude7; if (magnitude7 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector3), out raycastHit, magnitude7 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != animal.transform) { goto IL_ACC; } } if (playImpactEffect) { EffectManager.sendEffect(5, EffectManager.SMALL, animal.transform.position + Vector3.up, -vector3); EffectManager.sendEffect(5, EffectManager.SMALL, animal.transform.position + Vector3.up, Vector3.up); } EPlayerKill eplayerKill; uint num2; DamageTool.damage(animal, vector3, animalDamage, 1f - magnitude7 / damageRadius, out eplayerKill, out num2); if (eplayerKill != EPlayerKill.NONE) { kills.Add(eplayerKill); } } IL_ACC :; } } if (vehicleDamage > 0.5f) { DamageTool.vehiclesInRadius.Clear(); VehicleManager.getVehiclesInRadius(point, num, DamageTool.vehiclesInRadius); for (int num5 = 0; num5 < DamageTool.vehiclesInRadius.Count; num5++) { InteractableVehicle interactableVehicle = DamageTool.vehiclesInRadius[num5]; if (!(interactableVehicle == null) && !interactableVehicle.isDead) { if (interactableVehicle.asset != null && interactableVehicle.asset.isVulnerableToExplosions) { Vector3 a8 = interactableVehicle.transform.position - point; float magnitude8 = a8.magnitude; Vector3 direction5 = a8 / magnitude8; if (magnitude8 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, direction5), out raycastHit, magnitude8 - 0.5f, layerMask, QueryTriggerInteraction.UseGlobal); if (raycastHit.transform != null && raycastHit.transform != interactableVehicle.transform) { goto IL_BED; } } VehicleManager.damage(interactableVehicle, vehicleDamage, 1f - magnitude8 / damageRadius, false); } } IL_BED :; } } AlertTool.alert(point, alertRadius); }
public static void load() { LevelObjects._models = new GameObject().transform; LevelObjects.models.name = "Objects"; LevelObjects.models.parent = Level.level; LevelObjects.models.tag = "Logic"; LevelObjects.models.gameObject.layer = LayerMasks.LOGIC; LevelObjects._objects = new List <LevelObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._buildables = new List <LevelBuildableObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._total = 0; LevelObjects._regions = new bool[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._loads = new int[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects.shouldInstantlyLoad = true; LevelObjects.isHierarchyReady = false; for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { LevelObjects.loads[(int)b, (int)b2] = -1; } } for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { LevelObjects.objects[(int)b3, (int)b4] = new List <LevelObject>(); LevelObjects.buildables[(int)b3, (int)b4] = new List <LevelBuildableObject>(); } } if (Level.info.configData.Use_Legacy_Objects) { if (ReadWrite.fileExists(Level.info.path + "/Level/Objects.dat", false, false)) { River river = new River(Level.info.path + "/Level/Objects.dat", false); byte b5 = river.readByte(); bool flag = true; if (b5 > 0) { if (b5 > 1 && b5 < 3) { river.readSteamID(); } if (b5 > 8) { LevelObjects.availableInstanceID = river.readUInt32(); } else { LevelObjects.availableInstanceID = 1u; } for (byte b6 = 0; b6 < Regions.WORLD_SIZE; b6 += 1) { for (byte b7 = 0; b7 < Regions.WORLD_SIZE; b7 += 1) { ushort num = river.readUInt16(); for (ushort num2 = 0; num2 < num; num2 += 1) { Vector3 vector = river.readSingleVector3(); Quaternion newRotation = river.readSingleQuaternion(); Vector3 newScale; if (b5 > 3) { newScale = river.readSingleVector3(); } else { newScale = Vector3.one; } ushort num3 = river.readUInt16(); string newName = string.Empty; if (b5 > 5) { newName = river.readString(); } Guid newGUID = Guid.Empty; if (b5 > 7) { newGUID = river.readGUID(); } ELevelObjectPlacementOrigin newPlacementOrigin = ELevelObjectPlacementOrigin.MANUAL; if (b5 > 6) { newPlacementOrigin = (ELevelObjectPlacementOrigin)river.readByte(); } uint newInstanceID; if (b5 > 8) { newInstanceID = river.readUInt32(); } else { newInstanceID = LevelObjects.generateUniqueInstanceID(); } if (num3 != 0) { LevelObject levelObject = new LevelObject(vector, newRotation, newScale, num3, newName, newGUID, newPlacementOrigin, newInstanceID); if (levelObject.asset == null) { flag = false; } if (Level.isEditor) { byte b8; byte b9; Regions.tryGetCoordinate(vector, out b8, out b9); if (b8 != b6 || b9 != b7) { Debug.LogError(string.Concat(new object[] { num3, " should be in ", b8, ", ", b9, " but was in ", b6, ", ", b7, "!" })); } LevelObjects.objects[(int)b8, (int)b9].Add(levelObject); } else { LevelObjects.objects[(int)b6, (int)b7].Add(levelObject); } LevelObjects._total++; } } } } } if (flag) { LevelObjects._hash = river.getHash(); } else { LevelObjects._hash = new byte[20]; } river.closeRiver(); } else { for (byte b10 = 0; b10 < Regions.WORLD_SIZE; b10 += 1) { for (byte b11 = 0; b11 < Regions.WORLD_SIZE; b11 += 1) { if (ReadWrite.fileExists(string.Concat(new object[] { Level.info.path, "/Objects/Objects_", b10, "_", b11, ".dat" }), false, false)) { River river2 = new River(string.Concat(new object[] { Level.info.path, "/Objects/Objects_", b10, "_", b11, ".dat" }), false); byte b12 = river2.readByte(); if (b12 > 0) { ushort num4 = river2.readUInt16(); for (ushort num5 = 0; num5 < num4; num5 += 1) { Vector3 position = river2.readSingleVector3(); Quaternion rotation = river2.readSingleQuaternion(); ushort num6 = river2.readUInt16(); string empty = string.Empty; Guid empty2 = Guid.Empty; ELevelObjectPlacementOrigin placementOrigin = ELevelObjectPlacementOrigin.MANUAL; if (num6 != 0) { LevelObjects.addObject(position, rotation, Vector3.one, num6, empty, empty2, placementOrigin); } } } river2.closeRiver(); } } } LevelObjects._hash = new byte[20]; } } else { LevelObjects._hash = new byte[20]; } if ((Provider.isServer || Level.isEditor) && ReadWrite.fileExists(Level.info.path + "/Level/Buildables.dat", false, false)) { River river3 = new River(Level.info.path + "/Level/Buildables.dat", false); river3.readByte(); for (byte b13 = 0; b13 < Regions.WORLD_SIZE; b13 += 1) { for (byte b14 = 0; b14 < Regions.WORLD_SIZE; b14 += 1) { ushort num7 = river3.readUInt16(); for (ushort num8 = 0; num8 < num7; num8 += 1) { Vector3 vector2 = river3.readSingleVector3(); Quaternion newRotation2 = river3.readSingleQuaternion(); ushort num9 = river3.readUInt16(); if (num9 != 0) { LevelBuildableObject item = new LevelBuildableObject(vector2, newRotation2, num9); if (Level.isEditor) { byte b15; byte b16; Regions.tryGetCoordinate(vector2, out b15, out b16); if (b15 != b13 || b16 != b14) { Debug.LogError(string.Concat(new object[] { num9, " should be in ", b15, ", ", b16, " but was in ", b13, ", ", b14, "!" })); } LevelObjects.buildables[(int)b15, (int)b16].Add(item); } else { LevelObjects.buildables[(int)b13, (int)b14].Add(item); } LevelObjects._total++; } } } } river3.closeRiver(); } if (Level.info.configData.Use_Legacy_Objects && !Dedicator.isDedicated && !Level.isEditor) { for (byte b17 = 0; b17 < Regions.WORLD_SIZE; b17 += 1) { for (byte b18 = 0; b18 < Regions.WORLD_SIZE; b18 += 1) { for (int i = 0; i < LevelObjects.objects[(int)b17, (int)b18].Count; i++) { LevelObject levelObject2 = LevelObjects.objects[(int)b17, (int)b18][i]; if (levelObject2.asset != null && !(levelObject2.transform == null)) { if (levelObject2.asset.lod != EObjectLOD.NONE) { ObjectsLOD objectsLOD = levelObject2.transform.gameObject.AddComponent <ObjectsLOD>(); objectsLOD.lod = levelObject2.asset.lod; objectsLOD.bias = levelObject2.asset.lodBias; objectsLOD.center = levelObject2.asset.lodCenter; objectsLOD.size = levelObject2.asset.lodSize; objectsLOD.calculateBounds(); } } } } } } if (Level.isEditor) { LevelObjects.reun = new IReun[256]; LevelObjects.step = 0; LevelObjects.frame = 0; } }
public static void transformObject(Transform select, Vector3 toPosition, Quaternion toRotation, Vector3 toScale, Vector3 fromPosition, Quaternion fromRotation, Vector3 fromScale) { byte b; byte b2; if (Regions.tryGetCoordinate(fromPosition, out b, out b2)) { byte b3; byte b4; if (Regions.tryGetCoordinate(toPosition, out b3, out b4)) { LevelObject levelObject = null; int index = -1; for (int i = 0; i < LevelObjects.objects[(int)b, (int)b2].Count; i++) { if (LevelObjects.objects[(int)b, (int)b2][i].transform == select) { levelObject = LevelObjects.objects[(int)b, (int)b2][i]; index = i; break; } } if (levelObject != null) { if (b != b3 || b2 != b4) { LevelObjects.objects[(int)b, (int)b2].RemoveAt(index); LevelObjects.objects[(int)b3, (int)b4].Add(levelObject); } if (levelObject.transform != null) { levelObject.transform.position = toPosition; levelObject.transform.rotation = toRotation; levelObject.transform.localScale = toScale; } if (levelObject.skybox != null) { levelObject.skybox.position = toPosition; levelObject.skybox.rotation = toRotation; levelObject.skybox.localScale = toScale; } } else { LevelBuildableObject levelBuildableObject = null; int index2 = -1; for (int j = 0; j < LevelObjects.buildables[(int)b, (int)b2].Count; j++) { if (LevelObjects.buildables[(int)b, (int)b2][j].transform == select) { levelBuildableObject = LevelObjects.buildables[(int)b, (int)b2][j]; index2 = j; break; } } if (levelBuildableObject != null) { if (b != b3 || b2 != b4) { LevelObjects.buildables[(int)b, (int)b2].RemoveAt(index2); LevelObjects.buildables[(int)b3, (int)b4].Add(levelBuildableObject); } if (levelBuildableObject.transform != null) { levelBuildableObject.transform.position = toPosition; levelBuildableObject.transform.rotation = toRotation; } } else { select.position = fromPosition; select.rotation = fromRotation; select.localScale = fromScale; } } } else { select.position = fromPosition; select.rotation = fromRotation; select.localScale = fromScale; } } else { select.position = fromPosition; select.rotation = fromRotation; select.localScale = fromScale; } }
public static void load() { LevelNodes._models = new GameObject().transform; LevelNodes.models.name = "Nodes"; LevelNodes.models.parent = Level.level; LevelNodes.models.tag = "Logic"; LevelNodes.models.gameObject.layer = LayerMasks.LOGIC; LevelNodes._nodes = new List <Node>(); if (ReadWrite.fileExists(Level.info.path + "/Environment/Nodes.dat", false, false)) { River river = new River(Level.info.path + "/Environment/Nodes.dat", false); byte b = river.readByte(); if (b > 0) { ushort num = (ushort)river.readByte(); for (ushort num2 = 0; num2 < num; num2 += 1) { Vector3 vector = river.readSingleVector3(); ENodeType enodeType = (ENodeType)river.readByte(); if (enodeType == ENodeType.LOCATION) { string newName = river.readString(); LevelNodes.nodes.Add(new LocationNode(vector, newName)); } else if (enodeType == ENodeType.SAFEZONE) { float newRadius = river.readSingle(); bool newHeight = false; if (b > 1) { newHeight = river.readBoolean(); } bool newNoWeapons = true; if (b > 4) { newNoWeapons = river.readBoolean(); } bool newNoBuildables = true; if (b > 4) { newNoBuildables = river.readBoolean(); } LevelNodes.nodes.Add(new SafezoneNode(vector, newRadius, newHeight, newNoWeapons, newNoBuildables)); } else if (enodeType == ENodeType.PURCHASE) { float newRadius2 = river.readSingle(); ushort newID = river.readUInt16(); uint newCost = river.readUInt32(); LevelNodes.nodes.Add(new PurchaseNode(vector, newRadius2, newID, newCost)); } else if (enodeType == ENodeType.ARENA) { float newRadius3 = river.readSingle(); LevelNodes.nodes.Add(new ArenaNode(vector, newRadius3)); } else if (enodeType == ENodeType.DEADZONE) { float newRadius4 = river.readSingle(); LevelNodes.nodes.Add(new DeadzoneNode(vector, newRadius4)); } else if (enodeType == ENodeType.AIRDROP) { ushort num3 = river.readUInt16(); byte b2; byte b3; if (SpawnTableTool.resolve(num3) == 0 && Regions.tryGetCoordinate(vector, out b2, out b3)) { Assets.errors.Add(string.Concat(new object[] { Level.info.name, " airdrop references invalid spawn table ", num3, " at (", b2, ", ", b3, ")!" })); } LevelNodes.nodes.Add(new AirdropNode(vector, num3)); } else if (enodeType == ENodeType.EFFECT) { byte newShape = 0; if (b > 2) { newShape = river.readByte(); } float newRadius5 = river.readSingle(); Vector3 newBounds = Vector3.one; if (b > 2) { newBounds = river.readSingleVector3(); } ushort newID2 = river.readUInt16(); bool newNoWater = river.readBoolean(); bool newNoLighting = false; if (b > 3) { newNoLighting = river.readBoolean(); } LevelNodes.nodes.Add(new EffectNode(vector, (ENodeShape)newShape, newRadius5, newBounds, newID2, newNoWater, newNoLighting)); } } } river.closeRiver(); } }
private void Update() { if (!this.isBuilding) { return; } this.ray = MainCamera.instance.ScreenPointToRay(Input.mousePosition); Physics.Raycast(this.ray, ref this.worldHit, 256f, RayMasks.EDITOR_WORLD); Physics.Raycast(this.ray, ref this.buildableHit, 256f, RayMasks.EDITOR_BUILDABLE); Physics.Raycast(this.ray, ref this.logicHit, 256f, RayMasks.VIEWMODEL); if (GUIUtility.hotControl == 0) { if (Input.GetKey(ControlsSettings.secondary)) { this.handleType = EDragType.NONE; if (this.isDragging) { this._dragStart = Vector2.zero; this._dragEnd = Vector2.zero; this._isDragging = false; if (this.onDragStopped != null) { this.onDragStopped(); } this.clearSelection(); } return; } if (this.handleType != EDragType.NONE) { if (!Input.GetKey(ControlsSettings.primary)) { this.applySelection(); this.handleType = EDragType.NONE; } else { if (this.handleType == EDragType.TRANSFORM_X) { this.transformGroup(this.handle.right, this.handle.up); } else if (this.handleType == EDragType.TRANSFORM_Y) { this.transformGroup(this.handle.up, this.handle.right); } else if (this.handleType == EDragType.TRANSFORM_Z) { this.transformGroup(this.handle.forward, this.handle.up); } else if (this.handleType == EDragType.PLANE_X) { this.planeGroup(this.handle.right); } else if (this.handleType == EDragType.PLANE_Y) { this.planeGroup(this.handle.up); } else if (this.handleType == EDragType.PLANE_Z) { this.planeGroup(this.handle.forward); } if (this.handleType == EDragType.ROTATION_X) { this.rotateGroup(this.handle.right, Vector3.right); } else if (this.handleType == EDragType.ROTATION_Y) { this.rotateGroup(this.handle.up, Vector3.up); } else if (this.handleType == EDragType.ROTATION_Z) { this.rotateGroup(this.handle.forward, Vector3.forward); } } } if (Input.GetKeyDown(ControlsSettings.tool_0)) { this.dragMode = EDragMode.TRANSFORM; } if (Input.GetKeyDown(ControlsSettings.tool_1)) { this.dragMode = EDragMode.ROTATE; } if (Input.GetKeyDown(98) && this.selection.Count > 0 && Input.GetKey(306)) { this.copyPosition = this.handle.position; this.copyRotation = this.handle.rotation; } if (Input.GetKeyDown(110) && this.selection.Count > 0 && this.copyPosition != Vector3.zero && Input.GetKey(306)) { this.pointSelection(); this.handle.position = this.copyPosition; this.handle.rotation = this.copyRotation; this.updateGroup(); this.applySelection(); } if (this.handleType == EDragType.NONE) { if (Input.GetKeyDown(ControlsSettings.primary)) { if (this.logicHit.transform != null && (this.logicHit.transform.name == "Arrow_X" || this.logicHit.transform.name == "Arrow_Y" || this.logicHit.transform.name == "Arrow_Z" || this.logicHit.transform.name == "Plane_X" || this.logicHit.transform.name == "Plane_Y" || this.logicHit.transform.name == "Plane_Z" || this.logicHit.transform.name == "Circle_X" || this.logicHit.transform.name == "Circle_Y" || this.logicHit.transform.name == "Circle_Z")) { this.mouseOrigin = Input.mousePosition; this.transformOrigin = this.handle.position; this.rotateOrigin = this.handle.rotation; this.handleOffset = this.logicHit.point - this.handle.position; this.pointSelection(); if (this.logicHit.transform.name == "Arrow_X") { this.handleType = EDragType.TRANSFORM_X; } else if (this.logicHit.transform.name == "Arrow_Y") { this.handleType = EDragType.TRANSFORM_Y; } else if (this.logicHit.transform.name == "Arrow_Z") { this.handleType = EDragType.TRANSFORM_Z; } else if (this.logicHit.transform.name == "Plane_X") { this.handleType = EDragType.PLANE_X; } else if (this.logicHit.transform.name == "Plane_Y") { this.handleType = EDragType.PLANE_Y; } else if (this.logicHit.transform.name == "Plane_Z") { this.handleType = EDragType.PLANE_Z; } else if (this.logicHit.transform.name == "Circle_X") { this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f); this.handleType = EDragType.ROTATION_X; } else if (this.logicHit.transform.name == "Circle_Y") { this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f); this.handleType = EDragType.ROTATION_Y; } else if (this.logicHit.transform.name == "Circle_Z") { this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f); this.handleType = EDragType.ROTATION_Z; } } else { Transform transform = this.buildableHit.transform; if (transform != null && (transform.CompareTag("Barricade") || transform.CompareTag("Structure"))) { InteractableDoorHinge component = transform.GetComponent <InteractableDoorHinge>(); if (component != null) { transform = component.transform.parent.parent; } if (Input.GetKey(ControlsSettings.modify)) { if (this.containsSelection(transform)) { this.removeSelection(transform); } else { this.addSelection(transform); } } else if (this.containsSelection(transform)) { this.clearSelection(); } else { this.clearSelection(); this.addSelection(transform); } } else { if (!this.isDragging) { this._dragStart.x = PlayerUI.window.mouse_x; this._dragStart.y = PlayerUI.window.mouse_y; } if (!Input.GetKey(ControlsSettings.modify)) { this.clearSelection(); } } } } else if (Input.GetKey(ControlsSettings.primary) && this.dragStart.x != 0f) { this._dragEnd.x = PlayerUI.window.mouse_x; this._dragEnd.y = PlayerUI.window.mouse_y; if (this.isDragging || Mathf.Abs(this.dragEnd.x - this.dragStart.x) > 50f || Mathf.Abs(this.dragEnd.x - this.dragStart.x) > 50f) { int num = (int)this.dragStart.x; int num2 = (int)this.dragStart.y; if (this.dragEnd.x < this.dragStart.x) { num = (int)this.dragEnd.x; } if (this.dragEnd.y < this.dragStart.y) { num2 = (int)this.dragEnd.y; } int num3 = (int)this.dragEnd.x; int num4 = (int)this.dragEnd.y; if (this.dragStart.x > this.dragEnd.x) { num3 = (int)this.dragStart.x; } if (this.dragStart.y > this.dragEnd.y) { num4 = (int)this.dragStart.y; } if (this.onDragStarted != null) { this.onDragStarted(num, num2, num3, num4); } if (!this.isDragging) { this._isDragging = true; this.dragable.Clear(); byte region_x = Player.player.movement.region_x; byte region_y = Player.player.movement.region_y; if (Regions.checkSafe((int)region_x, (int)region_y)) { for (int i = 0; i < BarricadeManager.plants.Count; i++) { BarricadeRegion barricadeRegion = BarricadeManager.plants[i]; for (int j = 0; j < barricadeRegion.drops.Count; j++) { BarricadeDrop barricadeDrop = barricadeRegion.drops[j]; if (!(barricadeDrop.model == null)) { Vector3 newScreen = MainCamera.instance.WorldToScreenPoint(barricadeDrop.model.position); if (newScreen.z >= 0f) { newScreen.y = (float)Screen.height - newScreen.y; this.dragable.Add(new EditorDrag(barricadeDrop.model, newScreen)); } } } } for (int k = (int)(region_x - 1); k <= (int)(region_x + 1); k++) { for (int l = (int)(region_y - 1); l <= (int)(region_y + 1); l++) { if (Regions.checkSafe((int)((byte)k), (int)((byte)l))) { for (int m = 0; m < BarricadeManager.regions[k, l].drops.Count; m++) { BarricadeDrop barricadeDrop2 = BarricadeManager.regions[k, l].drops[m]; if (!(barricadeDrop2.model == null)) { Vector3 newScreen2 = MainCamera.instance.WorldToScreenPoint(barricadeDrop2.model.position); if (newScreen2.z >= 0f) { newScreen2.y = (float)Screen.height - newScreen2.y; this.dragable.Add(new EditorDrag(barricadeDrop2.model, newScreen2)); } } } for (int n = 0; n < StructureManager.regions[k, l].drops.Count; n++) { StructureDrop structureDrop = StructureManager.regions[k, l].drops[n]; if (structureDrop != null) { Vector3 newScreen3 = MainCamera.instance.WorldToScreenPoint(structureDrop.model.position); if (newScreen3.z >= 0f) { newScreen3.y = (float)Screen.height - newScreen3.y; this.dragable.Add(new EditorDrag(structureDrop.model, newScreen3)); } } } } } } } } if (!Input.GetKey(ControlsSettings.modify)) { for (int num5 = 0; num5 < this.selection.Count; num5++) { if (!(this.selection[num5].transform == null)) { Vector3 vector = MainCamera.instance.WorldToScreenPoint(this.selection[num5].transform.position); if (vector.z < 0f) { this.removeSelection(this.selection[num5].transform); } else { vector.y = (float)Screen.height - vector.y; if (vector.x < (float)num || vector.y < (float)num2 || vector.x > (float)num3 || vector.y > (float)num4) { this.removeSelection(this.selection[num5].transform); } } } } } for (int num6 = 0; num6 < this.dragable.Count; num6++) { EditorDrag editorDrag = this.dragable[num6]; if (!(editorDrag.transform == null)) { if (!(editorDrag.transform.parent == this.group)) { if (editorDrag.screen.x >= (float)num && editorDrag.screen.y >= (float)num2 && editorDrag.screen.x <= (float)num3 && editorDrag.screen.y <= (float)num4) { this.addSelection(editorDrag.transform); } } } } } } if (this.selection.Count > 0 && Input.GetKeyDown(ControlsSettings.tool_2) && this.worldHit.transform != null) { this.pointSelection(); this.handle.position = this.worldHit.point; if (Input.GetKey(ControlsSettings.snap)) { this.handle.position += this.worldHit.normal * this.snapTransform; } this.updateGroup(); this.applySelection(); } } } if (Input.GetKeyUp(ControlsSettings.primary) && this.dragStart.x != 0f) { this._dragStart = Vector2.zero; if (this.isDragging) { this._dragEnd = Vector2.zero; this._isDragging = false; if (this.onDragStopped != null) { this.onDragStopped(); } } } }
public static void explode(Vector3 point, float damageRadius, EDeathCause cause, CSteamID killer, float playerDamage, float zombieDamage, float animalDamage, float barricadeDamage, float structureDamage, float vehicleDamage, float resourceDamage, float objectDamage, EExplosionDamageType damageType = EExplosionDamageType.CONVENTIONAL, float alertRadius = 32f, bool playImpactEffect = true) { DamageTool.explosionRangeComparator.point = point; float num = damageRadius * damageRadius; DamageTool.regionsInRadius.Clear(); Regions.getRegionsInRadius(point, damageRadius, DamageTool.regionsInRadius); if (structureDamage > 0.5f) { DamageTool.structuresInRadius.Clear(); StructureManager.getStructuresInRadius(point, num, DamageTool.regionsInRadius, DamageTool.structuresInRadius); DamageTool.structuresInRadius.Sort(DamageTool.explosionRangeComparator); for (int i = 0; i < DamageTool.structuresInRadius.Count; i++) { Transform transform = DamageTool.structuresInRadius[i]; if (!(transform == null)) { ushort id; if (ushort.TryParse(transform.name, out id)) { ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id); if (itemStructureAsset != null && !itemStructureAsset.proofExplosion) { Vector3 vector = transform.transform.position - point; float magnitude = vector.magnitude; Vector3 vector2 = vector / magnitude; if (magnitude > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector2), out raycastHit, magnitude - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != transform.transform) { goto IL_154; } } StructureManager.damage(transform, vector.normalized, structureDamage, 1f - magnitude / damageRadius, true); } } } IL_154 :; } } if (resourceDamage > 0.5f) { DamageTool.resourcesInRadius.Clear(); ResourceManager.getResourcesInRadius(point, num, DamageTool.regionsInRadius, DamageTool.resourcesInRadius); DamageTool.resourcesInRadius.Sort(DamageTool.explosionRangeComparator); for (int j = 0; j < DamageTool.resourcesInRadius.Count; j++) { Transform transform2 = DamageTool.resourcesInRadius[j]; if (!(transform2 == null)) { Vector3 vector3 = transform2.transform.position - point; float magnitude2 = vector3.magnitude; Vector3 vector4 = vector3 / magnitude2; if (magnitude2 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector4), out raycastHit, magnitude2 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != transform2.transform) { goto IL_26D; } } EPlayerKill eplayerKill; uint num2; ResourceManager.damage(transform2, vector3.normalized, resourceDamage, 1f - magnitude2 / damageRadius, 1f, out eplayerKill, out num2); } IL_26D :; } } if (objectDamage > 0.5f) { DamageTool.objectsInRadius.Clear(); ObjectManager.getObjectsInRadius(point, num, DamageTool.regionsInRadius, DamageTool.objectsInRadius); DamageTool.objectsInRadius.Sort(DamageTool.explosionRangeComparator); for (int k = 0; k < DamageTool.objectsInRadius.Count; k++) { Transform transform3 = DamageTool.objectsInRadius[k]; if (!(transform3 == null)) { InteractableObjectRubble component = transform3.GetComponent <InteractableObjectRubble>(); if (!(component == null)) { if (!component.asset.rubbleProofExplosion) { for (byte b = 0; b < component.getSectionCount(); b += 1) { Transform section = component.getSection(b); Vector3 vector5 = section.position - point; if (vector5.sqrMagnitude < num) { float magnitude3 = vector5.magnitude; Vector3 vector6 = vector5 / magnitude3; if (magnitude3 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector6), out raycastHit, magnitude3 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != transform3.transform) { goto IL_3CA; } } EPlayerKill eplayerKill; uint num2; ObjectManager.damage(transform3, vector5.normalized, b, objectDamage, 1f - magnitude3 / damageRadius, out eplayerKill, out num2); } IL_3CA :; } } } } } } if (barricadeDamage > 0.5f) { DamageTool.barricadesInRadius.Clear(); BarricadeManager.getBarricadesInRadius(point, num, DamageTool.regionsInRadius, DamageTool.barricadesInRadius); BarricadeManager.getBarricadesInRadius(point, num, DamageTool.barricadesInRadius); DamageTool.barricadesInRadius.Sort(DamageTool.explosionRangeComparator); for (int l = 0; l < DamageTool.barricadesInRadius.Count; l++) { Transform transform4 = DamageTool.barricadesInRadius[l]; if (!(transform4 == null)) { Vector3 vector7 = transform4.transform.position - point; float magnitude4 = vector7.magnitude; Vector3 vector8 = vector7 / magnitude4; if (magnitude4 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector8), out raycastHit, magnitude4 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != transform4.transform) { goto IL_52A; } } ushort id2; if (ushort.TryParse(transform4.name, out id2)) { ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id2); if (itemBarricadeAsset != null && !itemBarricadeAsset.proofExplosion) { BarricadeManager.damage(transform4, barricadeDamage, 1f - magnitude4 / damageRadius, true); } } } IL_52A :; } } if ((Provider.isPvP || damageType == EExplosionDamageType.ZOMBIE_ACID || damageType == EExplosionDamageType.ZOMBIE_FIRE || damageType == EExplosionDamageType.ZOMBIE_ELECTRIC) && playerDamage > 0.5f) { DamageTool.playersInRadius.Clear(); PlayerTool.getPlayersInRadius(point, num, DamageTool.playersInRadius); for (int m = 0; m < DamageTool.playersInRadius.Count; m++) { Player player = DamageTool.playersInRadius[m]; if (!(player == null) && !player.life.isDead) { if (damageType != EExplosionDamageType.ZOMBIE_FIRE || player.clothing.shirtAsset == null || !player.clothing.shirtAsset.proofFire || player.clothing.pantsAsset == null || !player.clothing.pantsAsset.proofFire) { Vector3 vector9 = player.transform.position - point; float magnitude5 = vector9.magnitude; Vector3 vector10 = vector9 / magnitude5; if (magnitude5 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector10), out raycastHit, magnitude5 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != player.transform) { goto IL_760; } } if (playImpactEffect) { EffectManager.sendEffect(5, EffectManager.SMALL, player.transform.position + Vector3.up, -vector10); EffectManager.sendEffect(5, EffectManager.SMALL, player.transform.position + Vector3.up, Vector3.up); } float num3 = 1f - Mathf.Pow(magnitude5 / damageRadius, 2f); if (player.movement.getVehicle() != null && player.movement.getVehicle().asset != null) { num3 *= player.movement.getVehicle().asset.passengerExplosionArmor; } EPlayerKill eplayerKill; DamageTool.damage(player, cause, ELimb.SPINE, killer, vector10, playerDamage, num3, out eplayerKill); } } IL_760 :; } } if (damageType == EExplosionDamageType.ZOMBIE_FIRE || zombieDamage > 0.5f) { DamageTool.zombiesInRadius.Clear(); ZombieManager.getZombiesInRadius(point, num, DamageTool.zombiesInRadius); for (int n = 0; n < DamageTool.zombiesInRadius.Count; n++) { Zombie zombie = DamageTool.zombiesInRadius[n]; if (!(zombie == null) && !zombie.isDead) { if (damageType == EExplosionDamageType.ZOMBIE_FIRE) { if (zombie.speciality == EZombieSpeciality.NORMAL) { ZombieManager.sendZombieSpeciality(zombie, EZombieSpeciality.BURNER); } } else { Vector3 vector11 = zombie.transform.position - point; float magnitude6 = vector11.magnitude; Vector3 vector12 = vector11 / magnitude6; if (magnitude6 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector12), out raycastHit, magnitude6 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != zombie.transform) { goto IL_90E; } } if (playImpactEffect) { EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, zombie.transform.position + Vector3.up, -vector12); EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, zombie.transform.position + Vector3.up, Vector3.up); } EPlayerKill eplayerKill; uint num2; DamageTool.damage(zombie, vector12, zombieDamage, 1f - magnitude6 / damageRadius, out eplayerKill, out num2); } } IL_90E :; } } if (animalDamage > 0.5f) { DamageTool.animalsInRadius.Clear(); AnimalManager.getAnimalsInRadius(point, num, DamageTool.animalsInRadius); for (int num4 = 0; num4 < DamageTool.animalsInRadius.Count; num4++) { Animal animal = DamageTool.animalsInRadius[num4]; if (!(animal == null) && !animal.isDead) { Vector3 vector13 = animal.transform.position - point; float magnitude7 = vector13.magnitude; Vector3 vector14 = vector13 / magnitude7; if (magnitude7 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector14), out raycastHit, magnitude7 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != animal.transform) { goto IL_A6A; } } if (playImpactEffect) { EffectManager.sendEffect(5, EffectManager.SMALL, animal.transform.position + Vector3.up, -vector14); EffectManager.sendEffect(5, EffectManager.SMALL, animal.transform.position + Vector3.up, Vector3.up); } EPlayerKill eplayerKill; uint num2; DamageTool.damage(animal, vector14, animalDamage, 1f - magnitude7 / damageRadius, out eplayerKill, out num2); } IL_A6A :; } } if (vehicleDamage > 0.5f) { DamageTool.vehiclesInRadius.Clear(); VehicleManager.getVehiclesInRadius(point, num, DamageTool.vehiclesInRadius); for (int num5 = 0; num5 < DamageTool.vehiclesInRadius.Count; num5++) { InteractableVehicle interactableVehicle = DamageTool.vehiclesInRadius[num5]; if (!(interactableVehicle == null) && !interactableVehicle.isDead) { Vector3 vector15 = interactableVehicle.transform.position - point; float magnitude8 = vector15.magnitude; Vector3 vector16 = vector15 / magnitude8; if (magnitude8 > 0.5f) { RaycastHit raycastHit; PhysicsUtility.raycast(new Ray(point, vector16), out raycastHit, magnitude8 - 0.5f, RayMasks.BLOCK_EXPLOSION, 0); if (raycastHit.transform != null && raycastHit.transform != interactableVehicle.transform) { goto IL_B6C; } } VehicleManager.damage(interactableVehicle, vehicleDamage, 1f - magnitude8 / damageRadius, false); } IL_B6C :; } } AlertTool.alert(point, alertRadius); }