Inheritance: MonoBehaviour
コード例 #1
0
        /// <summary>
        /// Provides the functionality to map a DLL from disk into a process
        /// </summary>
        public LibraryMapper(Process process, string dllFilePath, MappingFlags mappingFlags = MappingFlags.None)
        {
            if (process is null || process.HasExited)
            {
                throw new ArgumentException("The provided process is not currently running");
            }

            if (string.IsNullOrWhiteSpace(dllFilePath) || !File.Exists(dllFilePath))
            {
                throw new ArgumentException("The provided file path did not point to a valid file");
            }

            if (!Environment.Is64BitProcess && process.GetArchitecture() == Architecture.X64)
            {
                throw new NotSupportedException("The provided process cannot be loaded into from an x86 build");
            }

            _dllBytes = File.ReadAllBytes(dllFilePath);

            _fileResolver = new FileResolver(process, Path.GetDirectoryName(dllFilePath));

            _mappingFlags = mappingFlags;

            _peImage = new PeImage(_dllBytes.ToArray());

            _processContext = new ProcessContext(process);

            _symbolHandler = new SymbolHandler(Path.Combine(process.GetSystemDirectoryPath(), "ntdll.dll"));
        }
コード例 #2
0
        private void RequestStopSymbol(SymbolInfo symbol)
        {
            SymbolHandler buffer = symbolHandlers[symbol.BinaryIdentifier];

            buffer.Stop();
            receiver.OnEvent(symbol, (int)EventType.EndRealTime, null);
        }
コード例 #3
0
        public async Task <IEnumerable <ExportedSymbol> > GetCFGFunctions()
        {
            var va        = CFGFunctionTable - _parser.OptionalHeader.ImageBase;
            int count     = (int)CFGFunctionCount;
            var symbols   = new ExportedSymbol[count];
            var offset    = _parser.RvaToFileOffset((int)va);
            int lastIndex = -1;

            using (var handler = SymbolHandler.Create(SymbolOptions.UndecorateNames)) {
                var dllBase = await handler.TryLoadSymbolsForModuleAsync(_parser.FileName);

                ulong disp;
                var   symbol = new SymbolInfo();
                for (int i = 0; i < count; i++)
                {
                    var    address = _parser.Read <uint>(offset);
                    string name    = null;
                    if (dllBase != 0)
                    {
                        if (handler.TryGetSymbolFromAddress(address + dllBase, ref symbol, out disp) && (lastIndex < 0 || symbol.Name != symbols[lastIndex].Name))
                        {
                            name      = symbol.Name;
                            lastIndex = i;
                        }
                    }
                    symbols[i] = new ExportedSymbol {
                        Address = address, Name = name
                    };
                    offset += 5;
                }
            }

            return(symbols);
        }
コード例 #4
0
        private void client_ExecDetails(object sender, ExecDetailsEventArgs e)
        {
            log.InfoFormat("Execution: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}",
                           e.Contract.Symbol, e.Execution.AccountNumber, e.Execution.ClientId, e.Execution.Exchange, e.Execution.ExecutionId,
                           e.Execution.Liquidation, e.Execution.OrderId, e.Execution.PermId, e.Execution.Price, e.Execution.Shares, e.Execution.Side, e.Execution.Time);

            SymbolInfo    symbol         = Factory.Symbol.LookupSymbol(e.Contract.Symbol);
            SymbolHandler symbolHandler  = symbolHandlers[symbol.BinaryIdentifier];
            TimeStamp     executionTime  = new TimeStamp(e.Execution.Time);
            int           logicalOrderId = GetLogicalOrderId(e.Execution.OrderId);
            double        change         = e.Execution.Side == ExecutionSide.Bought ? e.Execution.Shares : -e.Execution.Shares;
            double        positionBefore = symbolHandler.Position;

            symbolHandler.AddPosition(change);
            if (trace)
            {
                log.Trace("Changed symbol position: " + positionBefore + " + " + change + " = " + symbolHandler.Position);
            }
            LogicalFillBinary binary = new LogicalFillBinary(symbolHandler.Position, e.Execution.Price, executionTime, logicalOrderId);

            if (debug)
            {
                log.Debug("Sending logical fill: " + binary);
            }
            receiver.OnEvent(symbol, (int)EventType.LogicalFill, binary);
        }
