/// <summary> /// Registers the specified type to RTTI map. /// </summary> /// <param name="intType">The interface type.</param> /// <param name="implType">The implementation type.</param> /// <param name="address">The addresses.</param> /// <param name="moduleBase">Current module base address.</param> internal static void Register(Type intType, Type implType, uint[] address, IntPtr moduleBase) { if (intType == null) { throw new ArgumentNullException("intType"); } if (implType == null) { throw new ArgumentNullException("implType"); } if (address == null) { throw new ArgumentNullException("address"); } if (moduleBase == null) { throw new ArgumentNullException("moduleBase"); } if (MapInterface.ContainsKey(intType)) { throw new InvalidOperationException("RTTI for \"" + intType.Name + "\" already exists!"); } if (MapImplementation.ContainsKey(implType)) { throw new InvalidOperationException("RTTI for \"" + implType.Name + "\" already exists!"); } address = address.ToArray(); MapInterface[intType] = new Tuple <Type, uint[], IntPtr>(implType, address, moduleBase); MapImplementation[implType] = new Tuple <Type, uint[], IntPtr>(intType, address, moduleBase); }
public void TestSetPos(Transform pos = null) { foreach (var item in enemyState) { GameObject player = RoleInterface.GetPlayer(); GameObject enemy = item.GetGameObject(); if (pos) { enemy.transform.position = new Vector3(pos.position.x, pos.position.y, 0); } Vector3 offset = new Vector3(enemy.GetComponent <BoxCollider2D>().offset.x, enemy.GetComponent <BoxCollider2D>().offset.y, 0f); List <Vector3> path = MapInterface.FindPath(enemy.transform.position + offset, player.transform.position + offset); if (path != null) { if (item.curState._state != States.autoMove) { item.SetState(States.autoMove); } ; path.RemoveAt(0); item.curState.OnAutoMove(player.GetComponent <Animator>(), path, 0.01f); } } }
/// <summary> /// Attempt to perform a dynamic cast on an object. This will throw an exception if source or target type is unsupported /// or if the RTTI cast function has not been set up! /// </summary> /// <param name="obj">The object.</param> /// <param name="target">Type of object to cast to.</param> /// <returns></returns> internal static IVirtualObject DynamicCast(IVirtualObject obj, Type target) { if (obj == null || obj.Address == IntPtr.Zero) { return(null); } if (target == typeof(IVirtualObject)) { return(obj); } // Get target RTTI. There may be more than one if we combined types. Tuple <Type, uint[], IntPtr> targetInfo; { if (!MapInterface.TryGetValue(target, out targetInfo)) { throw new NotSupportedException("Missing RTTI type descriptor for target \"" + target.Name + "\"!"); } } // Try multiple RTTI addresses. foreach (var ip in targetInfo.Item2) { var result = Custom_RTTI_Cast(obj.Address, ip, targetInfo.Item3); if (result != IntPtr.Zero) { return((IVirtualObject)MemoryObject.FromAddress(target, result)); } } // None matched or didn't have any in the list. return(null); }
// Update is called once per frame void Update() { if (GameInput.GetMouseBtn(1)) { player = RoleInterface.GetPlayer(); offset = new Vector3(player.GetComponent <BoxCollider2D>().offset.x, player.GetComponent <BoxCollider2D>().offset.y, 0f); target.transform.position = Camera.main.ScreenToWorldPoint(GameInput.GetMousePos()); List <Vector3> path = MapInterface.FindPath(player.transform.position + offset, target.transform.position); if (path != null) { if (RoleInterface.GetPlayerState() != States.autoMove) { RoleInterface.SetPlayerState(States.autoMove); } path.RemoveAt(0); RoleInterface.OnAutoMove(player.GetComponent <Animator>(), path, 0.01f); } } /*if (GameInput.GetKeyDown(KeyCode.R)) * { * GameManager.instance.roleManager.GetEnemyManager().TestSetPos(target.transform); * } * * if (GameInput.GetKeyDown(KeyCode.F)) * { * GameManager.instance.roleManager.GetEnemyManager().TestSetPos(); * } * * if (GameInput.GetKeyDown(KeyCode.C)) * { * GameManager.instance.roleManager.GetEnemyManager().CreatEnemy("player"); * }*/ }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { if (op.Equals("<")) { return((e1.eval(tbl, heap) < e2.eval(tbl, heap)) ? 1 : 0); } if (op.Equals("<=")) { return((e1.eval(tbl, heap) <= e2.eval(tbl, heap)) ? 1 : 0); } if (op.Equals("==")) { return((e1.eval(tbl, heap).Equals(e2.eval(tbl, heap))) ? 1 : 0); } if (op.Equals("!=")) { return((!e1.eval(tbl, heap).Equals(e2.eval(tbl, heap))) ? 1 : 0); } if (op.Equals(">")) { return((e1.eval(tbl, heap) > e2.eval(tbl, heap)) ? 1 : 0); } if (op.Equals(">=")) { return((e1.eval(tbl, heap) >= e2.eval(tbl, heap)) ? 1 : 0); } return(0); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { try { return readInteger (""); } catch (UnexpectedTypeException) { return eval (tbl, heap); } }
public PrgState execute(PrgState state) { MapInterface <String, int> symTbl = state.SymTable; HeapInterface <int> heap = state.HeapTable; heap.Update(symTbl [Id], Exp.eval(symTbl, heap)); return(null); }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { if (tbl.ContainsKey(id)) { return(tbl [id]); } throw new UninitializedVariableException(); }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { try { return(readInteger("")); } catch (UnexpectedTypeException) { return(eval(tbl, heap)); } }
public PrgState execute(PrgState state) { MapInterface <String, int> symTbl = state.SymTable; HeapInterface <int> heap = state.HeapTable; int val = exp.eval(symTbl, heap); symTbl [id] = val; return(null); }
public PrgState execute(PrgState state) { ListInterface <int> output = state.Output; MapInterface <String, int> symTbl = state.SymTable; HeapInterface <int> heap = state.HeapTable; output.Add(Exp.eval(symTbl, heap)); return(null); }
//optional field, but good to have public PrgState(StackInterface <IStmt> stack, MapInterface <String, int> dictionary, HeapInterface <int> heap, ListInterface <int> list, IStmt prg) { id = generator++; exeStack = stack; symTable = dictionary; heapTable = heap; output = list; originalProgram = prg; exeStack.Push(originalProgram); }
//optional field, but good to have public PrgState(StackInterface<IStmt> stack, MapInterface<String, int> dictionary, HeapInterface<int> heap, ListInterface<int> list, IStmt prg) { id = generator++; exeStack = stack; symTable = dictionary; heapTable = heap; output = list; originalProgram = prg; exeStack.Push (originalProgram); }
private void Awake() { if (instance == null) { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else { GameObject.Destroy(this.gameObject); } }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { if (op.Equals("&&")) { return((e1.eval(tbl, heap) != 0 && e2.eval(tbl, heap) != 0) ? 1 : 0); } if (op.Equals("||")) { return((e1.eval(tbl, heap) != 0 || e2.eval(tbl, heap) != 0) ? 1 : 0); } return(0); }
public PrgState execute(PrgState state) { MapInterface <String, int> symTbl = state.SymTable; HeapInterface <int> heap = state.HeapTable; if (Exp.eval(symTbl, heap) != 0) { state.ExeStack.Push(this); state.ExeStack.Push(this.Stmt); } return(null); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { if (op == "+") return (e1.eval (tbl, heap) + e2.eval (tbl, heap)); if (op == "-") return (e1.eval (tbl, heap) - e2.eval (tbl, heap)); if (op == "*") return (e1.eval (tbl, heap) * e2.eval (tbl, heap)); if (op == "/") { if (e2.eval (tbl, heap) == 0) throw new DivisionByZeroException (); return (e1.eval (tbl, heap) / e2.eval (tbl, heap)); } return 0; }
public static void Postfix(MapInterface __instance) { if (DesignatorShapes.Settings.RestoreAltToggle && !DesignatorShapes.ShowControls) { return; } if (Find.CurrentMap == null || Find.DesignatorManager.SelectedDesignator == null || WorldRendererUtility.WorldRenderedNow) { return; } DesignatorShapes.ShapeControls?.ShapeControlsOnGUI(); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { if (op.Equals ("<")) return (e1.eval (tbl, heap) < e2.eval (tbl, heap)) ? 1 : 0; if (op.Equals ("<=")) return (e1.eval (tbl, heap) <= e2.eval (tbl, heap)) ? 1 : 0; if (op.Equals ("==")) return (e1.eval (tbl, heap).Equals (e2.eval (tbl, heap))) ? 1 : 0; if (op.Equals ("!=")) return (!e1.eval (tbl, heap).Equals (e2.eval (tbl, heap))) ? 1 : 0; if (op.Equals (">")) return (e1.eval (tbl, heap) > e2.eval (tbl, heap)) ? 1 : 0; if (op.Equals (">=")) return (e1.eval (tbl, heap) >= e2.eval (tbl, heap)) ? 1 : 0; return 0; }
private void menuDeleteObj_Click(object sender, EventArgs e) { if (dataGrid1.CurrentRow == null) { return; } if (showWarning) { var dr = MessageBox.Show("This will permanently delete the selected row/object.\n\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.No) { return; } showWarning = false; // User has been warned } var i = dataGrid1.CurrentRow.Index; var name = dataGrid1[3, i].Value.ToString(); var obj = GetNewObject(name); MapInterface.ObjectRemove(obj); dataGrid1.Rows.RemoveAt(i); UpdateFilter(); if (dataGrid1.Rows.Count > i) { if (dataGrid1.Rows[i].Visible) { dataGrid1.CurrentCell = dataGrid1.Rows[i].Cells[3]; } else { if (GetNumRowsVisible() > 0) { dataGrid1.CurrentCell = dataGrid1.Rows[dataGrid1.Rows.GetLastRow(DataGridViewElementStates.Visible)].Cells[3]; } } } MainWindow.Instance.mapView.MapRenderer.UpdateCanvas(true, true); }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { if (op == "+") { return(e1.eval(tbl, heap) + e2.eval(tbl, heap)); } if (op == "-") { return(e1.eval(tbl, heap) - e2.eval(tbl, heap)); } if (op == "*") { return(e1.eval(tbl, heap) * e2.eval(tbl, heap)); } if (op == "/") { if (e2.eval(tbl, heap) == 0) { throw new DivisionByZeroException(); } return(e1.eval(tbl, heap) / e2.eval(tbl, heap)); } return(0); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { return number; }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { return(number); }
public void Update(Point mousePt) { bool iWalls = (MapInterface.CurrentMode >= EditMode.WALL_PLACE && MapInterface.CurrentMode <= EditMode.WALL_CHANGE); bool iTiles = (MapInterface.CurrentMode >= EditMode.FLOOR_PLACE && MapInterface.CurrentMode <= EditMode.EDGE_PLACE); bool iObjs = (MapInterface.CurrentMode == EditMode.OBJECT_SELECT); // Search for walls/tiles/objects under cursor statusLocation = String.Format(FORMAT_COORDINATES, mousePt.X, mousePt.Y); statusMapItem = ""; statusPolygon = ""; // Wall tracking if (iWalls) { var wallPt = MapView.GetNearestWallPoint(mousePt); Map.Wall wall = map.Walls.ContainsKey(wallPt) ? map.Walls[wallPt] : null; statusLocation = String.Format(FORMAT_COORDINATES, wallPt.X, wallPt.Y); if (wall != null) { statusMapItem = String.Format(FORMAT_WALL_INFO, wall.Material, wall.Variation); } if (prevWall != wall) { prevWall = wall; updateStatusbars = true; } } else { prevWall = null; } // Tile tracking if (iTiles) { var tilePt = MapView.GetNearestTilePoint(mousePt); Map.Tile tile = map.Tiles.ContainsKey(tilePt) ? map.Tiles[tilePt] : null; statusLocation = String.Format(FORMAT_COORDINATES, tilePt.X, tilePt.Y); if (tile != null) { statusMapItem = String.Format(FORMAT_TILE_INFO, tile.Graphic, tile.Variation); edgeCount = tile.EdgeTiles.Count; if (tile.EdgeTiles.Count > 0) { statusMapItem += String.Format(FORMAT_EDGE_COUNT, tile.EdgeTiles.Count); foreach (Map.Tile.EdgeTile edge in tile.EdgeTiles) { statusMapItem += String.Format(FORMAT_EDGE_INFO, ThingDb.FloorTileNames[edge.Graphic], edge.Variation, edge.Dir, ThingDb.EdgeTileNames[edge.Edge]); } } } if (prevTile != tile) { prevTile = tile; updateStatusbars = true; } if (prevEdge != edgeCount && tile != null) { prevEdge = tile.EdgeTiles.Count; updateStatusbars = true; } } else { prevTile = null; } // Object tracking if (iObjs) { Map.Object obj = MapInterface.ObjectSelect(mousePt); if (obj == null) { return; } statusMapItem = String.Format(FORMAT_OBJECT_INFO, obj.Name, obj.Extent); if (prevObj != obj) { prevObj = obj; updateStatusbars = true; } } else { prevObj = null; } // Polygon tracking Map.Polygon ins = null; var ptFlt = new PointF(mousePt.X, mousePt.Y); int i = -1; foreach (Map.Polygon poly in map.Polygons) { i++; if (poly.IsPointInside(ptFlt)) { statusPolygon = poly.Name; ins = poly; if (MainWindow.Instance.mapView.PolygonEditDlg.Visible && !MainWindow.Instance.mapView.PolygonEditDlg.LockedBox.Checked && MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE && (MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon != MainWindow.Instance.mapView.PolygonEditDlg.SuperPolygon || MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon == null)) { MainWindow.Instance.mapView.PolygonEditDlg.listBoxPolygons.SelectedIndex = i; MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon = ins; //System.Windows.Forms.MessageBox.Show("ON:"); } break; } } /* * if (ins == null) * { * * MainWindow.Instance.mapView.PolygonEditDlg.listBoxPolygons.ClearSelected(); * MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon = null; * // System.Windows.Forms.MessageBox.Show("OFF:"); * } */ if (prevPoly != ins) { prevPoly = ins; updateStatusbars = true; } }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { if (tbl.ContainsKey (id)) return tbl [id]; throw new UninitializedVariableException (); }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { return(exp.eval(tbl, heap) == 0 ? 1 : 0); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { return exp.eval (tbl, heap) == 0 ? 1 : 0; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog eLoad = new OpenFileDialog(); eLoad.Filter = "Elements File (*.ecwld)|*.ecwld|All Files (*.*)|*.*"; eLoad.RestoreDirectory = false; if (eLoad.ShowDialog() == System.Windows.Forms.DialogResult.OK && File.Exists(eLoad.FileName)) { FileStream fs = File.OpenRead(eLoad.FileName); BinaryReader br = new BinaryReader(fs); string ecwldPath = Path.GetDirectoryName(eLoad.FileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(eLoad.FileName) + ".ecbsd"; FileStream fs2 = File.OpenRead(ecwldPath); BinaryReader ecbsd = new BinaryReader(fs2); try { EcwldStructure p = new EcwldStructure(); p.version = ecbsd.ReadInt32(); p.signature = ecbsd.ReadInt32(); p.noint = ecbsd.ReadInt32(); p.size = ecbsd.ReadInt32(); p.garb = ecbsd.ReadBytes(60); EcwldFiles[] kk = new EcwldFiles[p.size]; for (int paramString = 0; paramString < p.size; paramString++) { EcwldFiles k = new EcwldFiles(); k.lenght = ecbsd.ReadInt32(); k.fileName = Encoding.UTF8.GetString(ecbsd.ReadBytes(k.lenght));// Converter.ToString(br.ReadBytes(k.a)); kk[paramString] = k; } EcbsdData f = new EcbsdData(); f.a = br.ReadInt32(); f.b = br.ReadInt32(); f.c = br.ReadSingle(); f.d = br.ReadSingle(); f.e = br.ReadSingle(); f.f = br.ReadInt32(); f.g = br.ReadInt32(); f.h = br.ReadInt32(); f.i = br.ReadInt32(); f.j = br.ReadInt32(); f.k = br.ReadInt32(); f.l = br.ReadInt32(); f.m = br.ReadInt32(); f.n = br.ReadInt32(); f.o = br.ReadBytes(60); int[] g = new int[f.g]; for (int i2 = 0; i2 < g.Length; i2++) { g[i2] = br.ReadInt32(); } int n3 = 0; while (n3 < f.g) { br.BaseStream.Position = g[n3]; int n5 = f.b; MapInterface f2 = n5 >= 9 ? new MapInterface() : null; f2.read(br); a.Add(f2); int n4 = 0; if (f2.c > 0) { n4 = 0; while (n4 < f2.c) { PositionData k3 = new PositionData(); try { k3.a = br.ReadInt32(); k3.b.ar(br); } catch { } f2.n.Add(k3); ++n4; } } if (f2.d > 0) { n4 = 0; while (n4 < f2.d) { m k2 = new m(); new m().a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "WATER"; f2.j.Add(k2); ae((m)k2, n3); ++n4; } } if (f2.f > 0) { n4 = 0; while (n4 < f2.f) { m k2 = new m(); k2.a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "ORN"; f2.l.Add(k2); ae((m)k2, n3); ++n4; } } if (f2.g > 0) { n4 = 0; while (n4 < f2.g) { m k2 = new m(); k2.a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "BOX"; f2.h.Add(k2); ae((m)k2, n3); ++n4; } } if (f2.e > 0) { n4 = 0; while (n4 < f2.e) { m k2 = new m(); k2.a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "GRASS"; f2.k.Add(k2); this.ae((m)k2, n3); ++n4; } } if (f2.r > 0) { try { hx h2 = new hx(); h2.a = br.ReadInt32(); h2.b = br.ReadSingle(); h2.c.ar(br); h2.d.ar(br); h2.e.ar(br); h2.f = br.ReadSingle(); h2.g = br.ReadInt32(); h2.h = br.ReadSingle(); h2.i = br.ReadInt32(); h2.j = br.ReadInt32(); h2.k = br.ReadBytes(h2.j); } catch (IOException v1) { } } if (f2.s > 0) { gx g2 = new gx(); try { g2.a = br.ReadInt32(); g2.b.ar(br); g2.c.ar(br); g2.d.ar(br); g2.e = br.ReadInt32(); g2.f = br.ReadBytes(g2.e); g2.g = br.ReadInt32(); g2.h = Encoding.GetEncoding("gb2312").GetString(br.ReadBytes(g2.g)); } catch { } } if (f2.t > 0) { n4 = 0; while (n4 < f2.t) { m k2 = new m(); new m().a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "CRITTER"; f2.m.Add(k2); ae((m)k2, n3); ++n4; } } if (f2.u > 0) { n4 = 0; while (n4 < f2.u) { m k2 = new m(); new m().a = br.ReadInt32(); k2.b = br.ReadInt32(); k2.c = "BEZIER"; f2.i.Add(k2); this.ae((m)k2, n3); ++n4; } } if (f2.v > 0) { n4 = 0; while (n4 < f2.v) { j k2 = new j(); try { k2.a = br.ReadInt32(); k2.b.ar(br); k2.c = br.ReadSingle(); k2.d = br.ReadSingle(); k2.e = br.ReadInt32(); k2.f = br.ReadInt32(); k2.g = br.ReadInt32(); k2.h = Encoding.GetEncoding("gb2312").GetString(br.ReadBytes(k2.g));//br.ReadBytes(k2.g); } catch (IOException v3) { } f2.q.Add(k2); ++n4; } } ++n3; } } catch (Exception esad) { MessageBox.Show("ERR"); } } }
public int eval(MapInterface <String, int> tbl, HeapInterface <int> heap) { int address = tbl [id]; return(heap.Get(address)); }
public int eval(MapInterface<String, int> tbl, HeapInterface<int> heap) { int address = tbl [id]; return heap.Get (address); }