コード例 #1
0
        static void Postfix(LordJob_FormAndSendCaravan __instance, ref StateGraph __result)
        {
            // This patch modifies the return value of LordJob_FormAndSendCaravan.CreateGraph
            // The CreateGraph function generates a finite state machine that controls caravan formation.
            // Each state is a LordToil.
            // We need to make a few changes to that state machine.

            Traverse tthis        = Traverse.Create(__instance);
            IntVec3  meetingPoint = tthis.Field("meetingPoint").GetValue <IntVec3>();

            // All we need to do is replace the GatherAnimals and GatherSlaves LordToils with our versions.

            // OLD VERSIONS
            LordToil oldGatherAnimals = tthis.Field("gatherAnimals").GetValue <LordToil>();
            LordToil oldGatherSlaves  = tthis.Field("gatherSlaves").GetValue <LordToil>();

            // OUR NEW VERSIONS
            LordToil_BillyCaravan_GatherAnimals billyGatherAnimals = new LordToil_BillyCaravan_GatherAnimals(meetingPoint);
            LordToil_BillyCaravan_GatherSlaves  billyGatherSlaves  = new LordToil_BillyCaravan_GatherSlaves(meetingPoint);

            // REPLACE member variables with new versions
            tthis.Field("gatherAnimals").SetValue(billyGatherAnimals);
            tthis.Field("gatherSlaves").SetValue(billyGatherSlaves);

            // REPLACE states in state machine with new versions
            __result = __result.ReplaceState(oldGatherAnimals, billyGatherAnimals);
            __result = __result.ReplaceState(oldGatherSlaves, billyGatherSlaves);
        }
コード例 #2
0
        private static IEnumerator LoadLegacyPreset(ProfileData preset, PHIBL.PHIBL phIBL)
        {
            yield return(new WaitForSeconds(.1f));

            Profile  profile  = preset.profile;
            float    nipples  = preset.nipples;
            Traverse traverse = Traverse.Create(phIBL);

            traverse.Method("LoadPostProcessingProfile", profile).GetValue();
            DeferredShadingUtils deferredShading = traverse.Field("deferredShading").GetValue <DeferredShadingUtils>();

            PHIBL.AlloyDeferredRendererPlus SSSSS = deferredShading.SSSSS;
            Traverse trav = Traverse.Create(SSSSS);

            trav.Field("TransmissionSettings").SetValue(profile.TransmissionSettings);
            trav.Field("SkinSettings").SetValue(profile.SkinSettings);
            trav.Method("Reset").GetValue();
            traverse.Field("phong").SetValue(profile.phong);
            traverse.Field("edgelength").SetValue(profile.edgeLength);
            DeferredShadingUtils.SetTessellation(profile.phong, profile.edgeLength);
            traverse.Field("nippleSSS").SetValue(nipples);
            Shader.SetGlobalFloat(Shader.PropertyToID("_AlphaSSS"), nipples);
            QualitySettings.shadowDistance   = preset.shadowDistance;
            RenderSettings.reflectionBounces = preset.reflectionBounces;
            ReflectionProbe probe = traverse.Field("probeComponent").GetValue <ReflectionProbe>();

            probe.resolution = preset.probeResolution;
            probe.intensity  = preset.probeIntensity;

            var PPCtrl_obj = traverse.Field("PPCtrl").GetValue <PHIBL.PostProcessing.Utilities.PostProcessingController>();

            PPCtrl_obj.enableDither = preset.enableDithering;

            Console.WriteLine("[PHIBL_PresetLoad] Loaded LEGACY preset");
        }
コード例 #3
0
        public static bool Prefix(Player __instance)
        {
            long         playerID        = __instance.GetPlayerID();
            HardcoreData hardcoreProfile = Hardcore.GetHardcoreDataForProfileID(playerID);

            if (hardcoreProfile != null && hardcoreProfile.isHardcore)
            {
                hardcoreProfile.hasDied = true;

                Traverse tPlayer = Traverse.Create(__instance);
                tPlayer.Field <bool>("m_firstSpawn").Value = true;

                ZNetView nview = tPlayer.Field <ZNetView>("m_nview").Value;
                nview.GetZDO().Set("dead", true);
                nview.InvokeRPC(ZNetView.Everybody, "OnDeath", Array.Empty <object>());
                tPlayer.Method("CreateDeathEffects").GetValue(new object[] { });
                tPlayer.Field <GameObject>("m_visual").Value.SetActive(false);
                tPlayer.Field <List <Player.Food> >("m_foods").Value.Clear();

                __instance.UnequipAllItems();
                __instance.GetInventory().RemoveAll();

                if (Hardcore.Settings.ClearCustomSpawn.Value)
                {
                    Game.instance.GetPlayerProfile().ClearCustomSpawnPoint();
                }
                Game.instance.RequestRespawn(10f);

                Gogan.LogEvent("Game", "Death", "biome: " + __instance.GetCurrentBiome().ToString(), 0L);

                return(false);
            }

            return(true);
        }