コード例 #5
0
        private CallStack BuildStack(ulong[] stack)
        {
            if (stack == null)
            {
                return(null);
            }

            StackFrame[] frames;
            using (var handler = SymbolHandler.TryCreateFromProcess(ProcessId, SymbolOptions.Include32BitModules | SymbolOptions.UndecorateNames)) {
                if (handler == null)
                {
                    frames = stack.Select(p => new StackFrame {
                        Address = p
                    }).ToArray();
                }

                else
                {
                    frames = new StackFrame[stack.Length];
                    var   symbol = new SymbolInfo();
                    ulong disp;
                    for (int i = 0; i < stack.Length; i++)
                    {
                        if (handler.TryGetSymbolFromAddress(stack[i], ref symbol, out disp))
                        {
                            frames[i] = new StackFrame {
                                Address = stack[i], Offset = disp, SymbolName = symbol.Name
                            }
                        }
                    }
                    ;
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        instance = this;
        //SymbolHandler.graphModel = graphModel;

        Symbol square   = SymbolHandler.fromName("Square");
        Symbol circle   = SymbolHandler.fromName("Circle");
        Symbol star     = SymbolHandler.fromName("Star");
        Symbol diamond  = SymbolHandler.fromName("Diamond");
        Symbol squiggle = SymbolHandler.fromName("Squiggle");
        Symbol triangle = SymbolHandler.fromName("Triangle");

        SymbolHandler.fromName("Door").setHoverPrefab(furniturePrefab);
        SymbolHandler.fromName("Bed").setHoverPrefab(furniturePrefab);
        SymbolHandler.fromName("Dresser").setHoverPrefab(furniturePrefab);
        SymbolHandler.fromName("Sun").setHoverPrefab(sunPrefab);
        SymbolHandler.fromName("Floor Lamp").setHoverPrefab(lightPrefab);
        SymbolHandler.fromName("House").setHoverPrefab(wallBuilderPrefab);
        SymbolHandler.fromName("Chair").setHoverPrefab(chairPrefab);

        square.setHoverPrefab(squareHoverPrefab);
        circle.setHoverPrefab(circleHoverPrefab);
        star.setHoverPrefab(starHoverPrefab);
        diamond.setHoverPrefab(diamondHoverPrefab);
        squiggle.setHoverPrefab(squiggleHoverPrefab);
        triangle.setHoverPrefab(triangleHoverPrefab);

        foreach (GameObject go in props)
        {
            PropHandler.register(go);
        }

        startPython();
        StartCoroutine(SetupServer());
    }
コード例 #7
0
        /// <summary>
        /// Provides the functionality to map a DLL from memory into a process
        /// </summary>
        public LibraryMapper(Process process, Memory <byte> dllBytes, MappingFlags mappingFlags = MappingFlags.None)
        {
            if (process is null || process.HasExited)
            {
                throw new ArgumentException("The provided process is not currently running");
            }

            if (dllBytes.IsEmpty)
            {
                throw new ArgumentException("The provided DLL bytes were empty");
            }

            if (!Environment.Is64BitProcess && process.GetArchitecture() == Architecture.X64)
            {
                throw new NotSupportedException("The provided process cannot be loaded into from an x86 build");
            }

            _dllBytes = dllBytes.ToArray();

            _fileResolver = new FileResolver(process, null);

            _mappingFlags = mappingFlags;

            _peImage = new PeImage(dllBytes);

            _processContext = new ProcessContext(process);

            _symbolHandler = new SymbolHandler(Path.Combine(process.GetSystemDirectoryPath(), "ntdll.dll"));
        }
コード例 #8
0
 //
 // Additional methods
 //
 private void SetDrawer(PictureBox board)
 {
     if (_symbol is null || _symbol.GetSampleSize() != _params.PerSymbolSamples)
     {
         _symbol = new SymbolHandler(_params.PerSymbolSamples);
     }
     _drawer = new Drawer(board, _symbol);
 }
コード例 #9
0
        private void RequestStopSymbol(SymbolInfo symbol, Agent symbolAgent)
        {
            SymbolHandler handler = symbolHandlers[symbol.BinaryIdentifier];

            handler.Stop();
            var item = new EventItem(symbol, EventType.EndRealTime);

            symbolAgent.SendEvent(item);
        }
コード例 #10
0
 public void TestHomeDirectories()
 {
     using (SymbolHandler handler = new SymbolHandler()) {
         handler.HomeDirectory   = handler.HomeDirectory;
         handler.SourceDirectory = handler.SourceDirectory;
         handler.SymbolDirectory = handler.SymbolDirectory;
     }
     return;
 }
コード例 #11
0
ファイル: ProcessContext.cs プロジェクト: hugmyndakassi/Lunar
    internal ProcessContext(Process process)
    {
        _apiSetMap     = new ApiSetMap();
        _moduleCache   = new ConcurrentDictionary <string, Module>(StringComparer.OrdinalIgnoreCase);
        _symbolHandler = new SymbolHandler(process.GetArchitecture());

        Architecture = process.GetArchitecture();
        Process      = process;
    }
コード例 #12
0
        private static void SetLocalTickTIme(SymbolHandler handler)
        {
            var currentTime = TimeStamp.UtcNow;

            if (currentTime <= handler.Time)
            {
                currentTime.Internal = handler.Time.Internal + 1;
            }
            handler.Time = currentTime;
        }
コード例 #13
0
        private static void SetSimulatorTime(SymbolHandler handler, long ordertime)
        {
            var currentTime = new TimeStamp(ordertime);

            //SimulatorTime = currentTime;
            if (currentTime <= handler.Time)
            {
                currentTime.Internal = handler.Time.Internal + 1;
            }
            handler.Time = currentTime;
        }
コード例 #14
0
 private void ButtonLoadTestSet_Click(object sender, EventArgs e)
 {
     _instance                = _parser.ParseData(loadTestSet.Text);
     _params.Samples          = _instance.NumSamples;
     _params.Symbols          = _instance.NumSymbols;
     _params.PerSymbolSamples = _instance.NumSymbolSamples;
     _symbol = new SymbolHandler(_params.PerSymbolSamples);
     UiHandler.SetSlider(panelSlider, buttonTrain.Top, buttonTrain.Height);
     buttonTestSet.Enabled = true;
     buttonTrain.Enabled   = true;
     UiHandler.PanelVisible(panelTrain, _panels);
 }
コード例 #15
0
        public void StopSymbol(Receiver receiver, SymbolInfo symbol)
        {
            if (debug)
            {
                log.Debug("StartSymbol");
            }
            client.CancelMarketData((int)symbol.BinaryIdentifier);
            SymbolHandler buffer = symbolHandlers[symbol.BinaryIdentifier];

            buffer.Stop();
            receiver.OnEvent(symbol, (int)EventType.EndRealTime, null);
        }
コード例 #16
0
    public static float[,] getMatrix(List <Vector3> locs, List <Vector3> headLocs, List <Vector3> headForwards, string filepath = null)
    {
        if (filepath == null)
        {
            return(calcMatrix(locs, headLocs, headForwards));
        }
        filepath = SymbolHandler.getMatrixPath(filepath);

        if (File.Exists(filepath))
        {
            System.IO.StreamReader file = new System.IO.StreamReader(filepath);
            float[,] mat = new float[inputSizeRoot, inputSizeRoot];
            string line;
            int    i = 0;
            while ((line = file.ReadLine()) != null)
            {
                int j = 0;
                foreach (char c in line.ToCharArray())
                {
                    if (c == '*')
                    {
                        mat[i, j] = 1;
                    }
                    j++;
                }
                i++;
            }
            file.Close();
            return(mat);
        }
        else
        {
            float[,] mat = calcMatrix(locs, headLocs, headForwards);
            string text = "";
            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    text += (mat[i, j] == 1) ? "*" : " ";
                }
                text += "\n";
            }
            text = text.Substring(0, text.Length - 1);

            int last = filepath.LastIndexOf("/");
            System.IO.Directory.CreateDirectory(filepath.Substring(0, last));

            System.IO.File.WriteAllText(filepath, text);
            return(mat);
        }
    }
