Пример #1
0
 void Awake()
 {
     Logger.LogInfo("In Awake for SocketAPI Plug-in");
     UnityEngine.Debug.Log("SocketAPI Plug-in loaded");
     ModdingUtils.Initialize(this, this.Logger, true);
     KnownEffects.Invalidate();              // References the KnownEffects class, which triggers its static constructor, which registers our KnownEffectsBuilder before we load any scenes.
     // TODO: Remove SceneManager.sceneLoaded event and the SceneManager_sceneLoaded handler when we have the explorer driver by commands.
     SceneManager.sceneLoaded             += SceneManager_sceneLoaded;
     CreatureManager.OnLineOfSightUpdated += CreatureManager_OnLineOfSightUpdated;
 }
Пример #2
0
        private void SendCallback(IAsyncResult ar)
        {
            try
            {
                Socket socket = (Socket)ar.AsyncState;
                // Complete sending the data to the remote device.
                int bytesSent = socket.EndSend(ar);
                Console.WriteLine("Sent {0} bytes to server.", bytesSent);

                byte[] buffer   = ModdingUtils.ReceiveAll(socket);
                int    bytesRec = buffer.Length;
                string data     = Encoding.UTF8.GetString(buffer, 0, bytesRec);
                oobJson = JsonConvert.DeserializeObject <OOBResponse[]>(data);

                // Retrieve the socket from the state object.
                Socket client = (Socket)ar.AsyncState;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Пример #3
0
 public void CheckOOB()
 {
     foreach (OOBResponse item in oobJson)
     {
         Debug.Log("Board Load ID: " + item.boardLoadId);
         if (!seenMessages.Contains(item.messageid))
         {
             seenMessages.Add(item.messageid);
             if (item.boardLoadId != null)
             {
                 Debug.Log("Got OOB Board load.");
                 Debug.Log(ModdingUtils.LoadBoard(item.boardLoadId));
                 continue;
             }
             SystemMessage.DisplayInfoText(item.handoutUrl, 2.5f);
             StartCoroutine(DownloadImage(item.handoutUrl));
         }
     }
     oobJson = new OOBResponse[] { };
     //ModdingUtils.SendOOBMessage("{\"sessionid\": \"" + CampaignSessionManager.Info.CampaignId + "\", \"type\": \"get\"}", SendCallback);
     ModdingUtils.SendOOBMessage("{\"sessionid\": \"" + CampaignSessionManager.Info.CampaignId + "\", \"type\": \"get\"}", SendCallback);
 }
Пример #4
0
 void Update()
 {
     //Talespire.Camera.ShowPosition();
     ModdingUtils.OnUpdate();
     Talespire.Update();
 }
Пример #5
0
        void Update()
        {
            var board = BoardSessionManager.Board;
            var flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static;

            //Debug.Log("LOS Enabled: " + DistanceLOS.Value);
            if (board != null && DistanceLOS.Value)
            {
                Dictionary <NGuid, CreatureData> creatures = (Dictionary <NGuid, CreatureData>)board.GetType().GetField("_creatures", flags).GetValue(board);
                foreach (KeyValuePair <NGuid, CreatureData> focusCreature in creatures)
                {
                    if (focusCreature.Value.Alias == lineLater.Value)
                    {
                        //Debug.Log("Found Focus");
                        foreach (KeyValuePair <NGuid, CreatureData> entry in creatures)
                        {
                            CreatureBoardAsset creatureBoardAsset;
                            if (PhotonSimpleSingletonBehaviour <CreatureManager> .Instance.TryGetAsset(entry.Value.CreatureId, out creatureBoardAsset))
                            {
                                float distance = Vector3.Distance(entry.Value.Position, focusCreature.Value.Position);
                                //Debug.Log("Distance: " + distance + " Alias: " + entry.Value.Alias + "Pos: " + entry.Value.Position + " FCPos: " + focusCreature.Value.Position);
                                if (distance < LOSDistance.Value)
                                {
                                    creatureBoardAsset.InLineOfSight = true;
                                }
                                else
                                {
                                    creatureBoardAsset.InLineOfSight = false;
                                }
                            }
                        }
                    }
                }
            }
            ModdingUtils.OnUpdate();
            var diffInSeconds = (DateTime.Now - lastCheck).TotalSeconds;

            if (diffInSeconds > 3)
            {
                lastCheck = DateTime.Now;
                CheckOOB();
            }
            var diffInHandoutSeconds = (DateTime.Now - lastHandout).TotalSeconds;

            if (handout && handout.activeSelf && diffInHandoutSeconds > 10)
            {
                handout.SetActive(false);
            }

            if (board != null)
            {
                //Debug.Log("onboard");
                Dictionary <NGuid, CreatureData> creatures = (Dictionary <NGuid, CreatureData>)board.GetType().GetField("_creatures", flags).GetValue(board);
                if (creatures.Count + 1 != lineOfSiteFocusAlias.AcceptableValues.Length && creatures.Count > 0)
                {
                    List <string> charAliases = new List <string>();
                    charAliases.Add("Not Set");
                    foreach (KeyValuePair <NGuid, CreatureData> focusCreature in creatures)
                    {
                        charAliases.Add(focusCreature.Value.Alias);
                    }
                    string tmpVal = lineLater.Value;
                    Config.Remove(lineLater.Definition);
                    lineOfSiteFocusAlias = new AcceptableValueList <String>(charAliases.ToArray());
                    lineLater            = Config.Bind("Line of Sight", "Focused Character", "Not Set", new ConfigDescription("Select the alias to focus on. If not set all characters are in line of sight.", lineOfSiteFocusAlias));
                    lineLater.Value      = tmpVal;
                }
            }

            if (BringPlayersToMe.Value.IsUp())
            {
                PartyManager.SummonAllOnlinePlayersToThisBoard(true, CameraController.Position);
            }

            if (ShowHandout.Value.IsUp())
            {
                SystemMessage.AskForTextInput("Handout URL", "Enter the Handout URL (PNG or JPG Image Only)", "OK", delegate(string name)
                {
                    ModdingUtils.SendOOBMessage("{\"sessionid\": \"" + CampaignSessionManager.Info.CampaignId + "\", \"type\": \"put\", \"handoutUrl\": \"" + name + "\"}", null);
                }, delegate
                {
                }, "Cancel", delegate
                {
                });
            }
        }
Пример #6
0
 //private ModdingUtils mu = new ModdingUtils();
 void Awake()
 {
     UnityEngine.Debug.Log("SetInjectionFlag Plug-in loaded");
     ModdingUtils.Initialize(this);
 }