Exemplo n.º 1
0
        public AccountInfoRequest(Platform platform, LookupMethod lookupMethod, IEnumerable <string> queries)
        {
            Platform     = platform;
            LookupMethod = lookupMethod;

            LookupQuery = queries;
        }
Exemplo n.º 2
0
        private static List <GameObjectInfo> LookupID(string id, LookupMethod lookupMethod)
        {
            Func <GameObjectInfo, bool> predicate;

            switch (lookupMethod)
            {
            case LookupMethod.Regex:
                Regex regex = new Regex(id, RegexOptions.CultureInvariant);
                predicate = n => regex.IsMatch(n.FullID);
                break;

            case LookupMethod.Exact:
                predicate = n => n.FullID == id;
                break;

            case LookupMethod.Contains:
                predicate = n => n.FullID.Contains(id);
                break;

            default:
                return(null);
            }

            return(_gameObjectInfos.Where(predicate).ToList());
        }
Exemplo n.º 3
0
        public AccountInfoRequest(Platform platform, LookupMethod lookupMethod, string query)
        {
            Platform     = platform;
            LookupMethod = lookupMethod;

            LookupQuery = new[] { query };
        }
Exemplo n.º 4
0
 public static void SetName(this LookupMethod method, string name, string namingRegex)
 {
     if (!Regex.Match(method.Name, namingRegex).Success)
     {
         return;
     }
     if (method.Il2CppMethod != null)
     {
         method.Il2CppMethod.Name = name;
     }
 }