コード例 #17
0
 private void client_UpdatePortfolio(object sender, UpdatePortfolioEventArgs e)
 {
     try {
         SymbolInfo    symbol  = Factory.Symbol.LookupSymbol(e.Contract.Symbol);
         SymbolHandler handler = GetSymbolHandler(symbol, receiver);
         handler.SetPosition(e.Position);
         if (debug)
         {
             log.Debug("UpdatePortfolio: " + e.Contract.Symbol + " is " + e.Position);
         }
     } catch (ApplicationException ex) {
         log.Warn("UpdatePortfolio: " + ex.Message);
     }
 }
コード例 #18
0
        public void ShouldTranslateSymbolsToUnicode()
        {
            var fontFamily = new Dictionary <string, string>
            {
                { "font-family", "Symbol" }
            };

            var symbolHandler = new SymbolHandler();
            var element       = new XElement("symbol", new XAttribute(W._char, "F0D7"));

            var actual = symbolHandler.TransformSymbol(element, fontFamily);

            Assert.Equal("<span xmlns=\"http://www.w3.org/1999/xhtml\">⋅</span>", actual.ToString());
        }
コード例 #19
0
 public DriverInterface()
 {
     _hDevice = CreateFile(@"\\.\" + DriverName, FileAccessMask.GenericRead | FileAccessMask.GenericWrite, FileShareMode.Read,
                           IntPtr.Zero, CreationDisposition.OpenExisting, CreateFileFlags.None, IntPtr.Zero);
     if (_hDevice.IsInvalid)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
     _symbolHandler = SymbolHandler.Create(SymbolOptions.AllowAbsoluteSymbols | SymbolOptions.CaseInsensitive | SymbolOptions.AllowZeroAddress);
     _ntoskrnlBase  = _symbolHandler.LoadSymbolsForModule(@"%systemroot%\System32\Ntoskrnl.exe");
     if (_ntoskrnlBase == 0)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
     GetKernelAddress(out _kernelAddress);
 }
