private static void UpdatePosition() { ConstructableBase componentInParent = ghostModel.GetComponentInParent <ConstructableBase>(); if (componentInParent != null) { Transform transform = componentInParent.transform; transform.position = PlacePosition; transform.rotation = PlaceRotation; bool flag; BaseGhost baseGhost = ghostModel.GetComponent <BaseGhost>(); bool flag2 = UpdatePlacement(baseGhost, GetAimTransform(), componentInParent.placeMaxDistance, out bool positionFound, out flag, componentInParent); componentInParent.SetGhostVisible(positionFound); if (flag2 && RotationMetadata.HasValue) { ApplyRotationMetadata(baseGhost, RotationMetadata.Value); } if (flag) { renderers = MaterialExtensions.AssignMaterial(ghostModel, ghostStructureMaterial); InitBounds(ghostModel); } } Transform ghostModelTransform = ghostModel.transform; ghostModelTransform.position = PlacePosition + PlaceRotation * ghostModelPosition; ghostModelTransform.rotation = PlaceRotation * ghostModelRotation; ghostModelTransform.localScale = ghostModelScale; }
// Token: 0x06002B9C RID: 11164 RVA: 0x001040F8 File Offset: 0x001022F8 private static bool UpdateAllowed() { //MultiplayerBuilder.SetDefaultPlaceTransform(ref MultiplayerBuilder.placePosition, ref MultiplayerBuilder.placeRotation); bool flag = false; ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>(); bool flag2; if (componentInParent != null) { Transform transform = componentInParent.transform; transform.position = MultiplayerBuilder.placePosition; transform.rotation = MultiplayerBuilder.placeRotation; flag2 = componentInParent.UpdateGhostModel(MultiplayerBuilder.GetAimTransform(), MultiplayerBuilder.ghostModel, default(RaycastHit), out flag); //MultiplayerBuilder.placePosition = transform.position; //MultiplayerBuilder.placeRotation = transform.rotation; if (flag) { MultiplayerBuilder.renderers = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial); MultiplayerBuilder.InitBounds(MultiplayerBuilder.ghostModel); } } else { flag2 = MultiplayerBuilder.CheckAsSubModule(); } if (flag2) { List <GameObject> list = new List <GameObject>(); MultiplayerBuilder.GetObstacles(MultiplayerBuilder.placePosition, MultiplayerBuilder.placeRotation, MultiplayerBuilder.bounds, list); flag2 = (list.Count == 0); list.Clear(); } return(flag2); }
// Token: 0x06002B9B RID: 11163 RVA: 0x00103EBC File Offset: 0x001020BC private static bool CreateGhost() { if (MultiplayerBuilder.ghostModel != null) { return(false); } Constructable component = MultiplayerBuilder.prefab.GetComponent <Constructable>(); MultiplayerBuilder.constructableTechType = component.techType; MultiplayerBuilder.placeMinDistance = component.placeMinDistance; MultiplayerBuilder.placeMaxDistance = component.placeMaxDistance; MultiplayerBuilder.placeDefaultDistance = component.placeDefaultDistance; MultiplayerBuilder.allowedSurfaceTypes = component.allowedSurfaceTypes; MultiplayerBuilder.forceUpright = component.forceUpright; MultiplayerBuilder.allowedInSub = component.allowedInSub; MultiplayerBuilder.allowedInBase = component.allowedInBase; MultiplayerBuilder.allowedOutside = component.allowedOutside; MultiplayerBuilder.allowedOnConstructables = component.allowedOnConstructables; MultiplayerBuilder.rotationEnabled = component.rotationEnabled; ConstructableBase component2 = MultiplayerBuilder.prefab.GetComponent <ConstructableBase>(); if (component2 != null) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab); component2 = gameObject.GetComponent <ConstructableBase>(); MultiplayerBuilder.ghostModel = component2.model; BaseGhost component3 = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>(); component3.SetupGhost(); MultiplayerBuilder.ghostModelPosition = Vector3.zero; MultiplayerBuilder.ghostModelRotation = Quaternion.identity; MultiplayerBuilder.ghostModelScale = Vector3.one; MultiplayerBuilder.renderers = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial); MultiplayerBuilder.InitBounds(MultiplayerBuilder.ghostModel); } else { MultiplayerBuilder.ghostModel = UnityEngine.Object.Instantiate <GameObject>(component.model); MultiplayerBuilder.ghostModel.SetActive(true); Transform component4 = component.GetComponent <Transform>(); Transform component5 = component.model.GetComponent <Transform>(); Quaternion quaternion = Quaternion.Inverse(component4.rotation); MultiplayerBuilder.ghostModelPosition = quaternion * (component5.position - component4.position); MultiplayerBuilder.ghostModelRotation = quaternion * component5.rotation; MultiplayerBuilder.ghostModelScale = component5.lossyScale; Collider[] componentsInChildren = MultiplayerBuilder.ghostModel.GetComponentsInChildren <Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { UnityEngine.Object.Destroy(componentsInChildren[i]); } MultiplayerBuilder.renderers = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial); MultiplayerBuilder.SetupRenderers(MultiplayerBuilder.ghostModel, Player.main.IsInSub()); MultiplayerBuilder.CreatePowerPreview(MultiplayerBuilder.constructableTechType, MultiplayerBuilder.ghostModel); MultiplayerBuilder.InitBounds(MultiplayerBuilder.prefab); } return(true); }
private static void CreateGhost() { Constructable component = prefab.GetComponent <Constructable>(); constructableTechType = component.techType; allowedOutside = component.allowedOutside; ConstructableBase component2 = prefab.GetComponent <ConstructableBase>(); if (component2 != null) { GameObject gameObject = Object.Instantiate <GameObject>(prefab); component2 = gameObject.GetComponent <ConstructableBase>(); ghostModel = component2.model; BaseGhost component3 = ghostModel.GetComponent <BaseGhost>(); component3.SetupGhost(); ghostModelPosition = Vector3.zero; ghostModelRotation = Quaternion.identity; ghostModelScale = Vector3.one; renderers = MaterialExtensions.AssignMaterial(ghostModel, ghostStructureMaterial); InitBounds(ghostModel); } else { ghostModel = Object.Instantiate <GameObject>(component.model); ghostModel.SetActive(true); Transform component4 = component.GetComponent <Transform>(); Transform component5 = component.model.GetComponent <Transform>(); Quaternion quaternion = Quaternion.Inverse(component4.rotation); ghostModelPosition = quaternion * (component5.position - component4.position); ghostModelRotation = quaternion * component5.rotation; ghostModelScale = component5.lossyScale; Collider[] componentsInChildren = ghostModel.GetComponentsInChildren <Collider>(); foreach (Collider collider in componentsInChildren) { Object.Destroy(collider); } renderers = MaterialExtensions.AssignMaterial(ghostModel, ghostStructureMaterial); SetupRenderers(ghostModel, Player.main.IsInSub()); CreatePowerPreview(); InitBounds(prefab); } }