protected override NodeStates Tick(Tick tick) { NodeStates result = NodeStates.Failure; GameManager gameManager = Locator.Get <GameManager>(); Entity player = gameManager.Player; CellTransform playerTransform = player.CellTransform; Cell playerCell = gameManager.MapManager[playerTransform.Position.x, playerTransform.Position.y]; if ( playerCell != null && playerCell.Prop != null && playerCell.Prop.Info != null && playerCell.Prop.Info.NameId == "Stairs Exit" ) { TrapDoor trapDoor = playerCell.Prop.GetComponent <TrapDoor>(); if (trapDoor != null && trapDoor.IsOpen) { result = NodeStates.Success; } } return(result); }
public virtual bool TryTranslateTextAsset(ref TextAsset textAsset, CellTransform translator, out string result) { if (IsTable(textAsset)) { result = ProcessTable(textAsset, translator, out var tableResult); if (tableResult.RowsUpdated > 0) { return(true); } } result = null; return(false); }
public string ProcessTable(TextAsset textAsset, CellTransform columnTransform, out TextAssetTableResult tableResult) { tableResult = new TextAssetTableResult(); var colJoin = ColSplitStrings.First(); var result = new StringBuilder(textAsset.text.Length * 2); var colBuilder = new StringBuilder(); bool ColumnTransformWrapper(int rowIndex, int colIndex, string col, out string newCol) { if (!columnTransform(rowIndex, colIndex, col, out newCol)) { return(false); } colBuilder.Length = 0; colBuilder.Append(newCol); colBuilder = InvalidColStrings.Aggregate(colBuilder, (current, invalid) => current.Replace(invalid, " ")); newCol = colBuilder.ToString(); return(true); } var table = SplitTable(textAsset); tableResult.Rows = table.Length; tableResult.Cols = 0; for (var r = 0; r < table.Length; r++) { var rowUpdated = false; tableResult.Cols = Math.Max(tableResult.Cols, table[r].Length); for (var c = 0; c < table[r].Length; c++) { var col = table[r][c]; tableResult.Cols = Math.Max(tableResult.Cols, col.Length); if (ColumnTransformWrapper(r, c, col, out var newCol)) { tableResult.CellsUpdated++; rowUpdated = true; result.Append(newCol); } else { result.Append(col); } result.Append(colJoin); } // row complete // remove trailing colSplit result.Length -= colJoin.Length; result.Append(Environment.NewLine); if (rowUpdated) { tableResult.RowsUpdated++; } } // table complete // remove last newline result.Length -= Environment.NewLine.Length; return(tableResult.Updated ? result.ToString() : textAsset.text); }