コード例 #20
0
        void BuildEjobDescription()
        {
            if (_ejobDescription == null)
            {
                using (var handler = SymbolHandler.Create(SymbolOptions.CaseInsensitive)) {
                    var address = handler.LoadSymbolsForModule(@"%systemroot%\system32\ntoskrnl.exe");
                    if (address == 0)
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }
                    var types = handler.EnumTypes(address, "_ejob");
                    Debug.Assert(types != null && types.Count == 1);

                    _ejobDescription = handler.BuildStructDescriptor(address, types[0].TypeIndex);
                }
            }
        }
コード例 #21
0
        public void StartSymbol(Receiver receiver, SymbolInfo symbol, StartSymbolDetail detail)
        {
            if (debug)
            {
                log.Debug("StartSymbol " + symbol + ", " + detail.LastTime);
            }
//            Equity equity = new Equity(symbol.Symbol);
//			Contract contract = new Contract(symbol.Symbol,"SMART",SecurityType.Stock,"USD");
//            Contract contract = new Contract(symbol.Symbol,"GLOBEX",SecurityType.Future,"USD","201006");
            Contract      contract = SymbolToContract(symbol);
            SymbolHandler handler  = GetSymbolHandler(symbol, receiver);

//            tickerid.Add((int)symbol.BinaryIdentifier);
//            client.RequestMarketData((int)symbol.BinaryIdentifier, contract, null, false, false);
            client.RequestMarketData((int)symbol.BinaryIdentifier, contract, null, false, false);
            receiver.OnEvent(symbol, (int)EventType.StartRealTime, null);
        }
