public void SwitchLevel(Entity _player, string _level, string _entrance) { RegionBase r = this.Parent.LevelBank._GetRegion(_level); r.Position = this.Position; r._OnLevelLoad = this._OnLevelLoad; r._OnLevelEnter = this._OnLevelEnter; r._OnLevelExit = this._OnLevelExit; r._OnLevelUpdate = this._OnLevelUpdate; r._LoadInfo = this._LoadInfo; this.Children.Remove(_player); this.Kill(); this.Parents[0].Children.Add(r); r.SpawnPlayer(_player, _level, _entrance); }
public Region(RegionBase _base, Action <Level, T> _onlevelload = null, Action <Level, T> _onlevelenter = null, Action <Level, T> _onlevelexit = null, Action <Level, T> _onlevelupdate = null) { this._RegionBase = _base; if (_onlevelload != null) { this._RegionBase._OnLevelLoad = b => _onlevelload(b, (T)b._Properties); } if (_onlevelenter != null) { this._RegionBase._OnLevelEnter = b => _onlevelenter(b, (T)b._Properties); } if (_onlevelexit != null) { this._RegionBase._OnLevelExit = b => _onlevelexit(b, (T)b._Properties); } if (_onlevelupdate != null) { this._RegionBase._OnLevelUpdate = b => _onlevelupdate(b, (T)b._Properties); } this._RegionBase._LoadInfo = m => (T)PropertySaver.Load(typeof(T), m); }