private void Start() { Renderer tempRenderer = GetComponentInChildren <Renderer>(); if (tempRenderer != null) { defaultMaterials = tempRenderer.materials; } if (defaultMaterials != null) { for (int i = 0; i < defaultMaterials.Length; i++) { defaultMaterials[i].SetColor("_EmissionColor", new Color(0.1176471f, 0.1176471f, 0.1176471f)); } } rotatableComponent = gameObject.AddComponent <Rotatable>(); rotatableComponent.OnUnregisterForRotation += unregisterForUserGestures; rotatableComponent.OnRegisteringForRotation += registerForUserGestures; movableComponent = gameObject.AddComponent <Movable>(); movableComponent.OnUnregisterForTranslation += registerForUserGestures; movableComponent.OnRegisteringForTranslation += registerForUserGestures; isTableAlreadyExists = false; isThisObjectShowingGuide = false; InteractibleMap.Instance.OnBeforeUserActionOnMap += InteractibleMap_OnBeforeUserActionOnMap; InteractibleMap.Instance.OnAfterUserActionOnMap += InteractibleMap_OnAfterUserActionOnMap; }
private void Start() { mesh = GetComponent <MeshFilter>().mesh; setCoordinates(); // set up the scalable script scalableComponent = gameObject.AddComponent <Scalable>(); scalableComponent.ScalingSensitivity = 10f; scalableComponent.minimumScale = minimumHeightScale; scalableComponent.OnRegisteringForScaling += ScalableScript_OnRegisteringForScaling; scalableComponent.OnScalingUpdated += ScalableScript_OnScalingUpdated; gameObject.AddComponent <DeleteOnVoice>().OnBeforeDelete += DeleteOnVoiceComponent_OnBeforeDelete; movableComponent = gameObject.AddComponent <Movable>(); movableComponent.OnUnregisterForTranslation += UnregisterForTranslation; rotatableComponent = gameObject.AddComponent <Rotatable>(); if (InteractibleMap.Instance != null) { InteractibleMap.Instance.OnBeforeUserActionOnMap += InteractibleMap_OnBeforeMapPlacingStart; InteractibleMap.Instance.OnAfterUserActionOnMap += InteractibleMap_OnMapPlaced; } }
public static void Postfix(ref bool __result, BuildingDef __instance, GameObject source_go, int cell, Orientation orientation, ref string fail_reason) { if (!__result || source_go == null) { return; } List <ConduitIO> portList = MultiIOExtensions.GetAllPortsFromObject(source_go); if (portList.Count == 0) { return; } foreach (ConduitIO port in portList) { CellOffset rotatedCellOffset = Rotatable.GetRotatedCellOffset(port.CellOffset, orientation); int portCell = Grid.OffsetCell(cell, rotatedCellOffset); //fail_reason is ref, Invoke will modify this array if fail_reason is used object[] parameters = new object[] { source_go, port.ConduitType, portCell, fail_reason }; //Debug.Log($"[MultiIO] Are Conduit Ports in Valid Positions?"); __result = (bool)areConduitPortsInValidPositionsMethod.Invoke(__instance, parameters); fail_reason = (string)parameters[3]; if (!__result) { return; } } }
// ------------------------------------------------------------------------------- public void ResetRotation(System.Action onCompleteCallback = null) { var targetrotation = Vector3.zero; var rotationDelta = 0.0f; if (IsUpsideDown) { targetrotation = transform.eulerAngles; targetrotation.y = 180.0f; rotationDelta = Mathf.Abs(targetrotation.y - transform.eulerAngles.y); } else { rotationDelta = Mathf.Abs(targetrotation.y - transform.eulerAngles.y) + Mathf.Abs(targetrotation.x - transform.eulerAngles.x) + Mathf.Abs(targetrotation.z - transform.eulerAngles.z); } var duration = (RotationTweenDurationCurve.keys.Length > 0) ? RotationTweenDurationCurve.Evaluate(rotationDelta) : 2.0f; Rotatable.PlaySFX(true); LeanTween.rotate(gameObject, targetrotation, duration).setEaseInOutBack().setOnComplete(() => { Rotatable.StopSFX(); if (onCompleteCallback != null) { onCompleteCallback.Invoke(); } }); }
[HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite RotatablePump results public static void Postfix(Pump __instance, ref bool __result, Element.State expected_state) { if (__instance is RotatablePump) { Rotatable rotatable = __instance.GetComponent <Rotatable>(); RotatableElementConsumer consumer = __instance.GetComponent <RotatableElementConsumer>(); //Debug.Log("IsPumpable call " + consumer.rotatableCellOffset + ", " + consumer.sampleCellOffset); // Basically a copy of vanilla Pump IsPumpable, but with different initial int num = Grid.PosToCell(__instance.transform.GetPosition() + Rotatable.GetRotatedOffset(consumer.rotatableCellOffset, rotatable.GetOrientation())); for (int i = 0; i < consumer.consumptionRadius; i++) { for (int j = 0; j < consumer.consumptionRadius; j++) { int num2 = num + j + Grid.WidthInCells * i; bool flag = Grid.Element[num2].IsState(expected_state); if (flag) { __result = true; return; } } } __result = false; return; } }
private void Start() { upVectorForRotation = transform.up; child = transform.GetChild(0); directional = GetComponent <Rotatable>(); spriteRenderers = GetComponentsInChildren <SpriteRenderer>(); foreach (SpriteRenderer renderer in spriteRenderers) { //don't add it if it already exists var existingRenderer = renderer.GetComponent <WallmountSpriteBehavior>(); if (existingRenderer == null) { renderer.gameObject.AddComponent <WallmountSpriteBehavior>(); } } var textRenderers = GetComponentsInChildren <Text>(); foreach (var text in textRenderers) { if (GetComponent <WallmountTextBehavior>() == null) { text.gameObject.AddComponent <WallmountTextBehavior>(); } } }
private void Refresh(List <MinionAssignablesProxy> identities, bool rebuild) { Rotatable component = target.GetComponent <Rotatable>(); bool rotated = (UnityEngine.Object)component != (UnityEngine.Object)null && component.IsRotated; defaultsRow.SetRotated(rotated); defaultsRow.SetContent(target.DefaultPermission, OnDefaultPermissionChanged); if (rebuild) { ClearContent(); } foreach (MinionAssignablesProxy identity in identities) { AccessControlSideScreenRow accessControlSideScreenRow; if (rebuild) { accessControlSideScreenRow = rowPool.GetFreeElement(rowGroup, true); identityRowMap.Add(identity, accessControlSideScreenRow); } else { accessControlSideScreenRow = identityRowMap[identity]; } AccessControl.Permission setPermission = target.GetSetPermission(identity); bool isDefault = target.IsDefaultPermission(identity); accessControlSideScreenRow.SetRotated(rotated); accessControlSideScreenRow.SetMinionContent(identity, setPermission, isDefault, OnPermissionChanged, OnPermissionDefault); } RefreshOnline(); ContentContainer.SetActive(target.controlEnabled); }
private void Awake() { registerTile = GetComponent <RegisterTile>(); cnt = GetComponent <CustomNetTransform>(); rotatable = GetComponent <Rotatable>(); health = GetComponent <LivingHealthBehaviour>(); }
public Extents(int cell, CellOffset[] offsets, Orientation orientation) { int num = 0; int num2 = 0; Grid.CellToXY(cell, out num, out num2); int num3 = num; int num4 = num2; for (int i = 0; i < offsets.Length; i++) { CellOffset rotatedCellOffset = Rotatable.GetRotatedCellOffset(offsets[i], orientation); int val = 0; int val2 = 0; int cell2 = Grid.OffsetCell(cell, rotatedCellOffset); Grid.CellToXY(cell2, out val, out val2); num = Math.Min(num, val); num2 = Math.Min(num2, val2); num3 = Math.Max(num3, val); num4 = Math.Max(num4, val2); } x = num; y = num2; width = num3 - num + 1; height = num4 - num2 + 1; }
private void RegisterInGrid(bool register) { Building component = GetComponent <Building>(); if (!((Object)component == (Object)null)) { if (register) { Rotatable component2 = GetComponent <Rotatable>(); Grid.Restriction.Orientation orientation = (!((Object)component2 == (Object)null) && component2.GetOrientation() != 0) ? Grid.Restriction.Orientation.Horizontal : Grid.Restriction.Orientation.Vertical; int[] placementCells = component.PlacementCells; foreach (int cell in placementCells) { Grid.RegisterRestriction(cell, orientation); } } else { int[] placementCells2 = component.PlacementCells; foreach (int cell2 in placementCells2) { Grid.UnregisterRestriction(cell2); } } } }
public virtual void Start() { //for changing direction on click playerDirectional = gameObject.GetComponent <Rotatable>(); playerMove = GetComponent <PlayerMove>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
private void Awake() { scalable = new Scalable(this, (int)depth); selectable = new Selectable(this); rotatable = new Rotatable(this); objectPosition = this.transform.position; }
public override void OnKeyDown(KButtonEvent e) { if (e.TryConsume(Action.RotateBuilding)) { if ((Object)visualizer != (Object)null) { Rotatable component = visualizer.GetComponent <Rotatable>(); if ((Object)component != (Object)null) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Rotate", false)); buildingOrientation = component.Rotate(); if (Grid.IsValidBuildingCell(lastCell)) { Vector3 pos = Grid.CellToPosCCC(lastCell, Grid.SceneLayer.Building); UpdateVis(pos); } if (base.Dragging && lastDragCell != -1) { TryBuild(lastDragCell); } } } } else { base.OnKeyDown(e); } }
protected override void OnSpawn() { base.OnSpawn(); KBatchedAnimController component = GetComponent <KBatchedAnimController>(); Rotatable component2 = GetComponent <Rotatable>(); if ((Object)component != (Object)null && (Object)component2 == (Object)null) { component.Offset = Def.GetVisualizerOffset() + Def.placementPivot; } KBoxCollider2D component3 = GetComponent <KBoxCollider2D>(); if ((Object)component3 != (Object)null) { Vector3 visualizerOffset = Def.GetVisualizerOffset(); component3.offset += new Vector2(visualizerOffset.x, visualizerOffset.y); } if (Def.IsTilePiece) { int cell = Grid.PosToCell(base.transform.GetPosition()); Def.RunOnArea(cell, base.Orientation, delegate(int c) { TileVisualizer.RefreshCell(c, Def.TileLayer, Def.ReplacementLayer); }); } RegisterBlockTileRenderer(); }
public static void SetUpFarmPlotTags(GameObject go) { KPrefabID component = go.GetComponent <KPrefabID>(); component.prefabSpawnFn += delegate(GameObject inst) { Rotatable component2 = inst.GetComponent <Rotatable>(); PlantablePlot component3 = inst.GetComponent <PlantablePlot>(); switch (component2.GetOrientation()) { case Orientation.NumRotations: break; case Orientation.Neutral: case Orientation.FlipH: component3.SetReceptacleDirection(SingleEntityReceptacle.ReceptacleDirection.Top); break; case Orientation.R180: case Orientation.FlipV: component3.SetReceptacleDirection(SingleEntityReceptacle.ReceptacleDirection.Bottom); break; case Orientation.R90: case Orientation.R270: component3.SetReceptacleDirection(SingleEntityReceptacle.ReceptacleDirection.Side); break; } }; }
// invoked when buckledTo changes direction, so we can update our direction private void OnBuckledObjectDirectionChange(OrientationEnum newDir) { if (playerDirectional == null) { playerDirectional = gameObject.GetComponent <Rotatable>(); } playerDirectional.FaceDirection(newDir); }
private void Awake() { registerTile = GetComponent <RegisterTile>(); integrity = GetComponent <Integrity>(); wrenchSecurable = GetComponent <WrenchSecurable>(); spriteHandler = GetComponentInChildren <SpriteHandler>(); directional = GetComponent <Rotatable>(); }
protected virtual void Awake() { registerObject = GetComponent <RegisterObject>(); rotatable = GetComponent <Rotatable>(); drawerPushPull = GetComponent <PushPull>(); container = GetComponent <ObjectContainer>(); drawerSpriteHandler = GetComponentInChildren <SpriteHandler>(); }
private void Awake() { this.localBodyRotation = new Rotatable(Rotatable.Type.LocalBody, this); this.localBodyRotation.localAxis = new Vector3(0, 1, 0); this.localBodyRotation.torque = force; this.obstacle = new Obstacle(Obstacle.Type.Planet, this); }
private void Update() { try { var activeTrackable = sm.GetTrackableBehaviours().FirstOrDefault(); m_interactable = activeTrackable.GetComponentInChildren <Rotatable>(); } catch (NullReferenceException) { return; } if (!touchAnywhere) { //No need to check if already rotating if (!m_rotating) { RaycastHit hit; Ray ray = m_camera.ScreenPointToRay(Input.mousePosition); if (!Physics.Raycast(ray, out hit, 1000, targetLayer)) { return; } } } if (Input.GetMouseButtonDown(0)) { m_rotating = true; m_previousX = Input.mousePosition.x; m_previousY = Input.mousePosition.y; } // get the user touch input if (Input.GetMouseButton(0)) { var touch = Input.mousePosition; var deltaX = -(Input.mousePosition.y - m_previousY) * rotationRate; var deltaY = -(Input.mousePosition.x - m_previousX) * rotationRate; if (!yRotation) { deltaX = 0; } if (!xRotation) { deltaY = 0; } m_interactable.transform.Rotate(deltaX, deltaY, 0, Space.Self); m_previousX = Input.mousePosition.x; m_previousY = Input.mousePosition.y; } if (Input.GetMouseButtonUp(0)) { m_rotating = false; } }
///------------------------------------------------------------------------------------------------- /// \fn private void MainView_MouseClick(object sender, MouseEventArgs e) /// /// \brief Event handler. Called by MainView for mouse click events /// /// \param sender Source of the event. /// \param e Mouse event information. ///------------------------------------------------------------------------------------------------- private void MainView_MouseClick(object sender, MouseEventArgs e) { whichToBeRotated = null; ArrayList array = History.GetInstance().historyArray; for (int i = 0; i <= History.GetInstance().Index; i++) { if (array[i] is BackUpMAction) { continue; } try { ActionParameters_t actionParameters = ((MAction)array[i]).ActionParameters; Shape shape_temp = (Shape)actionParameters; shape_temp.ShowAsNotSelected(); } catch (InvalidCastException) { ; } } Shape shape = null; for (int i = 0; i <= History.GetInstance().Index; i++) { if (array[i] is BackUpMAction) { continue; } try { ActionParameters_t actionParameters = ((MAction)array[i]).ActionParameters; shape = (Shape)actionParameters; Rotatable dummy = (Rotatable)shape; if (shape.IsSelectMe(e.Location)) { History.GetInstance().AddBackUpClone(shape.RetMAction()); shape.ShowAsSelected(); whichToBeRotated = (Rotatable)shape; ShowRotatingWin(); break; } else { shape.ShowAsNotSelected(); } } catch (InvalidCastException) { ; } } // VERY IMPORTANT History.GetInstance().Update(); }
private void EnsureInit() { if (Rotatable != null) { return; } Rotatable = GetComponent <Rotatable>(); }
// ------------------------------------------------------------------------------- protected override void OnStart() { mGameManager = GameManager.Instance; mUniverse = Universe.Instance; mUniverseSphereRotatable = mUniverse.UniverseSphere.GetComponent <Rotatable>(); mUIManager = UIManager.Instance; mUIManager.DragPromptUI.ShowAtScreenPosition(DragPromptScreenPos, DragPromptScreenDir, DragPromptScreenDist); }
private int GetActualCell(CellOffset offset) { Rotatable component = GetComponent <Rotatable>(); if (component != null) { offset = component.GetRotatedCellOffset(offset); } return(Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), offset)); }
protected override void Awake() { base.Awake(); AddStatus(this); playerScript = GetComponent <PlayerScript>(); uprightSprites = GetComponent <UprightSprites>(); playerDirectional = GetComponent <Rotatable>(); //playerDirectional.ChangeDirectionWithMatrix = false; uprightSprites.spriteMatrixRotationBehavior = SpriteMatrixRotationBehavior.RemainUpright; }
private void Awake() { rotatable = GetComponent <Rotatable>(); scalable = GetComponent <Scalable>(); initialRotation = transform.localRotation; initialScale = transform.localScale; rotatable.enabled = false; scalable.enabled = false; }
/// <summary> /// Applied to Rotatable to rotate light previews if a visualizer is rotated. /// </summary> private static void OrientVisualizer_Postfix(Rotatable __instance) { var preview = __instance.gameObject.GetComponentSafe <LightShapePreview>(); // Force regeneration on next Update() if (preview != null) { Traverse.Create(preview).SetField("previousCell", -1); } }
private static void OrientVisualizer_Postfix(Rotatable __instance) { var preview = __instance.gameObject.GetComponentSafe <LightShapePreview>(); // Force regeneration on next Update() if (preview != null) { PREVIOUS_CELL.Set(preview, -1); } }
private void Awake() { directional = GetComponent <Rotatable>(); objectBehaviour = GetComponent <ObjectBehaviour>(); registerTile = GetComponent <RegisterTile>(); accessRestrictions = GetComponent <AccessRestrictions>(); clearanceCheckable = GetComponent <ClearanceCheckable>(); electricalNodeControl = GetComponent <ElectricalNodeControl>(); spriteHandler = GetComponentInChildren <SpriteHandler>(); }
public HandleVector <int> .Handle Add(GameObject go) { BuildingDef def = go.GetComponent <Building>().Def; int cell = Grid.PosToCell(go.transform.GetPosition()); Data data = default(Data); data.cell = cell; data.width = def.WidthInCells; data.height = def.HeightInCells; data.buildRule = def.BuildLocationRule; data.solid = true; data.go = go; Data data2 = data; HandleVector <int> .Handle h = Add(go, data2); if (def.ContinuouslyCheckFoundation) { Action <object> event_callback = delegate { OnSolidChanged(h); }; Rotatable component = data2.go.GetComponent <Rotatable>(); Orientation orientation = ((UnityEngine.Object)component != (UnityEngine.Object)null) ? component.GetOrientation() : Orientation.Neutral; int num = -(def.WidthInCells - 1) / 2; int num2 = def.WidthInCells / 2; List <int> list = new List <int>(); for (int i = num; i <= num2; i++) { CellOffset offset = new CellOffset(i, -1); if (def.BuildLocationRule == BuildLocationRule.OnWall) { offset = new CellOffset(i - 1, 0); } else if (def.BuildLocationRule == BuildLocationRule.OnCeiling || def.BuildLocationRule == BuildLocationRule.InCorner) { offset = new CellOffset(i, def.HeightInCells); } CellOffset rotatedCellOffset = Rotatable.GetRotatedCellOffset(offset, orientation); int item = Grid.OffsetCell(cell, rotatedCellOffset); list.Add(item); } Vector2I vector2I = Grid.CellToXY(list[0]); Vector2I vector2I2 = Grid.CellToXY(list[list.Count - 1]); float xmin = (float)((vector2I.x <= vector2I2.x) ? vector2I.x : vector2I2.x); float xmax = (float)((vector2I.x >= vector2I2.x) ? vector2I.x : vector2I2.x); float ymin = (float)((vector2I.y <= vector2I2.y) ? vector2I.y : vector2I2.y); float ymax = (float)((vector2I.y >= vector2I2.y) ? vector2I.y : vector2I2.y); Rect rect = Rect.MinMaxRect(xmin, ymin, xmax, ymax); data2.solidPartitionerEntry = GameScenePartitioner.Instance.Add("RequiresFoundation.Add", go, (int)rect.x, (int)rect.y, (int)rect.width + 1, (int)rect.height + 1, GameScenePartitioner.Instance.solidChangedLayer, event_callback); data2.buildingPartitionerEntry = GameScenePartitioner.Instance.Add("RequiresFoundation.Add", go, (int)rect.x, (int)rect.y, (int)rect.width + 1, (int)rect.height + 1, GameScenePartitioner.Instance.objectLayers[1], event_callback); SetData(h, data2); OnSolidChanged(h); } return(h); }