コード例 #22
0
        private void UpdateTime(SymbolHandler handler, MessageMbtQuotes message)
        {
            TimeStamp currentTime;

            if (UseLocalTickTime)
            {
                currentTime = TimeStamp.UtcNow;
            }
            else
            {
                currentTime = new TimeStamp(message.GetTickUtcTime());
            }
            if (currentTime <= handler.Time)
            {
                currentTime.Internal = handler.Time.Internal + 1;
            }
            handler.Time = currentTime;
        }
コード例 #23
0
        public void TestSearchPath()
        {
            IntPtr dllLibraryCookie = IntPtr.Zero;

            try {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                dllLibraryCookie = Kernel32.AddDllDirectory(currentDomain.BaseDirectory);
                IntPtr nativeDbgHelp = Kernel32.LoadLibraryEx("DBGHELP.DLL", IntPtr.Zero,
                                                              Kernel32.LoadFlags.SeachUserDirectories);
                if (IntPtr.Zero == nativeDbgHelp)
                {
                    throw new ApplicationException();
                }
                IntPtr nativeSymSrv = Kernel32.LoadLibraryEx("SYMSRV.DLL", IntPtr.Zero,
                                                             Kernel32.LoadFlags.SeachUserDirectories);
                if (IntPtr.Zero == nativeSymSrv)
                {
                    throw new ApplicationException();
                }
                string algExeSearchPath;
                string algPdbSearchPath;
                using (SymbolHandler handler = new SymbolHandler()) {
                    handler.SearchPath =
                        @"srv*c:\symbols*https://msdl.microsoft.com/download/symbols";
                    algExeSearchPath = handler.FindExeFile("alg.exe", 0x5632D7B5, 0x1c000);
                    Guid   pdbGuid;
                    uint   age;
                    string pdbFileName = SymbolHandler.GetPdbFileInfoFromExe(
                        new FileInfo(algExeSearchPath), out pdbGuid, out age);
                    if (null == pdbFileName)
                    {
                        throw new ApplicationException();
                    }
                    algPdbSearchPath = handler.FindPdbFile(pdbFileName, pdbGuid, age);
                }
                return;
            }
            finally {
                if (null != dllLibraryCookie)
                {
                    Kernel32.RemoveDllDirectory(dllLibraryCookie);
                }
            }
        }
コード例 #24
0
 private void client_TickSize(object sender, TickSizeEventArgs e)
 {
     if (e.Size < 65535)
     {
         SymbolHandler buffer = symbolHandlers[(ulong)e.TickerId];
         if (e.TickType == TickType.AskSize)
         {
             buffer.AskSize = e.Size;
             buffer.SendQuote();
         }
         else if (e.TickType == TickType.BidSize)
         {
             buffer.BidSize = e.Size;
             buffer.SendQuote();
         }
         else if (e.TickType == TickType.LastSize)
         {
             buffer.LastSize = e.Size;
             buffer.SendTimeAndSales();
         }
     }
 }
コード例 #25
0
        private void client_TickPrice(object sender, TickPriceEventArgs e)
        {
            SymbolHandler buffer = symbolHandlers[(ulong)e.TickerId];

            if (e.TickType == TickType.AskPrice)
            {
                buffer.Ask = (double)e.Price;
                buffer.SendQuote();
            }
            else if (e.TickType == TickType.BidPrice)
            {
                buffer.Bid = (double)e.Price;
                buffer.SendQuote();
            }
            else if (e.TickType == TickType.LastPrice)
            {
                buffer.Last = (double)e.Price;
                if (buffer.LastSize > 0)
                {
                    buffer.SendTimeAndSales();
                }
            }
        }
コード例 #26
0
 private void client_OpenOrderEnd(object sender, EventArgs e)
 {
     if (trace)
     {
         log.Trace("Open Order End ");
     }
     foreach (var kvp in symbolHandlers)
     {
         LogicalOrderHandler handler = kvp.Value.LogicalOrderHandler;
         handler.ClearPhysicalOrders();
     }
     foreach (var kvp in openOrders)
     {
         HandleOpenOrder(kvp.Value);
     }
     foreach (var kvp in symbolHandlers)
     {
         ulong               symbolBinaryId = kvp.Key;
         SymbolHandler       symbolHandler  = kvp.Value;
         LogicalOrderHandler orderHandler   = symbolHandler.LogicalOrderHandler;
         orderHandler.SetActualPosition(symbolHandler.Position);
         orderHandler.PerformCompare();
     }
 }