コード例 #4
0
        public static bool QEE_BuildingPawnVatGrower_TryMakeClonePrefix(Building __instance)
        {
            try
            {
                string BUID = __instance.GetUniqueLoadID();

                QEE_CheckInitData(__instance);

                ThingOwner to = (ThingOwner)Traverse.Create(__instance).Field("innerContainer").GetValue();

                Thing genome = to.FirstOrDefault(thing => thing.GetType().Name == "GenomeSequence");
                if (genome != null && Utils.ExceptionQEEGS.Contains(genome.def.defName))
                {
                    BodyTypeDef bodyType = BodyTypeDefOf.Female;
                    if (genome.def.defName == "ATPP_GS_TX2KMale" || genome.def.defName == "ATPP_GS_TX3Male" || genome.def.defName == "ATPP_GS_TX4Male")
                    {
                        bodyType = BodyTypeDefOf.Male;
                    }

                    Traverse bas = Traverse.Create(genome);
                    bas.Field("hairColor").SetValue(Utils.getHairColor(Utils.GCATPP.QEEAndroidHairColor[BUID]));
                    bas.Field("skinColor").SetValue(Utils.getSkinColor(Utils.GCATPP.QEESkinColor[BUID]));
                    bas.Field("hair").SetValue(DefDatabase <HairDef> .GetNamed(Utils.GCATPP.QEEAndroidHair[BUID], false));
                    bas.Field("bodyType").SetValue(bodyType);
                }
            }
            catch (Exception e)
            {
                Log.Message("[ATPP] QEE_BuildingPawnVatGrower_TryMakeClonePrefix " + e.Message + " " + e.StackTrace);
            }

            return(true);
        }
