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, "StealthOff"); //very weird, sometimes does the sound other times not. TransportPlayers(player); } foreach (var objects in Matrix.Get <ObjectBehaviour>(registerTile.LocalPositionServer + Vector3Int.up, ObjectType.Object, true)) { TransportObjectsItems(objects); } foreach (var items in Matrix.Get <ObjectBehaviour>(registerTile.LocalPositionServer + Vector3Int.up, ObjectType.Item, true)) { TransportObjectsItems(items); } }
void ConnectToWorld() { var randomWorld = SubSceneManager.RequestRandomAwayWorldLink(this); if (randomWorld == null) { Logger.Log("StationGateway failed to connect to an away world"); SetOffline(); return; } selectedWorld = randomWorld; Message = "Teleporting to: " + selectedWorld.WorldName; if (selectedWorld.spawnMobsOnConnection) { selectedWorld.SetUp(this); } if (HasPower) { SetOnline(); ServerChangeState(true); var text = "Alert! New Gateway connection formed.\n\n Connection established to: " + selectedWorld.WorldName; CentComm.MakeAnnouncement(CentComm.CentCommAnnounceTemplate, text, CentComm.UpdateSound.alert); } }