コード例 #27
0
        private unsafe void Level1Update(PacketMBTQuotes packet)
        {
            SymbolHandler handler = null;
            MemoryStream  data    = packet.Data;

            data.Position += 2;
            string time = null;
            string date = null;

            fixed(byte *bptr = data.GetBuffer())
            {
                byte *ptr = bptr + data.Position;

                while (ptr - bptr < data.Length)
                {
                    int key = packet.GetKey(ref ptr);
                    switch (key)
                    {
                    case 1003:                             // Symbol
                        string     symbol     = packet.GetString(ref ptr);
                        SymbolInfo symbolInfo = Factory.Symbol.LookupSymbol(symbol);
                        handler = symbolHandlers[symbolInfo.BinaryIdentifier];
                        break;

                    case 2014:                             // Time
                        time = packet.GetString(ref ptr);
                        break;

                    case 2015:                             // Date
                        date = packet.GetString(ref ptr);
                        break;

                    case 2003:                             // Bid
                        handler.Bid = packet.GetDouble(ref ptr);
                        break;

                    case 2004:                             // Ask
                        handler.Ask = packet.GetDouble(ref ptr);
                        break;

                    case 2005:                             // Bid Size
                        handler.AskSize = packet.GetInt(ref ptr);
                        break;

                    case 2006:                             // Ask Size
                        handler.BidSize = packet.GetInt(ref ptr);
                        break;

                    default:
                        packet.SkipValue(ref ptr);
                        break;
                    }
                    if (*(ptr - 1) == 10)
                    {
                        if (UseLocalTickTime)
                        {
                            var currentTime = TimeStamp.UtcNow;
                            if (currentTime == prevTime)
                            {
                                currentTime.Internal = prevTime.Internal + 1;
                            }
                            prevTime     = currentTime;
                            handler.Time = currentTime;
                        }
                        else
                        {
                            var strings = date.Split(new char[] { '/' });
                            date         = strings[2] + "/" + strings[0] + "/" + strings[1];
                            handler.Time = new TimeStamp(date + " " + time);
                        }
                        handler.SendQuote();
                        data.Position++;
                        return;
                    }
                }
            }

            throw new ApplicationException("Expected Level 1 Quote to end with new line character. Packet:\n" + packet);
        }
コード例 #28
0
 public float[,] getMatrix()
 {
     return(SymbolHandler.getMatrix(locs, headPos, headForward));
 }