コード例 #5
0
        public static bool Prefix(
            TransportPodsArrivalAction_LandInSpecificCell __instance,
            List <ActiveDropPodInfo> pods,
            int tile)
        {
            foreach (ActiveDropPodInfo pod in pods)
            {
                for (int index = 0; index < pod.innerContainer.Count; index++)
                {
                    if (pod.innerContainer[index].TryGetComp <CompLaunchableSRTS>() != null)
                    {
                        Thing    lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods);
                        Traverse traverse   = Traverse.Create((object)__instance);
                        IntVec3  c          = traverse.Field("cell").GetValue <IntVec3>();
                        Map      map        = traverse.Field("mapParent").GetValue <MapParent>().Map;
                        TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(pods);

                        for (int i = 0; i < pods.Count; ++i)
                        {
                            pods[i].openDelay = 0;
                            DropPodUtility.MakeDropPodAt(c, map, pods[i]);
                        }
                        Messages.Message("MessageTransportPodsArrived".Translate(), (LookTargets)lookTarget, MessageTypeDefOf.TaskCompletion, true);
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #6
0
                private static void ApplyColorToBuilding(BuildingComplete building)
                {
                    if (building.name.ToString().StartsWith("BigLiquidStorage") || building.name.ToString().StartsWith("BigGasReservoir"))
                    {
                        KAnimControllerBase kanim = building.GetComponent <KAnimControllerBase>();
                        if (kanim != null)
                        {
                            kanim.TintColour = defaultColor;
                            CaiLib.Logger.Logger.Log(string.Concat("Updating Object Color:", building.name.ToString()));
                        }
                    }

                    if (building.name.ToString().StartsWith("BigSolidStorage") || building.name.ToString().StartsWith("BigBeautifulStorage"))
                    {
                        TreeFilterable treeFilterable = building.GetComponent <TreeFilterable>();
                        if (treeFilterable != null)
                        {
                            Traverse traverse = Traverse.Create(treeFilterable);
                            if (building.name.ToString().StartsWith("BigSolidStorage"))
                            {
                                traverse.Field("filterTint").SetValue(defaultColor);
                            }
                            if (building.name.ToString().StartsWith("BigBeautifulStorage"))
                            {
                                traverse.Field("filterTint").SetValue(beautifulColor);
                            }
                            Tag[] array = traverse.Field <List <Tag> >("acceptedTags").Value.ToArray();
                            treeFilterable.OnFilterChanged(array);
                        }
                    }
                }
コード例 #7
0
            static void Postfix(Boot __instance, ref int ___m_Stage)
            {
                Traverse traverse = Traverse.Create(__instance);

                traverse.Field <bool>("m_SkipVideo").Value = true;
                traverse.Field <VideoPlayer>("m_Video").Value.gameObject.SetActive(false);
            }
    static bool Prefix(MFDVehicleOptions __instance)
    {
        Traverse mfdTraverse = new Traverse(__instance);

        Debug.Log("measurements");
        MeasurementManager measurements = (MeasurementManager)mfdTraverse.Field("measurements").GetValue();

        Debug.Log("mfdPage");
        object  obj1    = mfdTraverse.Field("mfdPage").GetValue();
        MFDPage mfdPage = null;

        if (obj1 != null)
        {
            mfdPage = (MFDPage)obj1;
        }

        Debug.Log("portalPage");
        object        obj2       = mfdTraverse.Field("portalPage").GetValue();
        MFDPortalPage portalPage = null;

        if (obj2 != null)
        {
            portalPage = (MFDPortalPage)obj2;
        }

        Bananaspersecond.speedMode = (Bananaspersecond.speedMode + 1) % Bananaspersecond.units.measurementSpeedUnits.Count;
        Bananaspersecond.UpdateDisplay(measurements, mfdPage, portalPage);
        return(false);
    }
コード例 #9
0
        public static void SavePreset(bool[] pScenes = null, string name = "preset name")
        {
            Traverse trav = Traverse.Create(phIBL);

            ReflectionProbe probe           = trav.Field("probeComponent").GetValue <ReflectionProbe>();
            int             selectedUserLut = trav.Field("selectedUserLut").GetValue <int>();

            PHIBL.PostProcessing.Utilities.PostProcessingController PPCtrl_obj = trav.Field("PPCtrl").GetValue <PHIBL.PostProcessing.Utilities.PostProcessingController>();

            PresetInfo preset = new PresetInfo
            {
                name              = name,
                scenes            = pScenes,
                profile           = phIBL.Snapshot(),
                nipples           = trav.Field("nippleSSS").GetValue <float>(),
                shadowDistance    = QualitySettings.shadowDistance,
                reflectionBounces = RenderSettings.reflectionBounces,
                probeResolution   = probe.resolution,
                probeIntensity    = probe.intensity,
                enabledLUT        = PPCtrl_obj.enableUserLut,
                selectedLUT       = selectedUserLut,
                contributionLUT   = PPCtrl_obj.userLut.contribution,
                enableDithering   = PPCtrl_obj.enableDither
            };

            File.WriteAllBytes(Directory.GetCurrentDirectory() + "\\Plugins\\PHIBL_PresetLoad\\presets\\" + name + ".preset", LZ4MessagePackSerializer.Serialize(preset, CustomCompositeResolver.Instance));

            SetupPresets();

            Console.WriteLine("[PHIBL_PresetLoad] Saved preset: " + name);
        }
コード例 #10
0
            private static void ChangeItem(CustomSelectListCtrl __instance, CustomSelectInfo itemInfo, VirtualListData listData)
            {
                // Calling original whenever possible is probably better for interop since any hooks will run
                if (itemInfo.sic != null)
                {
                    __instance.ChangeItem(itemInfo.sic.gameObject);
                    return;
                }

                __instance.onChangeItemFunc?.Invoke(itemInfo.index);

                var tv = new Traverse(__instance);

                tv.Field <string>("selectDrawName").Value = itemInfo.name;
#if KK
                var tmp = tv.Field <TMPro.TextMeshProUGUI>("textDrawName").Value;
                if (tmp)
                {
                    tmp.text = itemInfo.name;
                }
#endif

                if (VirtualListData.IsItemNew(itemInfo))
                {
                    VirtualListData.MarkItemAsNotNew(itemInfo);
                    MarkListDirty(__instance);
                }

                listData.SelectedItem = itemInfo;
            }
コード例 #11
0
ファイル: ArmsController.cs プロジェクト: Musashi-/Subnautica
        public static void Prefix(ArmsController __instance, PlayerTool tool)
        {
            FullBodyBipedIK ik = VRHandsController.main.ik;

            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = __instance.leftHandElbow;
            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 1f;
            if (tool == null)
            {
                Traverse tInstance = Traverse.Create(__instance);
                tInstance.Field("leftAim").Field("shouldAim").SetValue(false);
                tInstance.Field("rightAim").Field("shouldAim").SetValue(false);

                ik.solver.leftHandEffector.target  = null;
                ik.solver.rightHandEffector.target = null;
                if (!VRHandsController.main.pda.isActiveAndEnabled)
                {
                    Transform leftWorldTarget = tInstance.Field <Transform>("leftWorldTarget").Value;
                    if (leftWorldTarget)
                    {
                        ik.solver.leftHandEffector.target = leftWorldTarget;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = null;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 0f;
                    }

                    Transform rightWorldTarget = tInstance.Field <Transform>("rightWorldTarget").Value;
                    if (rightWorldTarget)
                    {
                        ik.solver.rightHandEffector.target = rightWorldTarget;
                        return;
                    }
                }
            }
        }
コード例 #12
0
    void FixedUpdate()
    {
        lastMessage.UID = networkUID;
        if ((bool)traverse.Field("connected").GetValue() != lastNav || lightsController.strobeLights.onByDefault != lastStrobe || (bool)traverse2.Field("connected").GetValue() != lastLand)
        {
            Debug.Log("The lights on " + networkUID + " have changed, sending");

            lastMessage.nav    = (bool)traverse.Field("connected").GetValue();
            lastMessage.strobe = lightsController.strobeLights.onByDefault;
            if (traverse2 != null)
            {
                lastMessage.strobe = (bool)traverse2.Field("connected").GetValue();
            }

            if (Networker.isHost)
            {
                NetworkSenderThread.Instance.SendPacketAsHostToAllClients(lastMessage, Steamworks.EP2PSend.k_EP2PSendUnreliable);
            }
            else
            {
                NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, lastMessage, Steamworks.EP2PSend.k_EP2PSendUnreliable);
            }

            lastNav    = (bool)traverse.Field("connected").GetValue();
            lastStrobe = lightsController.strobeLights.onByDefault;
            lastLand   = (bool)traverse2.Field("connected").GetValue();
        }
    }
コード例 #13
0
        private static void InitBackpack()
        {
            Dbgl("Initializing backpack.");

            backpack.transform.localPosition = Vector3.zero;
            backpack.name = backpackObjectName;

            if (backpack.GetComponent <WearNTear>())
            {
                Destroy(backpack.GetComponent <WearNTear>());
            }
            if (backpack.GetComponent <Piece>())
            {
                Destroy(backpack.GetComponent <Piece>());
            }
            if (backpack.transform.Find("New"))
            {
                Destroy(backpack.transform.Find("New").gameObject);
            }

            backpack.GetComponent <Container>().m_name = backpackName.Value;
            Traverse tc = Traverse.Create(backpack.GetComponent <Container>());
            Traverse ti = Traverse.Create(tc.Field("m_inventory").GetValue <Inventory>());

            tc.Field("m_nview").GetValue <ZNetView>().ClaimOwnership();
            ti.Field("m_name").SetValue(backpackName.Value);
            ti.Field("m_width").SetValue((int)Math.Min(8, backpackSize.Value.x));
            ti.Field("m_height").SetValue((int)backpackSize.Value.y);
            backpackZDO = backpack.GetComponent <ZNetView>().GetZDO();
            ResetBackpackSector();
        }
    static bool Prefix(AutoPilot __instance)
    {
        if (CheesesAITweaks.settings.controlNoiseEnabled)
        {
            if (CheesesAITweaks.apToHelper.ContainsKey(__instance))
            {
                CheeseAIHelper helper = CheesesAITweaks.apToHelper[__instance];

                Traverse apTraverse = new Traverse(__instance);
                helper.lastAimTarget  = __instance.targetPosition;
                helper.lastRollTarget = apTraverse.Field("overrideRollTarget").GetValue <Vector3>();
                if (helper.CanApplyNoise())
                {
                    Vector3 output = helper.GetControlNoise();
                    __instance.targetPosition += output * (__instance.targetPosition - __instance.referenceTransform.position).magnitude;
                    apTraverse.Field("overrideRollTarget").SetValue(helper.lastRollTarget + output * helper.lastRollTarget.magnitude);

                    float outputThrottle = apTraverse.Field("outputThrottle").GetValue <float>() + helper.GetThottleNoise();
                    if (__instance.controlThrottle)
                    {
                        foreach (ModuleEngine moduleEngine in __instance.engines)
                        {
                            moduleEngine.SetThrottle(outputThrottle);
                        }
                    }
                }
            }
        }
        return(true);
    }
コード例 #15
0
        private static void Postfix(MechComponentRef mechComponent, bool isOnMech, WorkOrderEntry_RepairComponent __result)
        {
            var mech = MechLabPanel_LoadMech.CurrentMech;

            if (mechComponent == null)
            {
                return;
            }

            float tpmod = 1;
            float cbmod = 1;

            Logger.LogDebug($"Module Repair Cost for {mechComponent.ComponentDefID}: ");
            Logger.LogDebug("***************************************");

            foreach (var tag in ArmorRepair.ModSettings.RepairCostByTag)
            {
                if (mech != null && mech.Chassis.ChassisTags.Contains(tag.Tag))
                {
                    Logger.LogDebug($" Chassis {tag.Tag} mods tp:{tag.RepairTPCost:0.00} cb:{tag.RepairCBCost:0.00}");

                    tpmod *= tag.RepairTPCost;
                    cbmod *= tag.RepairCBCost;
                }

                if (mechComponent.Def.ComponentTags.Contains(tag.Tag))
                {
                    Logger.LogDebug($" {mechComponent.ComponentDefID} {tag.Tag} mods tp:{tag.RepairTPCost:0.00} cb:{tag.RepairCBCost:0.00}");
                    tpmod *= tag.RepairTPCost;
                    cbmod *= tag.RepairCBCost;
                }
            }

            if (tpmod != 1 || cbmod != 1)
            {
                var trav = new Traverse(__result);
                if (tpmod != 1)
                {
                    var cost     = trav.Field <int>("Cost");
                    int new_cost = Mathf.CeilToInt(cost.Value * tpmod);
                    Logger.LogDebug($" TP cost: {cost.Value} * {tpmod:0.000} = {new_cost}");
                    cost.Value = new_cost;
                }

                if (cbmod != 1)
                {
                    var cost     = trav.Field <int>("CBillCost");
                    int new_cost = Mathf.CeilToInt(cost.Value * cbmod);
                    Logger.LogDebug($" CBIll cost: {cost.Value} * {cbmod:0.000} = {new_cost}");
                    cost.Value = new_cost;
                }
            }
            else
            {
                Logger.LogDebug(" no need to adjust, return");
            }

            Logger.LogDebug("***************************************");
        }
コード例 #16
0
        public static void ResetHardcorePlayer(PlayerProfile playerProfile)
        {
            Traverse.Create(Player.m_localPlayer)
            .Field <Skills>("m_skills").Value
            .Clear();

            Player.m_localPlayer.GetKnownTexts().RemoveAll((KeyValuePair <string, string> pair) => { return(pair.Key.StartsWith("<|>")); });

            // Clear out custom EquipmentSlotInventory and QuickSlotInventory, if applicable
            AppDomain       currentDomain = AppDomain.CurrentDomain;
            List <Assembly> assemblies    = new List <Assembly>(currentDomain.GetAssemblies());

            if (assemblies.Find((Assembly assembly) => { return(assembly.GetName().Name == "EquipmentAndQuickSlots"); }) != null)
            {
                Component extendedPlayerData = Player.m_localPlayer.GetComponent("ExtendedPlayerData");
                if (extendedPlayerData)
                {
                    Traverse tExtendedPlayerData = Traverse.Create(extendedPlayerData);
                    tExtendedPlayerData.Field <Inventory>("EquipmentSlotInventory").Value.RemoveAll();
                    tExtendedPlayerData.Field <Inventory>("QuickSlotInventory").Value.RemoveAll();
                }
            }
            // End clear custom inventories

            if (Settings.ClearMapOnDeath.Value)
            {
                // Reset sync data for MapSharingMadeEasy to prevent removal of all shared pins on next sync
                ZNetView nview = Traverse.Create(Player.m_localPlayer).Field <ZNetView>("m_nview").Value;
                if (nview != null)
                {
                    string syncData = nview.GetZDO().GetString("playerSyncData", string.Empty);
                    if (!string.IsNullOrEmpty(syncData))
                    {
                        nview.GetZDO().Set("playerSyncData", string.Empty);
                    }
                }
                // End reset sync data

                Traverse tMinimap                   = Traverse.Create(Minimap.instance);
                List <Minimap.PinData> pins         = tMinimap.Field <List <Minimap.PinData> >("m_pins").Value;
                List <Minimap.PinData> pinsToRemove = new List <Minimap.PinData>();
                foreach (Minimap.PinData pin in pins)
                {
                    if (pin.m_save)
                    {
                        pinsToRemove.Add(pin);
                    }
                }
                foreach (Minimap.PinData pinToRemove in pinsToRemove)
                {
                    Minimap.instance.RemovePin(pinToRemove);
                }

                Minimap.instance.Reset();
                Minimap.instance.SaveMapData();
            }
        }
コード例 #17
0
        public MiniFactionPanelHelper(SG_Stores_MiniFactionWidget widget)
        {
            Widget       = widget;
            MainTraverse = new Traverse(widget);

            FactionIcon         = MainTraverse.Field <Image>("FactionIcon").Value;
            FactionTooltip      = MainTraverse.Field <HBSTooltip>("FactionTooltip").Value;
            ratingIcon          = MainTraverse.Field <SGReputationRatingIcon>("ratingIcon").Value;
            ReputationBonusText = MainTraverse.Field <LocalizableText>("ReputationBonusText").Value;
        }
コード例 #18
0
        public static void RotateBoardWithSkater(this BoardController ob)
        {
            Vector3    vector = Mathd.LocalAngularVelocity(PlayerController.Instance.skaterController.skaterRigidbody);
            Quaternion rhs    = Quaternion.AngleAxis(57.29578f * vector.y * Time.deltaTime, PlayerController.Instance.skaterController.skaterTransform.up);

            Traverse   tObj             = Traverse.Create(ob);
            Quaternion bufferedRotation = tObj.Field("_bufferedRotation").GetValue <Quaternion>();

            tObj.Field("_bufferedRotation").SetValue(bufferedRotation * rhs);
        }
コード例 #19
0
                    public FakeHairAccessoryInfo(object _info)
                    {
                        Traverse _traverse = Traverse.Create(_info);

                        HairGloss      = _traverse.Field("HairGloss").GetValue <bool>();
                        ColorMatch     = _traverse.Field("ColorMatch").GetValue <bool>();
                        OutlineColor   = _traverse.Field("OutlineColor").GetValue <Color>();
                        AccessoryColor = _traverse.Field("AccessoryColor").GetValue <Color>();
                        HairLength     = _traverse.Field("HairLength").GetValue <float>();
                    }
コード例 #20
0
ファイル: EnchantHelper.cs プロジェクト: crmos3/LibCraftopia
        public void AddEnchant(params EnchantSetting[] settings)
        {
            var newAllEnchant = allEnchantCache.Concat(TakeOut(settings)).ToArray();

            enchantListTraverse.Field <SoEnchantment[]>("all").Value = newAllEnchant;
            UpdateTreassureProb(settings);
            UpdateStoneProb(settings);
            UpdateTreeProb(settings);
            UpdateUnspecifiedEnemyProb(settings);
            UpdateSpecifiedEnemyProb(settings);
        }
コード例 #21
0
        private void Initilize()
        {
            if (Shop == null)
            {
                Shop  = new Shop();
                ShopT = new Traverse(Shop);
            }

#if CCDEBUG
            if (Tags != null)
            {
                foreach (var item in Tags)
                {
                    Control.LogDebug(DInfo.RefreshShop, "-- " + item);
                }
            }
            else
            {
                Control.LogDebug(DInfo.RefreshShop, "-- Empty");
            }
#endif
            ShopT.Field <SimGameState>("Sim").Value  = UnityGameInstance.BattleTechGame.Simulation;
            ShopT.Field <StarSystem>("system").Value = Control.State.CurrentSystem;
            if (Shop.ItemCollections == null)
            {
                ShopT.Property <List <ItemCollectionDef> >("ItemCollections").Value = new List <ItemCollectionDef>();
            }
            else
            {
                Shop.ItemCollections.Clear();
            }

            if (Tags != null)
            {
                foreach (var item in Tags)
                {
                    try
                    {
                        var col = Control.State.Sim.DataManager.ItemCollectionDefs.Get(item);
                        if (col == null)
                        {
                            Control.LogError("Cannot retrive ItemCollection " + item + ", skipping");
                            continue;
                        }
                        Shop.ItemCollections.Add(col);
                    }
                    catch (Exception e)
                    {
                        Control.LogError("Cannot retrive ItemCollection " + item + ", skipping", e);
                    }
                }
            }
        }
コード例 #22
0
                    public object Convert()
                    {
                        object   _instance = Activator.CreateInstance(_types["HairAccessoryInfo"]);
                        Traverse _traverse = Traverse.Create(_instance);

                        _traverse.Field <bool>("HairGloss").Value       = HairGloss;
                        _traverse.Field <bool>("ColorMatch").Value      = ColorMatch;
                        _traverse.Field <Color>("OutlineColor").Value   = OutlineColor;
                        _traverse.Field <Color>("AccessoryColor").Value = AccessoryColor;
                        _traverse.Field <float>("HairLength").Value     = HairLength;
                        return(_instance);
                    }
コード例 #23
0
        private static void addSteelHeadbutt()
        {
            foreach (ArmorProficiencyGroup ArmorProficiency in new ArmorProficiencyGroup[] { ArmorProficiencyGroup.Heavy, ArmorProficiencyGroup.Medium })
            {
                string              newAssetID = Helpers.getGuid("SteelHeadbuttType" + ArmorProficiency);
                DiceType            diceType   = ArmorProficiency == ArmorProficiencyGroup.Heavy ? DiceType.D4 : DiceType.D3;
                BlueprintWeaponType BlueprintWeaponTypeBite     = library.Get <BlueprintWeaponType>("952e30e6cb40b454789a9db6e5f6dd09");
                BlueprintWeaponType BlueprintWeaponTypeHeadbutt = library.CopyAndAdd(BlueprintWeaponTypeBite, "SteelHeadbuttType" + ArmorProficiency, newAssetID);

                Traverse traverse = Traverse.Create(BlueprintWeaponTypeHeadbutt);
                traverse.Field("m_AssetGuid").SetValue(newAssetID);
                traverse.Field("m_IsNatural").SetValue(false);
                traverse.Field("m_DefaultNameText").SetValue(new FakeLocalizedString("Steel Headbutt"));
                traverse.Field("m_DescriptionText").SetValue(new FakeLocalizedString("While wearing medium or heavy armor, a fighter can deliver a headbutt with his helm as part of a full attack action. This headbutt is in addition to his normal attacks, and is made using the fighter’s base attack bonus – 5. A helmet headbutt deals 1d3 points of damage if the fighter is wearing medium armor, or 1d4 points of damage if he is wearing heavy armor (1d2 and 1d3, respectively, for Small creatures), plus an amount of damage equal to 1/2 the fighter’s Strength modifier. Treat this attack as a weapon attack made using the same special material (if any) as the armor. The armor’s enhancement bonus does modify the headbutt attack."));
                traverse.Field("m_BaseDamage").SetValue(new DiceFormula(1, diceType));


                for (int i = 0; i <= 5; ++i)
                {
                    newAssetID = Helpers.getGuid("SteelHeadbuttType" + ArmorProficiency + "Enhancement" + i);
                    BlueprintItemWeapon BlueprintItemWeaponBite     = library.Get <BlueprintItemWeapon>("35dfad6517f401145af54111be04d6cf");
                    BlueprintItemWeapon BlueprintItemWeaponHeadbutt = library.CopyAndAdd(BlueprintItemWeaponBite, "SteelHeadbuttType" + ArmorProficiency + "Enhancement" + i, newAssetID);

                    traverse = Traverse.Create(BlueprintItemWeaponHeadbutt);
                    traverse.Field("m_AssetGuid").SetValue(newAssetID);
                    traverse.Field("m_Type").SetValue(BlueprintWeaponTypeBite);
                    traverse.Field("SpendCharges").SetValue(false);
                    BlueprintItemWeaponBite.DamageType.Physical.Enhancement      = i;
                    BlueprintItemWeaponBite.DamageType.Physical.EnhancementTotal = i;
                }
            }
        }
コード例 #24
0
 public static bool Prefix(ref Location __instance)
 {
     if (null != __instance)
     {
         Traverse   traverse = HarmonyLib.Traverse.Create(__instance);
         CanUseDoor _playerCanEnterDelegate = traverse.Field <CanUseDoor>("_playerCanEnterDelegate").Value;
         String     _playerCanEnter         = traverse.Field <String>("_playerCanEnter").Value;
         if (null == _playerCanEnterDelegate && null == _playerCanEnter)
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #25
0
        public static async Task Init(EasyAssets __instance, [CanBeNull] IBundleLock bundleLock, string defaultKey, string rootPath, string platformName, [CanBeNull] Func <string, bool> shouldExclude)
        {
            Traverse traverse = Traverse.Create(__instance);
            string   path     = rootPath.Replace("file:///", "").Replace("file://", "") + "/" + platformName + "/";

            AssetBundleCreateRequest manifestLoading = AssetBundle.LoadFromFileAsync(path + platformName);
            await manifestLoading.Await();

            AssetBundle        assetBundle  = manifestLoading.assetBundle;
            AssetBundleRequest assetLoading = assetBundle.LoadAllAssetsAsync();

            await assetLoading.Await();

            traverse.Field <AssetBundleManifest>("Manifest").Value = (AssetBundleManifest)assetLoading.allAssets[0];
            AssetBundleManifest manifest = traverse.Field <AssetBundleManifest>("Manifest").Value;

            //Add ModManifest
            List <string> result = manifest.GetAllAssetBundles().ToList <string>();
            List <string> resourcesModbundles = new List <string>();


            foreach (KeyValuePair <string, BundleInfo> kvp in Settings.bundles)
            {
                resourcesModbundles.Add(kvp.Key);
            }

            string[] bundleNames = result.Union(resourcesModbundles).ToList <string>().ToArray <string>();

            //string[] bundleNames = manifest.GetAllAssetBundles();
            traverse.Field(bundlesFieldName).SetValue(Array.CreateInstance(easyBundleType, bundleNames.Length));
            if (bundleLock == null)
            {
                bundleLock = new BundleLock(int.MaxValue);
            }

            IEasyBundle[] bundles   = traverse.Field(bundlesFieldName).GetValue <IEasyBundle[]>();
            var           startTime = Time.time;

            for (int i = 0; i < bundleNames.Length; i++)
            {
                bundles[i] = (IEasyBundle)Activator.CreateInstance(easyBundleType, new object[] { bundleNames[i], path, manifest, bundleLock });
                await JobScheduler.Yield();
            }

            var endTime = Time.time;

            UnityEngine.Debug.LogError(endTime - startTime);
            traverse.Field(bundlesFieldName).SetValue(bundles);
            traverse.Property <DependencyGraph>("System").Value = new DependencyGraph(bundles, defaultKey, shouldExclude);
        }
 static bool Prefix(AutoPilot __instance, Vector3 rollTarget)
 {
     if (CheesesAITweaks.settings.invertedAI)
     {
         __instance.maxBank = 190;
         Traverse ap = new Traverse(__instance);
         ap.Field("useRollOverride").SetValue(true);
         ap.Field("overrideRollTarget").SetValue(-rollTarget);
         return(false);
     }
     else
     {
         return(true);
     }
 }
        public static bool Prefix(ArmsController __instance)
        {
            if (__instance.smoothSpeed == 0)
            {
                Traverse traverse = Traverse.Create(__instance);
                object   leftAim  = traverse.Field("leftAim").GetValue();
                object   rightAim = traverse.Field("rightAim").GetValue();
                leftAim.ReflectionCall("Update", true, false, __instance.ikToggleTime);
                rightAim.ReflectionCall("Update", true, false, __instance.ikToggleTime);
                __instance.ReflectionCall("UpdateHandIKWeights");

                return(false);
            }
            return(true);
        }
コード例 #28
0
        public static void FixedSwitchPositions(this BoardController ob)
        {
            Traverse tObj         = Traverse.Create(ob);
            float    bufferedFlip = tObj.Field("_bufferedFlip").GetValue <float>();
            float    thirdDelta   = tObj.Field("_thirdDelta").GetValue <float>();

            if (Main.settings.fixedSwitchFlipPositions && PlayerController.Instance.IsSwitch && Main.enabled)
            {
                tObj.Field("_bufferedFlip").SetValue(bufferedFlip - thirdDelta);
            }
            else
            {
                tObj.Field("_bufferedFlip").SetValue(bufferedFlip + thirdDelta);
            }
        }
コード例 #29
0
        /* The user has changed a filter, and we rebuild the item cache. */
        public void FilterChanged(bool resetIndex = true)
        {
            try {
                var iw = new Traverse(inventoryWidget);
                Func <string, bool> f = (n) => iw.Field(n).GetValue <bool>();

                LogDebug(string.Format("[LimitItems] Filter changed (reset? {9}):\n  :weapons {0}\n  :equip {1}\n  :ballistic {2}\n  :energy {3}\n  :missile {4}\n  :small {5}\n  :heatsink {6}\n  :jumpjet {7}\n  :upgrade {8}"
                                       , f("filteringWeapons")
                                       , f("filteringEquipment")
                                       , f("filterEnabledWeaponBallistic")
                                       , f("filterEnabledWeaponEnergy")
                                       , f("filterEnabledWeaponMissile")
                                       , f("filterEnabledWeaponSmall")
                                       , f("filterEnabledHeatsink")
                                       , f("filterEnabledJumpjet")
                                       , f("filterEnabledUpgrade")
                                       , resetIndex));
                if (resetIndex)
                {
                    new Traverse(inventoryWidget).Field("scrollbarArea").GetValue <UnityEngine.UI.ScrollRect>().verticalNormalizedPosition = 1.0f;
                    index = 0;
                }

                filteredInventory = FilterUsingHBSCode(rawInventory);
                endIndex          = filteredInventory.Count - itemsOnScreen;
                Refresh();
            } catch (Exception e) {
                LogException(e);
            }
        }
コード例 #30
0
        public static void Prefix(ref ClanFiefsVM value)
        {
            Traverse traverse             = Traverse.Create((object)value);
            ClanFiefsWithVillageRateVM vm = new ClanFiefsWithVillageRateVM(traverse.Field <Action>("_onRefresh").Value);

            value = vm;
        }