Exemplo n.º 5
0
        public void TestAccountLookup(string identifier, LookupMethod method, Platform platform = Platform.PC)
        {
            var account = Client.GetUser(platform, method, identifier);

            Assert.IsTrue(method switch
            {
                LookupMethod.Name => identifier.Equals(account.PlayerName, StringComparison.OrdinalIgnoreCase),
                LookupMethod.UserId => identifier.Equals(account.Identifiers.Ubisoft),
                LookupMethod.PlatformId => identifier.Equals(account.Identifiers.Platform),

                _ => throw new ArgumentOutOfRangeException(nameof(method), method, null)
            });
Exemplo n.º 6
0
        /// <summary>
        /// Get multiple users' account info through a mass query search
        /// </summary>
        public static IEnumerable <AccountInfo> GetUsers <T>(this T client, Platform platform, LookupMethod lookupMethod, IEnumerable <string> queries) where T : Dragon6Client
        {
            var request = new AccountInfoRequest(platform, lookupMethod, queries);

            return(client.Perform <JObject>(request).DeserializeAccountInfo());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Get a user's account info (in order to get stats)
 /// </summary>
 public static AccountInfo GetUser <T>(this T client, Platform platform, LookupMethod lookupMethod, string query) where T : Dragon6Client
 => GetUsers(client, platform, lookupMethod, new[] { query }).First();
Exemplo n.º 8
0
        /// <summary>
        /// Execute the activity and look up the flowsheet value.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get Variables
            Guid obdGuid = ObdGuid.Get(context);
            int? patId1  = PatId1.Expression != null?PatId1.Get(context) : (int?)null;

            int?obrId = ObrId.Expression != null?ObrId.Get(context) : (int?)null;

            FlowsheetLookupMethod lookupMethod = LookupMethod.Expression != null
                                               ? LookupMethod.Get(context)
                                               : FlowsheetLookupMethod.Earliest;

            //Lookup entities
            ObsDef obsDefEntity = ObsDef.GetEntityByObdGuid(obdGuid, PM);

            ObsDataValueFormat.Set(context, obsDefEntity.ObsDefDataFormat);

            string queryString;

            switch (lookupMethod)
            {
            case FlowsheetLookupMethod.Earliest:
                queryString = String.Format(EARLIEST_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID);
                break;

            case FlowsheetLookupMethod.Latest:
                queryString = String.Format(LATEST_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID);
                break;


            case FlowsheetLookupMethod.ByObrId:
                queryString = String.Format(OBR_ID_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID, obrId.GetValueOrDefault(0));
                break;

            default:
                throw new InvalidOperationException("Invalid Lookup Operation");
            }

            var pQuery = new PassthruRdbQuery(typeof(Observe), queryString);
            var result = PM.GetEntity <Observe>(pQuery, QueryStrategy.DataSourceOnly);

            //If we didn't find any observations
            if (result == result.NullEntity)
            {
                ObsResultFound.Set(context, false);
                return;
            }

            //Assign output information.
            ObsResultFound.Set(context, true);
            ObsDtTm.Set(context, result.ObsReqTip.Obs_DtTm);
            ObrIdValue.Set(context, result.OBR_SET_ID);

            if (result.ObsReqTip.Obs_DtTm != null)
            {
                // Recalculating for hours since don't want to mess with day calculation
                TimeSpan span = DateTime.Now - result.ObsReqTip.Obs_DtTm.Value;
                AgeInDays.Set(context, span.TotalDays);
                AgeInHours.Set(context, span.TotalHours);
            }

            //Always populate ObsString.  Lab interface may populate this even if the ObsDef type is something
            //different.
            ObsStringValue.Set(context, result.Obs_String);
            if (result.ObsDefEntityOnObsChoice != null && !result.ObsDefEntityOnObsChoice.IsNullEntity)
            {
                ObsChoiceValue.Set(context, result.ObsDefEntityOnObsChoice.OBD_GUID);
            }
            else
            {
                ObsChoiceValue.Set(context, null);
            }

            //Set the appropriate output value.
            switch (result.ObsDefEntity.ObsDefDataFormat)
            {
            case ObsDefDataFormat.CheckBox:
                ObsCheckboxValue.Set(context, (result.Obs_Float == 0) ? false : true);
                break;

            case ObsDefDataFormat.Date:
                ObsDateTimeValue.Set(context, ClarionConversions.DateToDateTime(result.Obs_Float));
                break;

            case ObsDefDataFormat.Time:
                ObsDateTimeValue.Set(context, ClarionConversions.TimeToDateTime(result.Obs_Float));
                break;

            case ObsDefDataFormat.Numeric:
                ObsNumericValue.Set(context, result.Obs_Float);
                break;

            case ObsDefDataFormat.Choice:
            case ObsDefDataFormat.String:
            case ObsDefDataFormat.Memo:
                //Do nothing.  Already string and choice already set set above the switch statement
                break;

            default:
                throw new InvalidOperationException(
                          String.Format(Strings.Error_InvalidObsDefDataFormat,
                                        result.ObsDefEntity.ObsDefDataFormat));
            }
        }
Exemplo n.º 9
0
        internal static void Init(CustomBeatmapData customBeatmapData, float noteLinesDistance)
        {
            List <dynamic> environmentData = Trees.at(customBeatmapData.customData, ENVIRONMENT);

            GetAllGameObjects();
            if (environmentData != null)
            {
                RingRotationOffsets.Clear();
                ParametricBoxControllerParameters.TransformParameters.Clear();

                if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                {
                    ChromaLogger.Log($"=====================================");
                }

                foreach (dynamic gameObjectData in environmentData)
                {
                    string id = Trees.at(gameObjectData, ID);

                    string       lookupString = Trees.at(gameObjectData, LOOKUPMETHOD);
                    LookupMethod lookupMethod = (LookupMethod)Enum.Parse(typeof(LookupMethod), lookupString);

                    int?dupeAmount = (int?)Trees.at(gameObjectData, DUPLICATIONAMOUNT);

                    bool?active = (bool?)Trees.at(gameObjectData, ACTIVE);

                    Vector3?scale         = GetVectorData(gameObjectData, SCALE);
                    Vector3?position      = GetVectorData(gameObjectData, POSITION);
                    Vector3?rotation      = GetVectorData(gameObjectData, OBJECTROTATION);
                    Vector3?localPosition = GetVectorData(gameObjectData, LOCALPOSITION);
                    Vector3?localRotation = GetVectorData(gameObjectData, LOCALROTATION);

                    List <GameObjectInfo> foundObjects = LookupID(id, lookupMethod);
                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"ID [\"{id}\"] using method [{lookupMethod:G}] found:");
                        foundObjects.ForEach(n => ChromaLogger.Log(n.FullID));
                    }

                    List <GameObjectInfo> gameObjectInfos;

                    if (dupeAmount.HasValue)
                    {
                        gameObjectInfos = new List <GameObjectInfo>();
                        foreach (GameObjectInfo gameObjectInfo in foundObjects)
                        {
                            if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                            {
                                ChromaLogger.Log($"Duplicating [{gameObjectInfo.FullID}]:");
                            }

                            GameObject gameObject = gameObjectInfo.GameObject;
                            Transform  parent     = gameObject.transform.parent;
                            Scene      scene      = gameObject.scene;

                            for (int i = 0; i < dupeAmount.Value; i++)
                            {
                                List <IComponentData> componentDatas = new List <IComponentData>();
                                ComponentInitializer.PrefillComponentsData(gameObject.transform, componentDatas);
                                GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject);
                                ComponentInitializer.PostfillComponentsData(newGameObject.transform, gameObject.transform, componentDatas);
                                SceneManager.MoveGameObjectToScene(newGameObject, scene);
                                newGameObject.transform.SetParent(parent, true);
                                ComponentInitializer.InitializeComponents(newGameObject.transform, gameObject.transform, _gameObjectInfos, componentDatas);
                                gameObjectInfos.AddRange(_gameObjectInfos.Where(n => n.GameObject == newGameObject));
                            }
                        }
                    }
                    else
                    {
                        gameObjectInfos = foundObjects;
                    }

                    foreach (GameObjectInfo gameObjectInfo in gameObjectInfos)
                    {
                        GameObject gameObject = gameObjectInfo.GameObject;

                        if (active.HasValue)
                        {
                            gameObjectInfo.GameObject.SetActive(active.Value);
                        }

                        Transform transform = gameObject.transform;

                        if (scale.HasValue)
                        {
                            transform.localScale = scale.Value;
                        }

                        if (position.HasValue)
                        {
                            transform.position = position.Value * noteLinesDistance;
                        }

                        if (rotation.HasValue)
                        {
                            transform.eulerAngles = rotation.Value;
                        }

                        if (localPosition.HasValue)
                        {
                            transform.localPosition = localPosition.Value * noteLinesDistance;
                        }

                        if (localRotation.HasValue)
                        {
                            transform.localEulerAngles = localRotation.Value;
                        }

                        // Handle TrackLaneRing
                        TrackLaneRing trackLaneRing = gameObject.GetComponent <TrackLaneRing>();
                        if (trackLaneRing != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                _positionOffsetAccessor(ref trackLaneRing) = transform.localPosition;
                                _posZAccessor(ref trackLaneRing) = 0;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                RingRotationOffsets[trackLaneRing] = transform.localRotation;
                                _rotZAccessor(ref trackLaneRing) = 0;
                            }
                        }

                        // Handle ParametricBoxController
                        ParametricBoxController parametricBoxController = gameObject.GetComponent <ParametricBoxController>();
                        if (parametricBoxController != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformPosition(parametricBoxController, transform.localPosition);
                            }

                            if (scale.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformScale(parametricBoxController, transform.localScale);
                            }
                        }

                        if (NoodleExtensionsInstalled)
                        {
                            GameObjectTrackController.HandleTrackData(gameObject, gameObjectData, customBeatmapData, noteLinesDistance, trackLaneRing, parametricBoxController);
                        }
                    }

                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"=====================================");
                    }
                }
            }

            LegacyEnvironmentRemoval.Init(customBeatmapData);
        }
        internal static void Init(CustomBeatmapData customBeatmapData, float noteLinesDistance)
        {
            IEnumerable <Dictionary <string, object?> >?environmentData = customBeatmapData.customData.Get <List <object> >(ENVIRONMENT)?.Cast <Dictionary <string, object?> >();

            GetAllGameObjects();

            RingRotationOffsets = new Dictionary <TrackLaneRing, Quaternion>();
            AvoidancePosition   = new Dictionary <BeatmapObjectsAvoidance, Vector3>();
            AvoidanceRotation   = new Dictionary <BeatmapObjectsAvoidance, Quaternion>();
            ParametricBoxControllerParameters.TransformParameters = new Dictionary <ParametricBoxController, ParametricBoxControllerParameters>();

            if (environmentData != null)
            {
                RingRotationOffsets.Clear();
                ParametricBoxControllerParameters.TransformParameters.Clear();

                if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                {
                    Plugin.Logger.Log($"=====================================");
                }

                foreach (Dictionary <string, object?> gameObjectData in environmentData)
                {
                    string id = gameObjectData.Get <string>(ID) ?? throw new InvalidOperationException("Id was not defined.");

                    string       lookupString = gameObjectData.Get <string>(LOOKUPMETHOD) ?? throw new InvalidOperationException("Lookup method was not defined.");
                    LookupMethod lookupMethod = (LookupMethod)Enum.Parse(typeof(LookupMethod), lookupString);

                    int?dupeAmount = gameObjectData.Get <int?>(DUPLICATIONAMOUNT);

                    bool?active = gameObjectData.Get <bool?>(ACTIVE);

                    Vector3?scale         = GetVectorData(gameObjectData, SCALE);
                    Vector3?position      = GetVectorData(gameObjectData, POSITION);
                    Vector3?rotation      = GetVectorData(gameObjectData, OBJECTROTATION);
                    Vector3?localPosition = GetVectorData(gameObjectData, LOCALPOSITION);
                    Vector3?localRotation = GetVectorData(gameObjectData, LOCALROTATION);

                    int?lightID = gameObjectData.Get <int?>(LIGHTID);

                    List <GameObjectInfo> foundObjects = LookupID(id, lookupMethod);
                    if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                    {
                        if (foundObjects.Count > 0)
                        {
                            Plugin.Logger.Log($"ID [\"{id}\"] using method [{lookupMethod:G}] found:");
                            foundObjects.ForEach(n => Plugin.Logger.Log(n.FullID));
                        }
                        else
                        {
                            Plugin.Logger.Log($"ID [\"{id}\"] using method [{lookupMethod:G}] found nothing.", IPA.Logging.Logger.Level.Error);
                        }
                    }

                    List <GameObjectInfo> gameObjectInfos;

                    if (dupeAmount.HasValue)
                    {
                        gameObjectInfos = new List <GameObjectInfo>();
                        foreach (GameObjectInfo gameObjectInfo in foundObjects)
                        {
                            if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                            {
                                Plugin.Logger.Log($"Duplicating [{gameObjectInfo.FullID}]:");
                            }

                            GameObject gameObject = gameObjectInfo.GameObject;
                            Transform  parent     = gameObject.transform.parent;
                            Scene      scene      = gameObject.scene;

                            for (int i = 0; i < dupeAmount.Value; i++)
                            {
                                List <IComponentData> componentDatas = new List <IComponentData>();
                                ComponentInitializer.PrefillComponentsData(gameObject.transform, componentDatas);
                                GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject);
                                ComponentInitializer.PostfillComponentsData(newGameObject.transform, gameObject.transform, componentDatas);
                                SceneManager.MoveGameObjectToScene(newGameObject, scene);
                                newGameObject.transform.SetParent(parent, true);
                                ComponentInitializer.InitializeComponents(newGameObject.transform, gameObject.transform, _gameObjectInfos, componentDatas, lightID);

                                List <GameObjectInfo> gameObjects = _gameObjectInfos.Where(n => n.GameObject == newGameObject).ToList();
                                gameObjectInfos.AddRange(gameObjects);

                                if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                                {
                                    gameObjects.ForEach(n => Plugin.Logger.Log(n.FullID));
                                }
                            }
                        }
                    }
                    else
                    {
                        if (lightID.HasValue)
                        {
                            Plugin.Logger.Log($"LightID requested but no duplicated object to apply to.", IPA.Logging.Logger.Level.Error);
                        }

                        gameObjectInfos = foundObjects;
                    }

                    foreach (GameObjectInfo gameObjectInfo in gameObjectInfos)
                    {
                        GameObject gameObject = gameObjectInfo.GameObject;

                        if (active.HasValue)
                        {
                            gameObjectInfo.GameObject.SetActive(active.Value);
                        }

                        Transform transform = gameObject.transform;

                        if (scale.HasValue)
                        {
                            transform.localScale = scale.Value;
                        }

                        if (position.HasValue)
                        {
                            transform.position = position.Value * noteLinesDistance;
                        }

                        if (rotation.HasValue)
                        {
                            transform.eulerAngles = rotation.Value;
                        }

                        if (localPosition.HasValue)
                        {
                            transform.localPosition = localPosition.Value * noteLinesDistance;
                        }

                        if (localRotation.HasValue)
                        {
                            transform.localEulerAngles = localRotation.Value;
                        }

                        // Handle TrackLaneRing
                        TrackLaneRing trackLaneRing = gameObject.GetComponent <TrackLaneRing>();
                        if (trackLaneRing != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                _positionOffsetAccessor(ref trackLaneRing) = transform.localPosition;
                                _posZAccessor(ref trackLaneRing) = 0;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                RingRotationOffsets[trackLaneRing] = transform.localRotation;
                                _rotZAccessor(ref trackLaneRing) = 0;
                            }
                        }

                        // Handle ParametricBoxController
                        ParametricBoxController parametricBoxController = gameObject.GetComponent <ParametricBoxController>();
                        if (parametricBoxController != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformPosition(parametricBoxController, transform.localPosition);
                            }

                            if (scale.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformScale(parametricBoxController, transform.localScale);
                            }
                        }

                        // Handle BeatmapObjectsAvoidance
                        BeatmapObjectsAvoidance beatmapObjectsAvoidance = gameObject.GetComponent <BeatmapObjectsAvoidance>();
                        if (beatmapObjectsAvoidance != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                AvoidancePosition[beatmapObjectsAvoidance] = transform.localPosition;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                AvoidanceRotation[beatmapObjectsAvoidance] = transform.localRotation;
                            }
                        }

                        GameObjectTrackController.HandleTrackData(gameObject, gameObjectData, customBeatmapData, noteLinesDistance, trackLaneRing, parametricBoxController, beatmapObjectsAvoidance);
                    }

                    if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                    {
                        Plugin.Logger.Log($"=====================================");
                    }
                }
            }

            try
            {
                LegacyEnvironmentRemoval.Init(customBeatmapData);
            }
            catch (Exception e)
            {
                Plugin.Logger.Log("Could not run Legacy Enviroment Removal");
                Plugin.Logger.Log(e);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Get a user's account info (in order to get stats)
 /// </summary>
 public static AccountInfo GetUser <T>(this T client, Platform platform, LookupMethod lookupMethod, string query, CancellationToken token = default) where T : Dragon6Client
 => GetUsers(client, platform, lookupMethod, new[] { query }, token).FirstOrDefault();
        internal static void Init(CustomBeatmapData customBeatmapData, float noteLinesDistance)
        {
            List <dynamic> environmentData = Trees.at(customBeatmapData.customData, "_environment");

            GetAllGameObjects();
            if (environmentData != null)
            {
                SkipRingUpdate = new Dictionary <TrackLaneRing, bool>();

                foreach (dynamic gameObjectData in environmentData)
                {
                    string id = Trees.at(gameObjectData, "_id");

                    string       lookupString = Trees.at(gameObjectData, "_lookupMethod");
                    LookupMethod lookupMethod = (LookupMethod)Enum.Parse(typeof(LookupMethod), lookupString);

                    bool hide = ((bool?)Trees.at(gameObjectData, "_hide")).GetValueOrDefault(false);

                    Vector3?scale         = GetVectorData(gameObjectData, "_scale");
                    Vector3?position      = GetVectorData(gameObjectData, "_position");
                    Vector3?rotation      = GetVectorData(gameObjectData, "_rotation");
                    Vector3?localPosition = GetVectorData(gameObjectData, "_localPosition");
                    Vector3?localRotation = GetVectorData(gameObjectData, "_localRotation");

                    List <GameObjectInfo> foundObjects = LookupID(id, lookupMethod);
                    foreach (GameObjectInfo gameObjectInfo in foundObjects)
                    {
                        GameObject gameObject = gameObjectInfo.GameObject;

                        if (hide)
                        {
                            gameObjectInfo.GameObject.SetActive(false);
                        }

                        Transform transform = gameObject.transform;

                        if (scale.HasValue)
                        {
                            transform.localScale = scale.Value;
                        }

                        if (position.HasValue)
                        {
                            transform.position = position.Value * noteLinesDistance;
                        }

                        if (rotation.HasValue)
                        {
                            transform.eulerAngles = rotation.Value;
                        }

                        if (localPosition.HasValue)
                        {
                            transform.localPosition = localPosition.Value * noteLinesDistance;
                        }

                        if (localRotation.HasValue)
                        {
                            transform.localEulerAngles = localRotation.Value;
                        }

                        // Handle TrackLaneRing
                        TrackLaneRing trackLaneRing = gameObject.GetComponent <TrackLaneRing>();
                        if (trackLaneRing != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                _positionOffsetAccessor(ref trackLaneRing) = transform.position;
                                float zPosition = transform.position.z;
                                _prevPosZAccessor(ref trackLaneRing) = zPosition;
                                _posZAccessor(ref trackLaneRing)     = zPosition;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                float zRotation = transform.rotation.z;
                                _prevRotZAccessor(ref trackLaneRing) = zRotation;
                                _rotZAccessor(ref trackLaneRing)     = zRotation;
                            }
                        }

                        if (Plugin.NoodleExtensionsInstalled && NoodleController.NoodleExtensionsActive)
                        {
                            GameObjectTrackController.HandleTrackData(gameObject, gameObjectData, customBeatmapData, noteLinesDistance, trackLaneRing);
                        }
                    }

                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"ID [\"{id}\"] using method [{lookupMethod.ToString("G")}] found:");
                        foundObjects.ForEach(n => ChromaLogger.Log(n.FullID));
                        ChromaLogger.Log($"=====================================");
                    }
                }
            }

            LegacyEnvironmentRemoval.Init(customBeatmapData);
        }