コード例 #29
0
    // Update is called once per frame
    void Update()
    {
        sel.select(hand.gameObject);
        if (sel.getHitObect() == null || sel.button == null)
        {
            sel.drawLine(new Color(0, 0, 0, 0));
        }
        else
        {
            sel.drawLine(Color.cyan);
            if (hand.grabPinchAction.GetStateDown(hand.handType))
            {
                sel.button.press();
            }
        }

        GameObject handAttached = null;
        Tool       tool         = null;

        if (hand.AttachedObjects.Count != 0)
        {
            handAttached = hand.AttachedObjects[0].attachedObject;
            tool         = handAttached.GetComponent <Tool>();
            foreach (GameObject obj in topObs)
            {
                if (obj != handAttached)
                {
                    Destroy(obj);
                }
            }
            foreach (GameObject obj in toolTips)
            {
                Destroy(obj);
            }
        }
        else
        {
            string pythonGuess = GameInitializer.instance.recieved;
            if (pythonGuess != null && instancePythonGuessing)
            {
                pythonGuessing                    = false;
                instancePythonGuessing            = false;
                GameInitializer.instance.recieved = null;
                Debug.Log("Python Guess: " + pythonGuess);
                string[] guess_ar = pythonGuess.Split('-');
                if (guess_ar.Length >= 2)
                {
                    Symbol[] topSymbols = new Symbol[3];
                    pythonGuess = guess_ar[0];
                    string[] guesses = pythonGuess.Split(' ');
                    pythonGuess = "";
                    int index = 0;
                    foreach (string num in guesses)
                    {
                        int x;
                        if (Int32.TryParse(num, out x))
                        {
                            if (index != 0)
                            {
                                pythonGuess += " | ";
                            }
                            pythonGuess      += SymbolHandler.fromId(x).getName();
                            topSymbols[index] = SymbolHandler.fromId(x);
                            index++;
                        }
                    }
                    Debug.Log(pythonGuess);
                    //pythonText.text = pythonGuess;


                    float   dis = .1F, hor = .3F;
                    Vector3 right = GameInitializer.instance.transform.right;
                    if (topSymbols[0].getHoverPrefab() != null)
                    {
                        topObs.Add(Instantiate(topSymbols[0].getHoverPrefab(), transform.position + transform.up * dis, Quaternion.identity));
                    }
                    if (topSymbols[1].getHoverPrefab() != null)
                    {
                        topObs.Add(Instantiate(topSymbols[1].getHoverPrefab(), transform.position + transform.up * dis - right * hor, Quaternion.identity));
                    }
                    if (topSymbols[2].getHoverPrefab() != null)
                    {
                        topObs.Add(Instantiate(topSymbols[2].getHoverPrefab(), transform.position + transform.up * dis + right * hor, Quaternion.identity));
                    }
                    int i = 0;
                    foreach (GameObject go in topObs)
                    {
                        while (topSymbols[i].getHoverPrefab() == null)
                        {
                            i++;
                        }
                        Rigidbody rb = go.GetComponent <Rigidbody>();
                        if (rb != null)
                        {
                            rb.useGravity = false;
                        }
                        Tool goTool = go.GetComponent <Tool>();
                        if (goTool != null)
                        {
                            GameObject toolTip = Instantiate(GameInitializer.instance.textTooltipPrefab);
                            toolTips.Add(toolTip);
                            toolTip.transform.parent        = go.transform;
                            toolTip.transform.localPosition = new Vector3(0, -.05F, 0);
                            TextMesh text = toolTip.GetComponent <TextMesh>();
                            text.text = goTool.getName(gameObject) + "\n" + topSymbols[i].getName();
                        }
                        i++;
                    }
                }
            }
        }

        //foreach (GameObject sphere in spheres) sphere.GetComponent<MeshRenderer>().material.color = symbolTensorChecker.getColor();

        if (hand.startAction.GetStateDown(hand.handType) && tool == null)
        {
            if (wand == null)
            {
                toggleSaveMenu();
            }
            else
            {
                toggleSaveMenu();
            }
        }

        //if (hand.grabGripAction.GetStateDown(hand.handType)) curColor = (curColor + 1) % colors.Length;
        if (hand.grabGripAction.GetStateDown(hand.handType))
        {
            if (saveMenu == null)
            {
                Destroy(saveMenu);
            }
            if (wand == null)
            {
                wand = Instantiate(wandPrefab, new Vector3(0, 0, 0), Quaternion.identity);
                hand.AttachScripted(wand);
                while (topObs.Count > 0)
                {
                    Destroy(topObs[0]);
                    topObs.RemoveAt(0);
                }
            }
            else
            {
                GameObject.Destroy(wand);
                wand = null;
                //float[,] eval = symbolTensorChecker.debug();
                if (locs.Count > 0 && !pythonGuessing)
                {
                    pythonGuessing         = true;
                    instancePythonGuessing = true;
                    SymbolHandler.python_guess(locs, headPos, headForward);
                }
            }
            ClearSpheres();
        }
        if (hand.grabPinchAction.GetStateDown(hand.handType))
        {
            triggerPressed = true;
        }
        if (hand.grabPinchAction.GetStateUp(hand.handType))
        {
            triggerPressed = false;
        }
        if (triggerPressed)
        {
            if (wand != null)
            {
                Spawn();
            }
        }

        bool padActive = (hand.padTouch.GetAxis(hand.handType) * 50F).magnitude > 1;

        if (!padActive)
        {
            lastZero = true;
        }
        else if (lastZero)
        {
            padActive = false;
            lastZero  = false;
        }

        if (tool != null)
        {
            tool.handUpdate(gameObject, hand.grabPinchAction.GetStateDown(hand.handType), hand.startAction.GetStateDown(hand.handType),
                            hand.padTouch.GetLastAxisDelta(hand.handType), padActive);
        }

        if (hand.flying && hand.teleportAction.GetLastState(hand.handType))
        {
            Player  p      = getPlayerParent(gameObject);
            Vector3 curFly = p.transform.position - gameObject.transform.position;
            if (currentlyFlying)
            {
                p.gameObject.transform.position += curFly - lastFly;
            }
            else
            {
                currentlyFlying = true;
            }
            lastFly = curFly;
        }
        else
        {
            currentlyFlying = false;
        }
    }
