public override void Update(bool eu) { base.Update(eu); Player ply = Ply; _lastAlpha = _alpha; // Find the player's shortcut vessel ShortcutHandler.ShortCutVessel plyVessel = null; foreach (ShortcutHandler.ShortCutVessel vessel in room.game.shortcuts.transportVessels) { if (vessel.creature == ply && vessel.room == room.abstractRoom) { plyVessel = vessel; break; } } if (plyVessel != null) { // Find the player's position in a shortcut Vector2 scPos = room.MiddleOfTile(plyVessel.pos); Vector2 lastScPos = room.MiddleOfTile(plyVessel.lastPos); //int update = (int)_RainWorldGame_updateShortCut.GetValue(room.game); //pos = Vector2.Lerp(lastScPos, scPos, (update + 1f) / 3f); lastPos = scPos; pos = scPos; _alpha = Mathf.Min(_alpha + 0.2f, 1f); } else { // Fade out when not in use _alpha = Mathf.Max(_alpha - 0.2f, 0f); } }
public override void Update(bool eu) { base.Update(eu); lastScreenblockAlpha = screenblockAlpha; hideAllSprites = false; if (room.game.IsArenaSession) { if (!room.game.GetArenaGameSession.playersSpawned) { hideAllSprites = true; } } Player ply = null; if (room.game.Players.Count > 0) { ply = room.game.Players[0].realizedCreature as Player; } // Map edges to display quads if (state != MappingState.Done) { UpdateMapper(300); } // Do not try to access shortcuts when the room is not ready for AI if (!room.readyForAI) { screenblockAlpha = 1f; return; } // Find the player's shortcut vessel ShortcutHandler.ShortCutVessel plyVessel = null; foreach (ShortcutHandler.ShortCutVessel vessel in room.game.shortcuts.transportVessels) { if (vessel.creature == ply) { plyVessel = vessel; break; } } if (ply == null || ply.room != room || (plyVessel != null && plyVessel.entranceNode != -1)) { screenblockAlpha = Mathf.Clamp01(screenblockAlpha + 0.1f); } else { screenblockAlpha = Mathf.Clamp01(screenblockAlpha - 0.1f); } if (ply != null) { // Search for the closest shortcut entrance and display a sprite at the end location // Disabled in classic mode if (!LineOfSightMod.classic) { IntVector2 scPos = new IntVector2(); bool found = false; if (ply.room != null && !ply.inShortcut) { for (int chunk = 0; chunk < ply.bodyChunks.Length; chunk++) { IntVector2 chunkPos = room.GetTilePosition(ply.bodyChunks[chunk].pos); for (int i = 0; i < _peekSearchOffsets.Length; i++) { IntVector2 testPos = chunkPos + _peekSearchOffsets[i]; if (testPos.x < 0 || testPos.y < 0 || testPos.x >= room.TileWidth || testPos.y >= room.TileHeight) { continue; } if (room.GetTile(testPos).Terrain == Room.Tile.TerrainType.ShortcutEntrance) { int ind = Array.IndexOf(room.shortcutsIndex, testPos); if (ind > -1 && ind < (room.shortcuts?.Length ?? 0)) { if (room.shortcuts[ind].shortCutType == ShortcutData.Type.Normal) { found = true; scPos = testPos; break; } } } } } } ShortcutData sc = default(ShortcutData); int scInd = Array.IndexOf(room.shortcutsIndex, scPos); if (scInd > -1 && scInd < (room.shortcuts?.Length ?? 0)) { sc = room.shortcuts[scInd]; } else { found = false; } if (found) { IntVector2 dest = sc.DestTile; Vector2 newPeekPos = ply.room.MiddleOfTile(dest); if (_peekPos != newPeekPos) { _peekAlpha = 0f; _peekPos = newPeekPos; _peekAngle = 0f; for (int i = 0; i < 4; i++) { if (!ply.room.GetTile(dest + Custom.fourDirections[i]).Solid) { _peekAngle = 180f - 90f * i; break; } } } } _lastPeekAlpha = _peekAlpha; _peekAlpha = Custom.LerpAndTick(_peekAlpha, found ? Mathf.Sin(room.game.clock / 40f * Mathf.PI * 4f) * 0.25f + 0.75f : 0f, 0.1f, 0.075f); } // Allow vision when going through shortcuts if (plyVessel != null) { int updateShortCut = (int)_RainWorldGame_updateShortCut.GetValue(room.game); bool first = !_overrideEyePos.HasValue; if (!first) { _lastOverrideEyePos = _overrideEyePos.Value; } _overrideEyePos = Vector2.Lerp(plyVessel.lastPos.ToVector2(), plyVessel.pos.ToVector2(), (updateShortCut + 1) / 3f) * 20f + new Vector2(10f, 10f); if (first) { _lastOverrideEyePos = _overrideEyePos.Value; } if (plyVessel.room.realizedRoom != null) { screenblockAlpha = plyVessel.room.realizedRoom.GetTile(_overrideEyePos.Value).Solid ? 1f : 0f; } } else { _overrideEyePos = null; } } else { _peekAlpha = 0f; } // Don't display in arena while multiple players are present // This doesn't happen in story so that Monkland still works if (room.game.IsArenaSession && room.game.Players.Count > 1) { hideAllSprites = true; } }