private Vector3Int GetDirection(PlayerAction action, MatrixInfo matrixInfo, bool isReplay) { ProcessAction(action); if (diagonalMovement) { return(GetMoveDirection(matrixInfo, isReplay)); } if (moveActionList.Count > 0) { return(GetMoveDirection(moveActionList[moveActionList.Count - 1])); } return(Vector3Int.zero); }
/// <summary> /// Server only: /// Picks best matching matrix at provided coords and releases reagents to that tile. /// <inheritdoc cref="MetaDataLayer.ReagentReact"/> /// </summary> public static void ReagentReact(ReagentMix reagents, Vector3Int worldPos, MatrixInfo matrixInfo = null) { if (CustomNetworkManager.IsServer == false) { return; } if (matrixInfo is null) { matrixInfo = AtPoint(worldPos, true); } Vector3Int localPos = WorldToLocalInt(worldPos, matrixInfo); matrixInfo.MetaDataLayer.ReagentReact(reagents, worldPos, localPos); }
/// Convert world position to local matrix coordinates. Keeps offsets in mind (+ rotation and pivot if MatrixMove is present) public static Vector3 WorldToLocal(Vector3 worldPos, MatrixInfo matrix) { //Invalid matrix info provided if (matrix.Equals(MatrixInfo.Invalid) || worldPos == TransformState.HiddenPos) { return(TransformState.HiddenPos); } if (!matrix.MatrixMove) { return(worldPos - matrix.Offset); } return((matrix.MatrixMove.ClientState.RotationOffset.QuaternionInverted * (worldPos - matrix.Offset - matrix.MatrixMove.Pivot)) + matrix.MatrixMove.Pivot); }
public void ServerPerformInteraction(PositionalHandApply interaction) { Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrixinfo = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrixinfo); var matrix = interaction.Performer.GetComponentInParent <Matrix>(); string toShow = ""; foreach (var pipeNode in matrix.GetPipeConnections(localPosInt)) { toShow += pipeNode.ToAnalyserExamineString() + "\n"; } Chat.AddExamineMsgFromServer(interaction.Performer, toShow); }
private void SetupNeighbors(MetaDataNode node) { Vector3Int[] neighbors = MetaUtils.GetNeighbors(node.Position); for (int i = 0; i < neighbors.Length; i++) { if (metaTileMap.IsSpaceAt(neighbors[i])) { if (node.IsRoom) { externalNodes.Add(node); } Vector3 worldPosition = transform.TransformPoint(neighbors[i] + Vector3Int.one); worldPosition.z = 0; if (!MatrixManager.IsSpaceAt(worldPosition.RoundToInt())) { MatrixInfo matrixInfo = MatrixManager.AtPoint(worldPosition.RoundToInt()); if (matrixInfo.MetaTileMap != metaTileMap) { Vector3Int localPosition = MatrixManager.WorldToLocalInt(worldPosition, matrixInfo); if (matrixInfo.MetaTileMap.IsAtmosPassableAt(localPosition)) { node.AddNeighbor(matrixInfo.MetaDataLayer.Get(localPosition)); } continue; } } } if (metaTileMap.IsAtmosPassableAt(neighbors[i])) { MetaDataNode neighborNode = metaDataLayer.Get(neighbors[i]); if (metaTileMap.IsSpaceAt(neighbors[i])) { neighborNode.Type = NodeType.Space; } node.AddNeighbor(neighborNode); } } }
private void InitServerState() { if (flyingDirection == Vector2.zero) { Logger.LogWarning($"{gameObject.name} move direction unclear", Category.Matrix); serverState.Direction = Vector2.up; } else { serverState.Direction = Vector2Int.RoundToInt(flyingDirection); } Vector3Int initialPositionInt = Vector3Int.RoundToInt(new Vector3(transform.position.x, transform.position.y, 0)); initialPosition = initialPositionInt; initialOrientation = Orientation.From(serverState.Direction); var child = transform.GetChild(0); MatrixInfo = MatrixManager.Get(child.gameObject); var childPosition = Vector3Int.CeilToInt(new Vector3(child.transform.position.x, child.transform.position.y, 0)); pivot = initialPosition - childPosition; Logger.LogTraceFormat("{0}: pivot={1} initialPos={2}, initialOrientation={3}", Category.Matrix, gameObject.name, pivot, initialPositionInt, initialOrientation); serverState.Speed = 1f; serverState.Position = initialPosition; serverState.Orientation = Orientation.Up; serverTargetState = serverState; clientState = serverState; clientTargetState = serverState; if (SensorPositions == null) { CollisionSensor[] sensors = GetComponentsInChildren <CollisionSensor>(); if (sensors.Length == 0) { SensorPositions = new Vector3Int[0]; return; } SensorPositions = sensors.Select(sensor => Vector3Int.RoundToInt(sensor.transform.localPosition)).ToArray(); Logger.Log($"Initialized sensors at {string.Join( ",", SensorPositions )}," + $" direction is {State.Direction}", Category.Matrix); } }
public void ServerPerformInteraction(PositionalHandApply interaction) { //wirecutters can be used to cut this cable Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrix = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrix); if (matrix.Matrix == null || !matrix.Matrix.IsClearUnderfloorConstruction(localPosInt, true)) { return; } ToolUtils.ServerPlayToolSound(interaction); Spawn.ServerPrefab(machineConnectorPrefab, gameObject.AssumedWorldPosServer()); Despawn.ServerSingle(gameObject); }
/// Finds first matrix that is not empty at given world pos public static MatrixInfo AtPoint(Vector3Int worldPos, bool isServer) { for (var i = Instance.ActiveMatrices.Count - 1; i >= 0; i--) { MatrixInfo mat = Instance.ActiveMatrices[i]; if (mat.Matrix == Instance.spaceMatrix) { continue; } if (!mat.Matrix.IsEmptyAt(WorldToLocalInt(worldPos, mat), isServer)) { return(mat); } } return(Instance.ActiveMatrices[Instance.spaceMatrix.Id]); }
public void ServerPerformInteraction(PositionalHandApply interaction) { Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrixinfo = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrixinfo); var matrix = interaction.Performer.GetComponentInParent <Matrix>(); var MetaDataNode = matrix.GetElectricalConnections(localPosInt); Logger.Log("MetaDataNodeCount " + MetaDataNode.Count, Category.Matrix); foreach (var D in MetaDataNode) { D.ShowDetails(); } MetaDataNode.Clear(); ElectricalPool.PooledFPCList.Add(MetaDataNode); }
/// Convert world position to local matrix coordinates. Keeps offsets in mind (+ rotation and pivot if MatrixMove is present) public static Vector3 WorldToLocal(Vector3 worldPos, MatrixInfo matrix) { //Invalid matrix info provided if (matrix.Equals(MatrixInfo.Invalid)) { return(TransformState.HiddenPos); } if (!matrix.MatrixMove) { return(worldPos - matrix.Offset); } Vector3 rotatedClean = worldPos - matrix.Offset - matrix.MatrixMove.Pivot; Vector3 unrotatedPos = matrix.MatrixMove.ClientState.Orientation.EulerInverted * rotatedClean; return(unrotatedPos + matrix.MatrixMove.Pivot); }
private void updateMatrixInfo() { matrix = new MatrixInfo(null, null, null, null, null, "NotConnected"); try { var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"); foreach (var device in searcher.Get()) { if (device.GetPropertyValue("DeviceID").ToString().Contains(@"VID_0203")) { if (device.GetPropertyValue("DeviceID").ToString().Contains(@"PID_0003")) { matrix = new MatrixInfo( device.GetPropertyValue("Name").ToString(), "Matrix DFU", "不可用", null, "不可用", "DFU"); break; } else if (device.GetPropertyValue("PNPClass").ToString().Equals("MEDIA")) { matrix = new MatrixInfo( device.GetPropertyValue("Name").ToString(), "Matrix", "未知", null, "未知", "Connected"); requestMatrixInfo(); break; } } } this.Dispatcher.Invoke(() => { UpdateUserControl(); }); } catch (Exception e) { } }
public override void OnEventStart() { stationMatrix = MatrixManager.MainStationMatrix; if (AnnounceEvent) { var text = "Proximity Alert:\nInbound Meteors have been detected.\nBrace for impact!"; CentComm.MakeAnnouncement(CentComm.CentCommAnnounceTemplate, text, CentComm.UpdateSound.alert); } if (FakeEvent) { return; } base.OnEventStart(); }
public bool CanPass(Vector3Int localPos, Vector3Int direction, Matrix currentMatrix) { MatrixInfo matrixInfo = MatrixManager.Instance.Get(currentMatrix); if (matrixInfo.MatrixMove) { //Converting local direction to world direction direction = Vector3Int.RoundToInt(matrixInfo.MatrixMove.ClientState.Orientation.Euler * direction); } Vector3Int position = MatrixManager.LocalToWorldInt(localPos, MatrixManager.Instance.Get(currentMatrix)); if (!MatrixManager.Instance.IsPassableAt(position, position + direction)) { return(false); } return(true); }
/// <inheritdoc cref="WorldToLocal(Vector3, Matrix)"/> public static Vector3 WorldToLocal(Vector3 worldPos, MatrixInfo matrix) { // Invalid matrix info provided if (matrix is null || matrix.Equals(MatrixInfo.Invalid) || worldPos == TransformState.HiddenPos) { return(TransformState.HiddenPos); } if (matrix.MatrixMove == null) { return(worldPos - matrix.Offset); } var state = matrix.MatrixMove.ClientState; return((state.FacingOffsetFromInitial(matrix.MatrixMove).QuaternionInverted * (worldPos - matrix.MatrixMove.Pivot - matrix.GetOffset(state))) + matrix.MatrixMove.Pivot); }
/// Convert world position to local matrix coordinates. Keeps offsets in mind (+ rotation and pivot if MatrixMove is present) public static Vector3 WorldToLocal(Vector3 worldPos, MatrixInfo matrix) { //Invalid matrix info provided if (matrix.Equals(MatrixInfo.Invalid) || worldPos == TransformState.HiddenPos) { return(TransformState.HiddenPos); } // return matrix.MetaTileMap.WorldToLocal( worldPos ); if (!matrix.MatrixMove) { return(worldPos - matrix.Offset); } return((matrix.MatrixMove.FacingOffsetFromInitial.QuaternionInverted * (worldPos - matrix.Offset - matrix.MatrixMove.Pivot)) + matrix.MatrixMove.Pivot); }
public void PrintElectricalThings(PositionalHandApply interaction) { Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrixinfo = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrixinfo); var matrix = interaction.Performer.GetComponentInParent <Matrix>(); var MetaDataNode = matrix.GetElectricalConnections(localPosInt); string ToReturn = "The Multitool Display lights up with \n" + "Number of electrical objects present : " + MetaDataNode.Count + "\n"; foreach (var D in MetaDataNode) { ToReturn = ToReturn + D.ShowInGameDetails() + "\n"; } MetaDataNode.Clear(); ElectricalPool.PooledFPCList.Add(MetaDataNode); Chat.AddExamineMsgFromServer(interaction.Performer, ToReturn); }
/// <summary> /// Play Footstep at given world position. /// </summary> public static void FootstepAtPosition(Vector3 worldPos) { MatrixInfo matrix = MatrixManager.AtPoint(worldPos.NormalizeToInt(), false); var locPos = matrix.ObjectParent.transform.InverseTransformPoint(worldPos).RoundToInt(); var tile = matrix.MetaTileMap.GetTile(locPos) as BasicTile; if (tile != null) { if (Step) { PlayNetworkedAtPos(Instance.FootSteps[tile.WalkingSoundCategory][RANDOM.Next(Instance.FootSteps[tile.WalkingSoundCategory].Count)], worldPos, (float)Instance.GetRandomNumber(0.7d, 1.2d), Global: false, polyphonic: true); } Step = !Step; } }
public override void OnEventStart() { stationMatrix = MatrixManager.MainStationMatrix; if (AnnounceEvent) { var text = "What the f**k is going on?!"; CentComm.MakeAnnouncement(CentComm.CentCommAnnounceTemplate, text, CentComm.UpdateSound.alert); } if (FakeEvent) { return; } base.OnEventStart(); }
// public Matrix4x4 matrix; //has terrible inspector and Defaults to invalid Option // public Color Colour; // Defaults to bad option public bool Initiate(TestRunSO TestRunSO) { MatrixInfo _Magix = UsefulFunctions.GetCorrectMatrix(MatrixName, WorldPosition); if (LayerTile == null) { _Magix.Matrix.MetaTileMap.RemoveTileWithlayer(WorldPosition.ToLocal(_Magix).RoundToInt(), tileLayerRemove); } else { _Magix.Matrix.MetaTileMap.SetTile(WorldPosition.ToLocal(_Magix).RoundToInt(), LayerTile, Matrix4x4.identity, Color.white); } return(true); }
public bool Initiate(TestRunSO TestRunSO) { MatrixInfo _Magix = UsefulFunctions.GetCorrectMatrix(MatrixName, WorldPosition); var _MetaDataNode = _Magix.MetaDataLayer.Get(WorldPosition.ToLocal(_Magix).RoundToInt()); if (Parameters.SatisfiesConditions(_MetaDataNode.GetType(), _MetaDataNode, out var ReportString)) { return(true); } else { TestRunSO.Report.AppendLine(CustomFailedText); TestRunSO.Report.AppendLine($"The Meta data node no did not meet the requirements of the parameters"); TestRunSO.Report.AppendLine(ReportString); return(false); } return(true); }
void ServerInit(MatrixInfo matrixInfo) { SpawnResult traySpawn = Spawn.ServerPrefab(trayPrefab, DrawerWorldPosition); if (!traySpawn.Successful) { throw new MissingReferenceException($"Failed to spawn tray! Is {name} prefab missing reference to tray prefab?"); } tray = traySpawn.GameObject; traySpriteHandler = tray.GetComponentInChildren<SpriteHandler>(); trayTransform = tray.GetComponent<CustomNetTransform>(); trayBehaviour = tray.GetComponent<ObjectBehaviour>(); trayBehaviour.parentContainer = drawerPushPull; trayBehaviour.VisibleState = false; // These two will sync drawer state/orientation and render appropriate sprite drawerState = DrawerState.Shut; drawerOrientation = directional.CurrentDirection; }
public void SetPosition(Vector3 worldPos) { ClearQueueServer(); Vector3Int roundedPos = Vector3Int.RoundToInt((Vector2)worldPos); //cutting off z-axis MatrixInfo newMatrix = MatrixManager.AtPoint(roundedPos); //Note the client queue reset var newState = new PlayerState { MoveNumber = 0, MatrixId = newMatrix.Id, WorldPosition = roundedPos, ResetClientQueue = true }; serverState = newState; serverTargetState = newState; SyncMatrix(); NotifyPlayers(); }
public override bool Equals(object obj) { MatrixInfo mi = (MatrixInfo)obj; if (mi == null || mi.TRS == null) { return(false); } for (int i = 0; i < 9; i++) { if (TRS[i] != mi.TRS[i]) { return(false); } } return(true); }
public bool Push(Vector2Int direction, float speed = Single.NaN, bool followMode = false) { //player speed change not implemented yet if (direction == Vector2Int.zero) { return(false); } Vector3Int origin = Vector3Int.RoundToInt((Vector2)serverState.WorldPosition); Vector3Int pushGoal = origin + Vector3Int.RoundToInt((Vector2)direction); if (!MatrixManager.IsPassableAt(origin, pushGoal, !followMode)) { return(false); } if (followMode) { SendMessage("FaceDirection", RotationOffset.From(direction), SendMessageOptions.DontRequireReceiver); } Logger.LogTraceFormat("Server push to {0}", Category.PushPull, pushGoal); ClearQueueServer(); MatrixInfo newMatrix = MatrixManager.AtPoint(pushGoal); //Note the client queue reset var newState = new PlayerState { MoveNumber = 0, Impulse = direction, MatrixId = newMatrix.Id, WorldPosition = pushGoal, ImportantFlightUpdate = true, ResetClientQueue = true, IsFollowUpdate = followMode }; serverLastDirection = direction; serverState = newState; SyncMatrix(); OnStartMove().Invoke(origin, pushGoal); NotifyPlayers(); return(true); }
public override void OnEventStart() { stationMatrix = MatrixManager.MainStationMatrix; if (AnnounceEvent) { var text = "Proximity Alert:\nInbound Meteors have been detected.\nBrace for impact!"; CentComm.MakeAnnouncement(ChatTemplates.CentcomAnnounce, text, CentComm.UpdateSound.NoSound); _ = SoundManager.PlayNetworked(SingletonSOSounds.Instance.MeteorsAnnouncement); } if (FakeEvent) { return; } base.OnEventStart(); }
public void ServerPerformInteraction(PositionalHandApply interaction) { Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrixinfo = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrixinfo); var matrix = interaction.Performer.GetComponentInParent <Matrix>(); var MetaDataNode = matrix.GetElectricalConnections(localPosInt); StringBuilder SB = new StringBuilder(); SB.Append("MetaDataNodeCount " + MetaDataNode.List.Count); SB.Append("\n"); foreach (var D in MetaDataNode.List) { SB.Append(D.ShowDetails()); } MetaDataNode.Pool(); Chat.AddExamineMsgFromServer(interaction.Performer, SB.ToString()); Logger.Log(SB.ToString()); }
public void ServerPerformInteraction(PositionalHandApply interaction) { //wirecutters can be used to cut this cable Vector3Int worldPosInt = interaction.WorldPositionTarget.To2Int().To3Int(); MatrixInfo matrix = MatrixManager.AtPoint(worldPosInt, true); var localPosInt = MatrixManager.WorldToLocalInt(worldPosInt, matrix); if (matrix.Matrix != null) { if (!matrix.Matrix.IsClearUnderfloorConstruction(localPosInt, true)) { return; } } else { return; } wireConnect.DestroyThisPlease(); }
private void InitCollisions(MatrixInfo matrixInfo) { if (!Application.isPlaying || !CustomNetworkManager.Instance._isServer) { return; } if (matrixInfo.MatrixMove != null) { matrixInfo.MatrixMove.MatrixMoveEvents.OnStartMovementServer.AddListener(() => { if (!movingMatrices.Contains(matrixInfo)) { movingMatrices.Add(matrixInfo); } }); matrixInfo.MatrixMove.MatrixMoveEvents.OnStopMovementServer.AddListener(() => { if (movingMatrices.Contains(matrixInfo)) { var participatingIntersections = trackedIntersections.FindAll(intersection => intersection.Matrix1 == matrixInfo); matrixInfo.MatrixMove.MatrixMoveEvents.OnFullStopClient.AddListener(CollideBeforeStop(matrixInfo, participatingIntersections)); movingMatrices.Remove(matrixInfo); trackedIntersections.RemoveAll(intersection => intersection.Matrix1 == matrixInfo); } }); } UnityAction CollideBeforeStop(MatrixInfo matrix, List <MatrixIntersection> intersections) { return(() => { foreach (var intersection in intersections) { CheckTileCollisions(intersection); } intersections.Clear(); }); } }
private void AddBuildLegs(MatrixInfo matrix, string[] matrixNameParts, IGrouping <dynamic, PlatformInfo> platformGrouping) { IEnumerable <IEnumerable <PlatformInfo> > subgraphs = platformGrouping.GetCompleteSubgraphs(GetPlatformDependencies); foreach (IEnumerable <PlatformInfo> subgraph in subgraphs) { string[] dockerfilePaths = subgraph .Select(platform => platform.Model.Dockerfile) .ToArray(); LegInfo leg = new LegInfo() { Name = FormatLegName(dockerfilePaths, matrixNameParts) }; matrix.Legs.Add(leg); string pathArgs = dockerfilePaths .Select(path => $"--path {path}") .Aggregate((working, next) => $"{working} {next}"); leg.Variables.Add(("imageBuilderPaths", pathArgs)); } }
private void InitServerState() { Vector3Int worldPos = Vector3Int.RoundToInt((Vector2)transform.position); //cutting off Z-axis & rounding MatrixInfo matrixAtPoint = MatrixManager.AtPoint(worldPos); PlayerState state = new PlayerState { MoveNumber = 0, MatrixId = matrixAtPoint.Id, WorldPosition = worldPos }; // Logger.Log( $"{PlayerList.Instance.Get( gameObject ).Name}: InitServerState for {worldPos} found matrix {matrixAtPoint} resulting in\n{state}" ); serverState = state; serverTargetState = state; //Subbing to new matrix rotations if (matrixAtPoint.MatrixMove != null) { matrixAtPoint.MatrixMove.OnRotate.AddListener(OnRotation); } }