public virtual void DetectPlayer() { //detect players positioned on the portal bit of the gateway var playersFound = Matrix.Get <ObjectBehaviour>(registerTile.LocalPositionServer + Vector3Int.up, ObjectType.Player, true); if (!SpawnedMobs && selectedWorld != null && playersFound.Count() > 0) { selectedWorld.SetUp(this); Logger.Log("Gateway Spawned Mobs"); if (selectedWorld.GetComponent <MobSpawnControlScript>() != null) { selectedWorld.GetComponent <MobSpawnControlScript>().SpawnMobs(); } SpawnedMobs = true; } foreach (ObjectBehaviour player in playersFound) { var coord = new Vector2(Position.x, Position.y); Chat.AddLocalMsgToChat(Message, coord, gameObject); SoundManager.PlayNetworkedForPlayer(player.gameObject, SingletonSOSounds.Instance.StealthOff); //very weird, sometimes does the sound other times not. TransportUtility.TransportObjectAndPulled(player, TeleportTargetCoord); } foreach (var item in Matrix.Get <ObjectBehaviour>(registerTile.LocalPositionServer + Vector3Int.up, ObjectType.Object, true) .Concat(Matrix.Get <ObjectBehaviour>(registerTile.LocalPositionServer + Vector3Int.up, ObjectType.Item, true))) { TransportUtility.TransportObjectAndPulled(item, TeleportTargetCoord); } }
public void ServerDetectObjectsOnTile() { if (connectedPad == null) { return; } if (!doingAnimation && !passiveDetect) { ServerSync(true); StartCoroutine(ServerAnimation()); } travelCoord = connectedPad.registerTile.WorldPositionServer; switch (padDirection) { case PadDirection.OnTop: break; case PadDirection.Up: travelCoord += Vector3.up; break; case PadDirection.Down: travelCoord += Vector3.down; break; case PadDirection.Left: travelCoord += Vector3.left; break; case PadDirection.Right: travelCoord += Vector3.right; break; } if (passiveDetect && padDirection == PadDirection.OnTop) { travelCoord += Vector3.up; } var message = connectedPad.messageOnTravelToThis; var registerTileLocation = registerTile.LocalPositionServer; var somethingTeleported = false; //Use the transport object code from StationGateway //detect players positioned on the portal bit of the gateway foreach (ObjectBehaviour player in Matrix.Get <ObjectBehaviour>(registerTileLocation, ObjectType.Player, true)) { Chat.AddExamineMsgFromServer(player.gameObject, message); _ = SoundManager.PlayNetworkedForPlayer(player.gameObject, SingletonSOSounds.Instance.StealthOff); //very weird, sometimes does the sound other times not. TransportUtility.TransportObjectAndPulled(player, travelCoord); somethingTeleported = true; } //detect objects and items foreach (var item in Matrix.Get <ObjectBehaviour>(registerTileLocation, ObjectType.Object, true) .Concat(Matrix.Get <ObjectBehaviour>(registerTileLocation, ObjectType.Item, true))) { if (item.gameObject.TryGetComponent(out IQuantumReaction reaction)) { reaction.OnTeleportStart(); TransportUtility.TransportObjectAndPulled(item, travelCoord); reaction.OnTeleportEnd(); } else { TransportUtility.TransportObjectAndPulled(item, travelCoord); } somethingTeleported = true; } if (!doingAnimation && passiveDetect && somethingTeleported) { ServerSync(true); StartCoroutine(ServerAnimation()); } }