public void ServerPerformInteraction(HandApply interaction) { if (interaction.HandObject == null) { return; } if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wrench)) { switch (orientation) { case OrientationEnum.Right_By270: directional.FaceDirection(OrientationEnum.Up_By0); break; case OrientationEnum.Up_By0: directional.FaceDirection(OrientationEnum.Left_By90); break; case OrientationEnum.Left_By90: directional.FaceDirection(OrientationEnum.Down_By180); break; case OrientationEnum.Down_By180: directional.FaceDirection(OrientationEnum.Right_By270); break; } } }
public void ServerBuckle(BuckleInteract buckleInteract, Action unbuckledAction = null) { var netid = buckleInteract.gameObject.NetId(); if (netid == NetId.Invalid) { Logger.LogError("attempted to buckle to object " + buckleInteract.gameObject + " which has no NetworkIdentity. Buckle" + " can only be used on objects with a Net ID. Ensure this object has one.", Category.Movement); return; } if (buckleInteract.forceLayingDown) { registerPlayer.ServerLayDown(); } else { registerPlayer.ServerStandUp(); } SyncBuckledObjectNetId(0, netid); // can't push/pull when buckled in, break if we are pulled / pulling // sinform the puller if (PlayerScript.pushPull.PulledBy != null) { PlayerScript.pushPull.PulledBy.ServerStopPulling(); } PlayerScript.pushPull.StopFollowing(); PlayerScript.pushPull.ServerStopPulling(); PlayerScript.pushPull.ServerSetPushable(false); onUnbuckled = unbuckledAction; // sync position to ensure they buckle to the correct spot PlayerScript.PlayerSync.SetPosition(buckleInteract.gameObject.TileWorldPosition().To3Int()); // set direction if toObject has a direction var directionalObject = buckleInteract.GetComponent <Rotatable>(); if (directionalObject != null) { playerDirectional.FaceDirection(directionalObject.CurrentDirection); } else { playerDirectional.FaceDirection(playerDirectional.CurrentDirection); } }
public override void OnInspectorGUI() { // Render default inspector for the component. base.OnInspectorGUI(); // Don't show connection elements; not relevant to runtime or prefab edit mode. if (Application.isPlaying || PrefabStageUtility.GetCurrentPrefabStage() != null) { return; } GUILayout.Label("Set Direction"); GUILayout.BeginHorizontal(); if (GUILayout.Button("Up")) { thisDevice.FaceDirection(OrientationEnum.Up_By0); Save(); } if (GUILayout.Button("Right")) { thisDevice.FaceDirection(OrientationEnum.Right_By270); Save(); } if (GUILayout.Button("Down")) { thisDevice.FaceDirection(OrientationEnum.Down_By180); Save(); } if (GUILayout.Button("Left")) { thisDevice.FaceDirection(OrientationEnum.Left_By90); Save(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Refresh")) { thisDevice.Refresh(); Save(); } }
private void DeconstructPipe(TileApply interaction) { DisposalPipe pipeTile = interaction.BasicTile as DisposalPipe; // Despawn pipe tile var matrix = MatrixManager.AtPoint(interaction.WorldPositionTarget.RoundToInt(), true).Matrix; MetaDataNode metaDataNode = matrix.GetMetaDataNode(interaction.TargetCellPos, false); DisposalPipeNode disPipeNode = null; for (var i = 0; i < metaDataNode.DisposalPipeData.Count; i++) { if (metaDataNode.DisposalPipeData[i].DisposalPipeTile == pipeTile) { disPipeNode = metaDataNode.DisposalPipeData[i]; } } if (disPipeNode == null) { Logger.LogError($"Impossible to deconstruct the disposal pipe at {interaction.TargetCellPos} in {matrix.gameObject.scene.name} - {matrix.name}. Disposal pipe node wasn't found", Category.Pipes); return; } matrix.TileChangeManager.MetaTileMap.RemoveTileWithlayer(disPipeNode.NodeLocation, LayerType.Underfloor); // Spawn pipe GameObject if (interaction.BasicTile.SpawnOnDeconstruct == null) { return; } var spawn = Spawn.ServerPrefab(interaction.BasicTile.SpawnOnDeconstruct, interaction.WorldPositionTarget); if (spawn.Successful == false) { return; } if (spawn.GameObject.TryGetComponent <Rotatable>(out var Rotatable)) { Rotatable.FaceDirection(pipeTile.DisposalPipeObjectOrientation); } if (spawn.GameObject.TryGetComponent <ObjectBehaviour>(out var behaviour)) { behaviour.ServerSetPushable(false); } }