public void Place() { if (!CurrentPlacementIsValid) { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } StuffPlacer.RemoveOutlineFromObject(BoardBeingStacked); StuffPlacer.SetStateOfAllBoxCollidersIn(BoardBeingStacked, true); FloatingPointRounder.RoundIn(BoardBeingStacked, true); SnappingPeg.TryToSnapIn(BoardBeingStacked); MegaMeshManager.AddComponentsIn(StackedBoard); foreach (VisualUpdaterWithMeshCombining visualboi in StackedBoard.GetComponentsInChildren <VisualUpdaterWithMeshCombining>()) { visualboi.AllowedToCombineOnStable = true; } SoundPlayer.PlaySoundAt(Sounds.PlaceOnBoard, BoardBeingStacked); BoardBeingStacked = null; BoardBeingStackedCircuitBoard = null; AllSubBoardsInvolvedWithStacking = new List <GameObject>(); Done(); }
public override bool Execute(IEnumerable <string> arguments) { GetScale(); var clone = CreatePrefabFromCode(); clone.transform.position = GetPosition(); clone.AddComponent <ObjectInfo>().ComponentType = ComponentType.Delayer; clone.transform.position = new Vector3(clone.transform.position.x + 10, clone.transform.position.y, clone.transform.position.z + 10); ModUtilities.ExecuteStaticMethod(typeof(StuffPlacer), "SetStateOfAllBoxCollidersFromThingBeingPlaced", true); StuffPlacer.OutlinesOfThingBeingPlaced = null; ModUtilities.SetStaticFieldValue(typeof(StuffPlacer), "BoxCollidersOfThingBeingPlaced", null); FloatingPointRounder.RoundIn(clone, true); MegaMeshManager.AddComponentsIn(clone); foreach (VisualUpdaterWithMeshCombining visualUpdaterWithMeshCombining in clone.GetComponentsInChildren <VisualUpdaterWithMeshCombining>()) { visualUpdaterWithMeshCombining.AllowedToCombineOnStable = true; } SnappingPeg.TryToSnapIn(clone); return(true); }
public override void Do() { var RotateThis = NetObject.GetByNetId(Packet.ComponentID)?.gameObject; if (RotateThis != null) { BoxCollider[] componentsInChildren = RotateThis.GetComponentsInChildren <BoxCollider>(); SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis); RotateThis.transform.localEulerAngles = Packet.EulerAngles; FloatingPointRounder.RoundIn(RotateThis, false); StuffRotater.RedrawCircuitGeometryOf(RotateThis); StuffRotater.DestroyIntersectingConnections(RotateThis); SnappingPeg.TryToSnapIn(RotateThis); MegaMeshManager.RecalculateGroupsOf(RotateThis); } }
public static void PlaceThingBeingPlaced() { if (!OkayToPlace) { // shitty hack to prevent the sound playing in specific circumstances that are undesirable RaycastHit hit; Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask); if (hit.collider == null || hit.collider.tag != "Interactable") { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); } return; } RemoveOutlineFromObject(ThingBeingPlaced, true); // destoryimmediate used so that if what you place has you looking at a peg, you'll be able to get it highlighted SetStateOfAllBoxCollidersFromThingBeingPlaced(true); OutlinesOfThingBeingPlaced = null; BoxCollidersOfThingBeingPlaced = null; FloatingPointRounder.RoundIn(ThingBeingPlaced, true); // mega mesh stuff MegaMeshManager.AddComponentsIn(ThingBeingPlaced); foreach (VisualUpdaterWithMeshCombining visualboi in ThingBeingPlaced.GetComponentsInChildren <VisualUpdaterWithMeshCombining>()) { visualboi.AllowedToCombineOnStable = true; } SnappingPeg.TryToSnapIn(ThingBeingPlaced); if (MostRecentPlacementWasOnBoard) { SoundPlayer.PlaySoundAt(Sounds.PlaceOnBoard, ThingBeingPlaced); } else { SoundPlayer.PlaySoundAt(Sounds.PlaceOnTerrain, ThingBeingPlaced); } ThingBeingPlaced = null; }
public override void Do() { NetObject parentBoard = NetObject.GetByNetId(Packet.ParentBoardID); SavedCircuitBoard savedBoard; using (var mem = new MemoryStream(Packet.SavedBoard)) { savedBoard = (SavedCircuitBoard)BinFormatter.Deserialize(mem); } var boardObj = SavedObjectUtilities.LoadSavedObject(savedBoard, parentBoard?.transform); boardObj.transform.position = Packet.Position; boardObj.transform.eulerAngles = Packet.EulerAngles; foreach (var item in boardObj.GetComponentsInChildren <CircuitOutput>()) { item.On = item.On; //It works 100% of the times most of the time } BoardFunctions.RecalculateClustersOfBoard(boardObj); SnappingPeg.TryToSnapIn(boardObj); }
public static void RotateThing(GameObject RotateThis) { // determines which direction to rotate // TODO: use camera.main.transform to rotate stuff left and right rather than clockwise & ccw if (RotateThis.tag == "World") { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } if (RotateThis.tag == "CircuitBoard" || RotateThis.tag == "PlaceOnlyCircuitBoard") { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } // rotate the full object, not part of it // the last check is so that rotating child boards doesn't rotate their parent RotateThis = ComponentPlacer.FullComponent(RotateThis); Quaternion BeforeRotation = Quaternion.identity; Vector3 AxisToRotateAround = RotateThis.transform.up; // everything but wires should rotate around transform.up if (RotateThis.tag == "Wire") { if (RotateThis.GetComponent <SnappedConnection>()) // you cannot rotate snapped connections { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } AxisToRotateAround = RotateThis.transform.forward; StuffConnector.QueueWireMeshRecalculation(RotateThis); SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis); } else { BeforeRotation = RotateThis.transform.rotation; // non-wires might be rotated into invalid positions, in which case they should be reverted to their original rotations } int direction = 1; if (Input.GetAxis("Rotate") < 0) { direction = -1; } else { direction = 1; } if (Input.GetButton("Mod")) // rotate by 22.5 degrees if the mod key is held down { RotateThis.transform.RotateAround(RotateThis.transform.position, AxisToRotateAround, direction * 22.5f); } else // ...but normally rotate by 90 degrees { RotateThis.transform.RotateAround(RotateThis.transform.position, AxisToRotateAround, direction * 90f); } // the validity of wire placement is never affected when rotating them, but if it's an object, check if it can actually be placed there. If not, revert to original rotation if (RotateThis.tag != "Wire") { BoxCollider[] colliders = RotateThis.GetComponentsInChildren <BoxCollider>(); StuffPlacer.SetStateOfBoxColliders(colliders, false); if (StuffPlacer.GameObjectIntersectingStuffOrWouldDestroyWires(RotateThis, true, true)) // ignore wires { RotateThis.transform.rotation = BeforeRotation; StuffPlacer.SetStateOfBoxColliders(colliders, true); SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis); StuffPlacer.SetStateOfBoxColliders(colliders, true); } FloatingPointRounder.RoundIn(RotateThis); RedrawCircuitGeometryOf(RotateThis); DestroyIntersectingConnections(RotateThis); SnappingPeg.TryToSnapIn(RotateThis); MegaMeshManager.RecalculateGroupsOf(RotateThis); }