コード例 #30
0
        private unsafe void TimeAndSalesUpdate(PacketMBTQuotes packet)
        {
            SymbolHandler handler = null;
            MemoryStream  data    = packet.Data;

            data.Position += 2;
            string     time       = null;
            string     date       = null;
            SymbolInfo symbolInfo = null;

            fixed(byte *bptr = data.GetBuffer())
            {
                byte *ptr = bptr + data.Position;

                while (ptr - bptr < data.Length)
                {
                    int key = packet.GetKey(ref ptr);
                    switch (key)
                    {
                    case 1003:                             // Symbol
                        string symbol = packet.GetString(ref ptr);
                        symbolInfo = Factory.Symbol.LookupSymbol(symbol);
                        handler    = symbolHandlers[symbolInfo.BinaryIdentifier];
                        break;

                    case 2014:                             // Time
                        time = packet.GetString(ref ptr);
                        break;

                    case 2015:                             // Date
                        date = packet.GetString(ref ptr);
                        break;

                    case 2002:                             // Last Trade Price
                        handler.Last = packet.GetDouble(ref ptr);
                        if (trace)
                        {
                            log.Trace("Got last trade price: " + handler.Last);                                     // + "\n" + packet);
                        }
                        break;

                    case 2007:                             // Last Trade Size
                        handler.LastSize = packet.GetInt(ref ptr);
                        break;

                    case 2082:                             // Condition
                        int condition = packet.GetInt(ref ptr);
                        if (condition != 0 &&
                            condition != 53 &&
                            condition != 45)
                        {
                            log.Info("Trade quote received with non-zero condition: " + condition);
                        }
                        break;

                    case 2083:                             // Status
                        int status = packet.GetInt(ref ptr);
                        if (status != 0)
                        {
                            log.Info("Trade quote received with non-zero status: " + status);
                        }
                        break;

                    case 2084:                             // Type
                        int type = packet.GetInt(ref ptr);
                        if (type != 0)
                        {
                            log.Info("Trade quote received with non-zero type: " + type);
                        }
                        break;

                    default:
                        packet.SkipValue(ref ptr);
                        break;
                    }
                    if (*(ptr - 1) == 10)
                    {
                        if (UseLocalTickTime)
                        {
                            var currentTime = TimeStamp.UtcNow;
                            if (currentTime <= prevTime)
                            {
                                currentTime.Internal = prevTime.Internal + 1;
                            }
                            prevTime     = currentTime;
                            handler.Time = currentTime;
                        }
                        else
                        {
                            var strings = date.Split(new char[] { '/' });
                            date         = strings[2] + "/" + strings[0] + "/" + strings[1];
                            handler.Time = new TimeStamp(date + " " + time);
                        }
                        if (handler.Last == 0D)
                        {
                            log.Warn("About to call SendTimeAndSales with Last price = zero.");
                        }
                        handler.SendTimeAndSales();
                        data.Position++;
                        return;
                    }
                }
            }

            throw new ApplicationException("Expected Trade Quote to end with new line character.");
        }