Beispiel #1
0
        private static void DistrictToggleCheck(UIComponent comp, bool value)
        {
            DebugHelper.Log($"Toggling {comp.name} to {value}");

            DistrictOptions customOptions =
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.TryGetValue(
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID, out var props)
                    ? props
                    : new DistrictOptions();

            if (value)
            {
                customOptions.AllowedDistricts.Add(DistrictHelper.RetrieveDistrictIDFromName(comp.name));
            }
            else
            {
                customOptions.AllowedDistricts.Remove(DistrictHelper.RetrieveDistrictIDFromName(comp.name));
            }

            if (AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.TryGetValue(
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID, out var _))
            {
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions[
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID] = customOptions;
            }
            else
            {
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.Add(AdvancedDistrictOptionsTool.instance.SelectedDistrictID, customOptions);
            }

            foreach (var id in AdvancedDistrictOptionsTool.instance.CustomDistrictOptions[AdvancedDistrictOptionsTool.instance.SelectedDistrictID].AllowedDistricts)
            {
                DebugHelper.Log($"{DistrictManager.instance.GetDistrictName(id)} exists in {DistrictManager.instance.GetDistrictName(AdvancedDistrictOptionsTool.instance.SelectedDistrictID)}'s Allowed List");
            }
        }
Beispiel #2
0
        private static void EventCheck(UIComponent comp, bool value)
        {
            DistrictOptions customOptions =
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.TryGetValue(
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID, out var props)
                    ? props
                    : new DistrictOptions();

            customOptions.GetType().GetField(comp.name)?.SetValue(customOptions, value);

            if (AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.TryGetValue(
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID, out var _))
            {
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions[
                    AdvancedDistrictOptionsTool.instance.SelectedDistrictID] = customOptions;
            }
            else
            {
                AdvancedDistrictOptionsTool.instance.CustomDistrictOptions.Add(AdvancedDistrictOptionsTool.instance.SelectedDistrictID, customOptions);
            }

            DebugHelper.Log($"{comp.name} has been set to {(bool)AdvancedDistrictOptionsTool.instance.CustomDistrictOptions[AdvancedDistrictOptionsTool.instance.SelectedDistrictID].GetType().GetField(comp.name).GetValue(AdvancedDistrictOptionsTool.instance.CustomDistrictOptions[AdvancedDistrictOptionsTool.instance.SelectedDistrictID])} for {DistrictManager.instance.GetDistrictName(AdvancedDistrictOptionsTool.instance.SelectedDistrictID)}");
        }