public static void registerRemoveObject(Transform select) { if (select == null) { return; } byte b; byte b2; if (Regions.tryGetCoordinate(select.position, out b, out b2)) { if (select.CompareTag("Barricade") || select.CompareTag("Structure")) { for (int i = 0; i < LevelObjects.buildables[(int)b, (int)b2].Count; i++) { if (LevelObjects.buildables[(int)b, (int)b2][i].transform == select) { LevelObjects.register(new ReunObjectRemove(LevelObjects.step, select, null, LevelObjects.buildables[(int)b, (int)b2][i].asset, select.position, select.rotation, select.localScale)); break; } } } else { for (int j = 0; j < LevelObjects.objects[(int)b, (int)b2].Count; j++) { if (LevelObjects.objects[(int)b, (int)b2][j].transform == select) { LevelObjects.register(new ReunObjectRemove(LevelObjects.step, select, LevelObjects.objects[(int)b, (int)b2][j].asset, null, select.position, select.rotation, select.localScale)); break; } } } } }
// Token: 0x06001F54 RID: 8020 RVA: 0x000ADB14 File Offset: 0x000ABF14 public void undo() { if (this.model != null) { LevelObjects.transformObject(this.model, this.fromPosition, this.fromRotation, this.fromScale, this.toPosition, this.toRotation, this.toScale); } }
public void undo() { if (this.model != null) { LevelObjects.removeObject(this.model); this.model = null; } }
// Token: 0x06001F53 RID: 8019 RVA: 0x000ADAC0 File Offset: 0x000ABEC0 public Transform redo() { if (this.model != null) { LevelObjects.transformObject(this.model, this.toPosition, this.toRotation, this.toScale, this.fromPosition, this.fromRotation, this.fromScale); } return(this.model); }
public static void applySelection() { LevelObjects.step++; for (int i = 0; i < EditorObjects.selection.Count; i++) { LevelObjects.registerTransformObject(EditorObjects.selection[i].transform, EditorObjects.selection[i].transform.position, EditorObjects.selection[i].transform.rotation, EditorObjects.selection[i].transform.localScale, EditorObjects.selection[i].fromPosition, EditorObjects.selection[i].fromRotation, EditorObjects.selection[i].fromScale); } }
public void undo() { if (this.model == null) { if (this.objectAsset != null) { this.model = LevelObjects.addObject(this.position, this.rotation, this.scale, this.objectAsset.id, this.objectAsset.name, this.objectAsset.GUID, ELevelObjectPlacementOrigin.MANUAL); } else if (this.itemAsset != null) { this.model = LevelObjects.addBuildable(this.position, this.rotation, this.itemAsset.id); } } }
private static void findChartHit(Vector3 pos, out EObjectChart chart, out RaycastHit hit) { Physics.Raycast(pos, Vector3.down, ref hit, Level.HEIGHT, RayMasks.CHART); chart = EObjectChart.NONE; ObjectAsset asset = LevelObjects.getAsset(hit.transform); if (asset != null) { chart = asset.chart; } if (chart == EObjectChart.IGNORE) { Level.findChartHit(hit.point + Vector3.down * 0.1f, out chart, out hit); return; } }
public Transform redo() { if (this.model != null) { if (this.objectAsset != null) { LevelObjects.removeObject(this.model); this.model = null; } else if (this.itemAsset != null) { LevelObjects.removeBuildable(this.model); this.model = null; } } return(null); }
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(); }
private void OnTriggerEnter(Collider other) { if (Provider.isServer) { if (other.isTrigger) { return; } if (other.CompareTag("Debris")) { return; } float num = Mathf.Clamp(this.vehicle.speed * this.vehicle.asset.bumperMultiplier, 0f, 10f); if (num < 3f) { return; } if (other.transform.parent.CompareTag("Vehicle")) { return; } if (other.transform.CompareTag("Player")) { if (Provider.isPvP && this.vehicle.isDriven) { Player player = DamageTool.getPlayer(other.transform); if (player != null && player.movement.getVehicle() == null && !this.vehicle.passengers[0].player.player.quests.isMemberOfSameGroupAs(player)) { EPlayerKill eplayerKill; DamageTool.damage(player, EDeathCause.ROADKILL, ELimb.SPINE, this.vehicle.passengers[0].player.playerID.steamID, base.transform.forward, Bumper.DAMAGE_PLAYER, num, out eplayerKill); EffectManager.sendEffect(5, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward); this.vehicle.askDamage(2, true); } } } else if (other.transform.CompareTag("Agent")) { Zombie zombie = DamageTool.getZombie(other.transform); if (zombie != null) { EPlayerKill eplayerKill2; uint num2; DamageTool.damage(zombie, base.transform.forward, Bumper.DAMAGE_ZOMBIE, num, out eplayerKill2, out num2); EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward); this.vehicle.askDamage(2, true); } else { Animal animal = DamageTool.getAnimal(other.transform); if (animal != null) { EPlayerKill eplayerKill3; uint num3; DamageTool.damage(animal, base.transform.forward, Bumper.DAMAGE_ANIMAL, num, out eplayerKill3, out num3); EffectManager.sendEffect(5, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward); this.vehicle.askDamage(2, true); } } } else { if (!other.transform.CompareTag("Barricade")) { if (!other.transform.CompareTag("Structure")) { if (other.transform.CompareTag("Resource")) { DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true); EPlayerKill eplayerKill4; uint num4; ResourceManager.damage(other.transform, base.transform.forward, Bumper.DAMAGE_RESOURCE, num, 1f, out eplayerKill4, out num4); this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true); } else { InteractableObjectRubble componentInParent = other.transform.GetComponentInParent <InteractableObjectRubble>(); if (componentInParent != null) { EPlayerKill eplayerKill5; uint num5; DamageTool.damage(componentInParent.transform, base.transform.forward, componentInParent.getSection(other.transform), Bumper.DAMAGE_OBJECT, num, out eplayerKill5, out num5); if (Time.realtimeSinceStartup - this.lastDamageImpact > 0.2f) { this.lastDamageImpact = Time.realtimeSinceStartup; DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true); this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true); } } else if (Time.realtimeSinceStartup - this.lastDamageImpact > 0.2f) { ObjectAsset asset = LevelObjects.getAsset(other.transform); if (asset != null && !asset.isSoft) { this.lastDamageImpact = Time.realtimeSinceStartup; DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true); this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true); } } } } } if (!this.vehicle.isDead && !other.transform.CompareTag("Border") && ((this.vehicle.asset.engine == EEngine.PLANE && this.vehicle.speed > 20f) || (this.vehicle.asset.engine == EEngine.HELICOPTER && this.vehicle.speed > 10f))) { this.vehicle.askDamage(20000, false); } } } }
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; }
public static void registerTransformObject(Transform select, Vector3 toPosition, Quaternion toRotation, Vector3 toScale, Vector3 fromPosition, Quaternion fromRotation, Vector3 fromScale) { LevelObjects.register(new ReunObjectTransform(LevelObjects.step, select, fromPosition, fromRotation, fromScale, toPosition, toRotation, toScale)); }
private static void onRegionUpdated(byte old_x, byte old_y, byte new_x, byte new_y) { bool flag = true; LevelObjects.onRegionUpdated(null, old_x, old_y, new_x, new_y, 0, ref flag); }
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 Transform registerAddObject(Vector3 position, Quaternion rotation, Vector3 scale, ObjectAsset objectAsset, ItemAsset itemAsset) { return(LevelObjects.register(new ReunObjectAdd(LevelObjects.step, objectAsset, itemAsset, position, rotation, scale))); }
public static Transform addObject(Vector3 position, Quaternion rotation, Vector3 scale, ushort id, string name, Guid GUID, ELevelObjectPlacementOrigin placementOrigin) { byte b; byte b2; if (Regions.tryGetCoordinate(position, out b, out b2)) { LevelObject levelObject = new LevelObject(position, rotation, scale, id, name, GUID, placementOrigin, LevelObjects.generateUniqueInstanceID()); levelObject.enableCollision(); levelObject.enableVisual(); levelObject.disableSkybox(); LevelObjects.objects[(int)b, (int)b2].Add(levelObject); LevelObjects._total++; return(levelObject.transform); } return(null); }
private void Update() { if (!EditorObjects.isBuilding) { return; } if (GUIUtility.hotControl == 0) { if (EditorInteract.isFlying) { EditorObjects.handleType = EDragType.NONE; if (EditorObjects.isDragging) { EditorObjects._dragStart = Vector2.zero; EditorObjects._dragEnd = Vector2.zero; EditorObjects._isDragging = false; if (EditorObjects.onDragStopped != null) { EditorObjects.onDragStopped(); } EditorObjects.clearSelection(); } return; } if (EditorObjects.handleType != EDragType.NONE) { if (!Input.GetKey(ControlsSettings.primary)) { if (EditorObjects.dragMode == EDragMode.SCALE) { for (int i = 0; i < EditorObjects.selection.Count; i++) { EditorObjects.selection[i].transform.parent = EditorObjects.selection[i].parent; } EditorObjects.group.localScale = Vector3.one; for (int j = 0; j < EditorObjects.selection.Count; j++) { EditorObjects.selection[j].transform.parent = EditorObjects.group; } } EditorObjects.applySelection(); EditorObjects.handleType = EDragType.NONE; } else { if (EditorObjects.handleType == EDragType.TRANSFORM_X) { EditorObjects.transformGroup(EditorObjects.handle.right, EditorObjects.handle.up); } else if (EditorObjects.handleType == EDragType.TRANSFORM_Y) { EditorObjects.transformGroup(EditorObjects.handle.up, EditorObjects.handle.right); } else if (EditorObjects.handleType == EDragType.TRANSFORM_Z) { EditorObjects.transformGroup(EditorObjects.handle.forward, EditorObjects.handle.up); } else if (EditorObjects.handleType == EDragType.PLANE_X) { EditorObjects.planeGroup(EditorObjects.handle.right); } else if (EditorObjects.handleType == EDragType.PLANE_Y) { EditorObjects.planeGroup(EditorObjects.handle.up); } else if (EditorObjects.handleType == EDragType.PLANE_Z) { EditorObjects.planeGroup(EditorObjects.handle.forward); } if (EditorObjects.handleType == EDragType.ROTATION_X) { EditorObjects.rotateGroup(EditorObjects.handle.right, Vector3.right); } else if (EditorObjects.handleType == EDragType.ROTATION_Y) { EditorObjects.rotateGroup(EditorObjects.handle.up, Vector3.up); } else if (EditorObjects.handleType == EDragType.ROTATION_Z) { EditorObjects.rotateGroup(EditorObjects.handle.forward, Vector3.forward); } else if (EditorObjects.handleType == EDragType.SCALE_X) { EditorObjects.scaleGroup(EditorObjects.handle.right, Vector3.right, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.x); } else if (EditorObjects.handleType == EDragType.SCALE_Y) { EditorObjects.scaleGroup(EditorObjects.handle.up, Vector3.up, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.y); } else if (EditorObjects.handleType == EDragType.SCALE_Z) { EditorObjects.scaleGroup(EditorObjects.handle.forward, Vector3.forward, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.z); } else if (EditorObjects.handleType == EDragType.SIZE) { EditorObjects.sizeGroup(EditorObjects.handle.localScale.x); } } } if (Input.GetKeyDown(ControlsSettings.tool_0)) { EditorObjects.dragMode = EDragMode.TRANSFORM; } if (Input.GetKeyDown(ControlsSettings.tool_1)) { EditorObjects.dragMode = EDragMode.ROTATE; } if (Input.GetKeyDown(ControlsSettings.tool_3)) { EditorObjects.dragMode = EDragMode.SCALE; } if ((Input.GetKeyDown(127) || Input.GetKeyDown(8)) && EditorObjects.selection.Count > 0) { LevelObjects.step++; for (int k = 0; k < EditorObjects.selection.Count; k++) { EditorObjects.selection[k].transform.parent = EditorObjects.selection[k].parent; LevelObjects.registerRemoveObject(EditorObjects.selection[k].transform); } EditorObjects.selection.Clear(); EditorObjects.calculateHandleOffsets(); } if (Input.GetKeyDown(122) && Input.GetKey(306)) { EditorObjects.clearSelection(); LevelObjects.undo(); } if (Input.GetKeyDown(120) && Input.GetKey(306)) { EditorObjects.clearSelection(); LevelObjects.redo(); } if (Input.GetKeyDown(98) && EditorObjects.selection.Count > 0 && Input.GetKey(306)) { EditorObjects.copyPosition = EditorObjects.handle.position; EditorObjects.copyRotation = EditorObjects.handle.rotation; if (EditorObjects.selection.Count == 1) { EditorObjects.copyScale = EditorObjects.selection[0].transform.localScale; EditorObjects.copyScale.x = EditorObjects.copyScale.x * EditorObjects.group.localScale.x; EditorObjects.copyScale.y = EditorObjects.copyScale.y * EditorObjects.group.localScale.y; EditorObjects.copyScale.z = EditorObjects.copyScale.z * EditorObjects.group.localScale.z; } else { EditorObjects.copyScale = Vector3.one; } } if (Input.GetKeyDown(110) && EditorObjects.selection.Count > 0 && EditorObjects.copyPosition != Vector3.zero && Input.GetKey(306)) { EditorObjects.pointSelection(); EditorObjects.handle.position = EditorObjects.copyPosition; EditorObjects.handle.rotation = EditorObjects.copyRotation; if (EditorObjects.selection.Count == 1) { EditorObjects.group.localScale = EditorObjects.copyScale; } EditorObjects.updateGroup(); EditorObjects.applySelection(); } if (Input.GetKeyDown(99) && EditorObjects.selection.Count > 0 && Input.GetKey(306)) { EditorObjects.copies.Clear(); for (int l = 0; l < EditorObjects.selection.Count; l++) { ObjectAsset objectAsset; ItemAsset itemAsset; LevelObjects.getAssetEditor(EditorObjects.selection[l].transform, out objectAsset, out itemAsset); if (objectAsset != null || itemAsset != null) { EditorObjects.copies.Add(new EditorCopy(EditorObjects.selection[l].transform.position, EditorObjects.selection[l].transform.rotation, EditorObjects.selection[l].transform.localScale, objectAsset, itemAsset)); } } } if (Input.GetKeyDown(118) && EditorObjects.copies.Count > 0 && Input.GetKey(306)) { EditorObjects.clearSelection(); LevelObjects.step++; for (int m = 0; m < EditorObjects.copies.Count; m++) { Transform transform = LevelObjects.registerAddObject(EditorObjects.copies[m].position, EditorObjects.copies[m].rotation, EditorObjects.copies[m].scale, EditorObjects.copies[m].objectAsset, EditorObjects.copies[m].itemAsset); if (transform != null) { EditorObjects.addSelection(transform); } } } if (EditorObjects.handleType == EDragType.NONE) { if (Input.GetKeyDown(ControlsSettings.primary)) { if (EditorInteract.logicHit.transform != null && (EditorInteract.logicHit.transform.name == "Arrow_X" || EditorInteract.logicHit.transform.name == "Arrow_Y" || EditorInteract.logicHit.transform.name == "Arrow_Z" || EditorInteract.logicHit.transform.name == "Plane_X" || EditorInteract.logicHit.transform.name == "Plane_Y" || EditorInteract.logicHit.transform.name == "Plane_Z" || EditorInteract.logicHit.transform.name == "Circle_X" || EditorInteract.logicHit.transform.name == "Circle_Y" || EditorInteract.logicHit.transform.name == "Circle_Z" || EditorInteract.logicHit.transform.name == "Scale_X" || EditorInteract.logicHit.transform.name == "Scale_Y" || EditorInteract.logicHit.transform.name == "Scale_Z" || EditorInteract.logicHit.transform.name == "Size")) { EditorObjects.mouseOrigin = Input.mousePosition; EditorObjects.transformOrigin = EditorObjects.handle.position; EditorObjects.rotateOrigin = EditorObjects.handle.rotation; EditorObjects.scaleOrigin = EditorObjects.group.localScale; EditorObjects.handleOffset = EditorInteract.logicHit.point - EditorObjects.handle.position; EditorObjects.pointSelection(); if (EditorInteract.logicHit.transform.name == "Arrow_X") { EditorObjects.handleType = EDragType.TRANSFORM_X; } else if (EditorInteract.logicHit.transform.name == "Arrow_Y") { EditorObjects.handleType = EDragType.TRANSFORM_Y; } else if (EditorInteract.logicHit.transform.name == "Arrow_Z") { EditorObjects.handleType = EDragType.TRANSFORM_Z; } else if (EditorInteract.logicHit.transform.name == "Plane_X") { EditorObjects.handleType = EDragType.PLANE_X; } else if (EditorInteract.logicHit.transform.name == "Plane_Y") { EditorObjects.handleType = EDragType.PLANE_Y; } else if (EditorInteract.logicHit.transform.name == "Plane_Z") { EditorObjects.handleType = EDragType.PLANE_Z; } else if (EditorInteract.logicHit.transform.name == "Circle_X") { EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f); EditorObjects.handleType = EDragType.ROTATION_X; } else if (EditorInteract.logicHit.transform.name == "Circle_Y") { EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f); EditorObjects.handleType = EDragType.ROTATION_Y; } else if (EditorInteract.logicHit.transform.name == "Circle_Z") { EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f); EditorObjects.handleType = EDragType.ROTATION_Z; } else if (EditorInteract.logicHit.transform.name == "Scale_X") { EditorObjects.handleType = EDragType.SCALE_X; } else if (EditorInteract.logicHit.transform.name == "Scale_Y") { EditorObjects.handleType = EDragType.SCALE_Y; } else if (EditorInteract.logicHit.transform.name == "Scale_Z") { EditorObjects.handleType = EDragType.SCALE_Z; } else if (EditorInteract.logicHit.transform.name == "Size") { EditorObjects.handleType = EDragType.SIZE; } } else if (EditorInteract.objectHit.transform != null) { if (Input.GetKey(ControlsSettings.modify)) { if (EditorObjects.containsSelection(EditorInteract.objectHit.transform)) { EditorObjects.removeSelection(EditorInteract.objectHit.transform); } else { EditorObjects.addSelection(EditorInteract.objectHit.transform); } } else if (EditorObjects.containsSelection(EditorInteract.objectHit.transform)) { EditorObjects.clearSelection(); } else { EditorObjects.clearSelection(); EditorObjects.addSelection(EditorInteract.objectHit.transform); } } else { if (!EditorObjects.isDragging) { EditorObjects._dragStart.x = EditorUI.window.mouse_x; EditorObjects._dragStart.y = EditorUI.window.mouse_y; } if (!Input.GetKey(ControlsSettings.modify)) { EditorObjects.clearSelection(); } } } else if (Input.GetKey(ControlsSettings.primary) && EditorObjects.dragStart.x != 0f) { EditorObjects._dragEnd.x = EditorUI.window.mouse_x; EditorObjects._dragEnd.y = EditorUI.window.mouse_y; if (EditorObjects.isDragging || Mathf.Abs(EditorObjects.dragEnd.x - EditorObjects.dragStart.x) > 50f || Mathf.Abs(EditorObjects.dragEnd.x - EditorObjects.dragStart.x) > 50f) { int num = (int)EditorObjects.dragStart.x; int num2 = (int)EditorObjects.dragStart.y; if (EditorObjects.dragEnd.x < EditorObjects.dragStart.x) { num = (int)EditorObjects.dragEnd.x; } if (EditorObjects.dragEnd.y < EditorObjects.dragStart.y) { num2 = (int)EditorObjects.dragEnd.y; } int num3 = (int)EditorObjects.dragEnd.x; int num4 = (int)EditorObjects.dragEnd.y; if (EditorObjects.dragStart.x > EditorObjects.dragEnd.x) { num3 = (int)EditorObjects.dragStart.x; } if (EditorObjects.dragStart.y > EditorObjects.dragEnd.y) { num4 = (int)EditorObjects.dragStart.y; } if (EditorObjects.onDragStarted != null) { EditorObjects.onDragStarted(num, num2, num3, num4); } if (!EditorObjects.isDragging) { EditorObjects._isDragging = true; EditorObjects.dragable.Clear(); byte region_x = Editor.editor.area.region_x; byte region_y = Editor.editor.area.region_y; if (Regions.checkSafe((int)region_x, (int)region_y)) { for (int n = (int)(region_x - 1); n <= (int)(region_x + 1); n++) { for (int num5 = (int)(region_y - 1); num5 <= (int)(region_y + 1); num5++) { if (Regions.checkSafe((int)((byte)n), (int)((byte)num5)) && LevelObjects.regions[n, num5]) { for (int num6 = 0; num6 < LevelObjects.objects[n, num5].Count; num6++) { LevelObject levelObject = LevelObjects.objects[n, num5][num6]; if (!(levelObject.transform == null)) { Vector3 newScreen = MainCamera.instance.WorldToScreenPoint(levelObject.transform.position); if (newScreen.z >= 0f) { newScreen.y = (float)Screen.height - newScreen.y; EditorObjects.dragable.Add(new EditorDrag(levelObject.transform, newScreen)); } } } for (int num7 = 0; num7 < LevelObjects.buildables[n, num5].Count; num7++) { LevelBuildableObject levelBuildableObject = LevelObjects.buildables[n, num5][num7]; if (!(levelBuildableObject.transform == null)) { Vector3 newScreen2 = MainCamera.instance.WorldToScreenPoint(levelBuildableObject.transform.position); if (newScreen2.z >= 0f) { newScreen2.y = (float)Screen.height - newScreen2.y; EditorObjects.dragable.Add(new EditorDrag(levelBuildableObject.transform, newScreen2)); } } } } } } } } if (!Input.GetKey(ControlsSettings.modify)) { for (int num8 = 0; num8 < EditorObjects.selection.Count; num8++) { Vector3 vector = MainCamera.instance.WorldToScreenPoint(EditorObjects.selection[num8].transform.position); if (vector.z < 0f) { EditorObjects.removeSelection(EditorObjects.selection[num8].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) { EditorObjects.removeSelection(EditorObjects.selection[num8].transform); } } } } for (int num9 = 0; num9 < EditorObjects.dragable.Count; num9++) { EditorDrag editorDrag = EditorObjects.dragable[num9]; if (!(editorDrag.transform == null)) { if (!(editorDrag.transform.parent == EditorObjects.group)) { if (editorDrag.screen.x >= (float)num && editorDrag.screen.y >= (float)num2 && editorDrag.screen.x <= (float)num3 && editorDrag.screen.y <= (float)num4) { EditorObjects.addSelection(editorDrag.transform); } } } } } } if (EditorObjects.selection.Count > 0) { if (Input.GetKeyDown(ControlsSettings.tool_2) && EditorInteract.worldHit.transform != null) { EditorObjects.pointSelection(); EditorObjects.handle.position = EditorInteract.worldHit.point; if (Input.GetKey(ControlsSettings.snap)) { EditorObjects.handle.position += EditorInteract.worldHit.normal * EditorObjects.snapTransform; } EditorObjects.updateGroup(); EditorObjects.applySelection(); } if (Input.GetKeyDown(ControlsSettings.focus)) { MainCamera.instance.transform.parent.position = EditorObjects.handle.position - 15f * MainCamera.instance.transform.forward; } } else if (EditorInteract.worldHit.transform != null) { if (EditorInteract.worldHit.transform.CompareTag("Large") || EditorInteract.worldHit.transform.CompareTag("Medium") || EditorInteract.worldHit.transform.CompareTag("Small") || EditorInteract.worldHit.transform.CompareTag("Barricade") || EditorInteract.worldHit.transform.CompareTag("Structure")) { ObjectAsset objectAsset2; ItemAsset itemAsset2; LevelObjects.getAssetEditor(EditorInteract.worldHit.transform, out objectAsset2, out itemAsset2); if (objectAsset2 != null) { EditorUI.hint(EEditorMessage.FOCUS, objectAsset2.objectName); } else if (itemAsset2 != null) { EditorUI.hint(EEditorMessage.FOCUS, itemAsset2.itemName); } } if (Input.GetKeyDown(ControlsSettings.tool_2)) { EditorObjects.handle.position = EditorInteract.worldHit.point; if (Input.GetKey(ControlsSettings.snap)) { EditorObjects.handle.position += EditorInteract.worldHit.normal * EditorObjects.snapTransform; } EditorObjects.handle.rotation = Quaternion.Euler(-90f, 0f, 0f); if (EditorObjects.selectedObjectAsset != null || EditorObjects.selectedItemAsset != null) { LevelObjects.step++; Transform transform2 = LevelObjects.registerAddObject(EditorObjects.handle.position, EditorObjects.handle.rotation, Vector3.one, EditorObjects.selectedObjectAsset, EditorObjects.selectedItemAsset); if (transform2 != null) { EditorObjects.addSelection(transform2); } } } } } } if (Input.GetKeyUp(ControlsSettings.primary) && EditorObjects.dragStart.x != 0f) { EditorObjects._dragStart = Vector2.zero; if (EditorObjects.isDragging) { EditorObjects._dragEnd = Vector2.zero; EditorObjects._isDragging = false; if (EditorObjects.onDragStopped != null) { EditorObjects.onDragStopped(); } } } }
private void Update() { if (!Level.isLoaded) { return; } if (Dedicator.isDedicated) { return; } if (LevelObjects.loads == null || LevelObjects.regions == null || LevelObjects.objects == null) { return; } if (!LevelObjects.isHierarchyReady) { return; } for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (LevelObjects.loads[(int)b, (int)b2] != -1) { if (LevelObjects.loads[(int)b, (int)b2] >= LevelObjects.objects[(int)b, (int)b2].Count) { LevelObjects.loads[(int)b, (int)b2] = -1; if (LevelObjects.onRegionActivated != null) { LevelObjects.onRegionActivated(b, b2); } } else { if (LevelObjects.regions[(int)b, (int)b2]) { if (!LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isCollisionEnabled) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].enableCollision(); } if (!LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isVisualEnabled && !LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isSpeciallyCulled) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].enableVisual(); } if (LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isSkyboxEnabled) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].disableSkybox(); } } else { if (LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isCollisionEnabled) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].disableCollision(); } if (LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isVisualEnabled && !LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isSpeciallyCulled) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].disableVisual(); } if (!LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isSkyboxEnabled && LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].isLandmarkQualityMet) { LevelObjects.objects[(int)b, (int)b2][LevelObjects.loads[(int)b, (int)b2]].enableSkybox(); } } LevelObjects.loads[(int)b, (int)b2]++; } } } } }