Пример #1
0
 /// <summary>
 /// This method ensures that the text, extraText and price button lists will always match up, even if some buttons don't have extraText / prices
 /// </summary>
 /// <param name="playfieldObject">instance of the playFieldObject to add buttons to</param>
 /// <param name="text">base text for the button</param>
 /// <param name="extraText">extra text for the button</param>
 /// <param name="price">price value for the button</param>
 public static void AddButton(this PlayfieldObject playfieldObject, string text, string extraText = null, int price = 0)
 {
     NormalizeButtons(playfieldObject);
     playfieldObject.buttons.Add(text);
     playfieldObject.buttonsExtra.Add(extraText);
     playfieldObject.buttonPrices.Add(price);
 }
Пример #2
0
 private static void DestroyMe_Prefix(PlayfieldObject damagerObject, ObjectReal __instance)
 {
     logger.LogDebug($"{__instance.name}: {MethodBase.GetCurrentMethod().Name}");
     if (__instance is Stove stove)
     {
         StoveController.RegisterDamagedBy(stove, damagerObject);
     }
 }
Пример #3
0
        public static bool Item_SpecialDamage(PlayfieldObject damagerObject, Item __instance)
        {
            string itemName = __instance.invItem.invItemName;

            if (CustomListDump.customThrowables.Contains(itemName) && damagerObject.CompareTag("Agent"))
            {
                Agent agent = (Agent)damagerObject;

                if (itemName == cItem.BeerCan)
                {
                    GC.audioHandler.Play(agent, vAudioClip.BulletHitObject);
                }
                else if (itemName == cItem.ManholeCover)
                {
                    GC.audioHandler.Play(agent, vAudioClip.MeleeHitAgentLarge);
                }
                else if (itemName == cItem.Sawblade)
                {
                    GC.audioHandler.Play(agent, vAudioClip.SawBladeHit);
                }
                else if (itemName == cItem.ThrowingKnife)
                {
                    GC.audioHandler.Play(agent, vAudioClip.MeleeHitAgentCutSmall2);
                }
                else if (itemName == cItem.WhiskeyBottle)
                {
                    GC.audioHandler.Play(agent, vAudioClip.WindowDamage);
                }
                else
                {
                    GC.audioHandler.Play(agent, vAudioClip.MeleeHitAgentLarge);
                }

                GC.spawnerMain.SpawnParticleEffect("ObjectDestroyed", __instance.tr.position, __instance.tr.eulerAngles.z);

                if (agent.inhuman || agent.mechFilled || agent.mechEmpty)
                {
                    GC.spawnerMain.SpawnParticleEffect("BloodHitYellow", agent.tr.position, __instance.tr.eulerAngles.z);
                    GC.playerAgent.objectMultPlayfield.SpawnParticleEffect("BloodHitYellow", agent.tr.position, __instance.tr.eulerAngles.z, false, agent);
                }
                else
                {
                    GC.spawnerMain.SpawnParticleEffect("BloodHit", agent.tr.position, __instance.tr.eulerAngles.z);
                    GC.playerAgent.objectMultPlayfield.SpawnParticleEffect("BloodHit", agent.tr.position, __instance.tr.eulerAngles.z, false, agent);
                }

                __instance.DestroyMeFromClient();

                return(false);
            }

            return(true);
        }
Пример #4
0
Файл: aToI.cs Проект: zTBBz/aToI
        public static bool PlayfieldObject_FindDamage(PlayfieldObject __instance, PlayfieldObject damagerObject, ref bool generic)
        {
            if (!__instance.isAgent || !damagerObject.isMelee)
            {
                return(true);
            }

            Agent ag = (Agent)__instance;
            Melee me = damagerObject.playfieldObjectMelee;

            if (me.agent != ag && me.invItem.invItemName == "CupOfMoltenChocolate" && !ag.statusEffects.hasStatusEffect("Invincible"))
            {
                me.invItem.database.SubtractFromItemCount(me.invItem, 1);

                ag.knockedOut = ag.knockedOutLocal = true;
                __instance.gc.tileInfo.DirtyWalls();
                ag.lastHitByAgent       = ag.justHitByAgent2 = me.agent;
                ag.healthBeforeKnockout = ag.health;

                ag.deathMethodItem = ag.deathMethodObject = ag.deathMethod = me.invItem.invItemName;
                ag.deathKiller     = me.agent.agentName;

                ag.statusEffects.ChangeHealth(-200f);
                ag.tranqTime = 0;
                string rel = ag.relationships.GetRel(me.agent);
                if (rel != "Aligned" && rel != "Submissive")
                {
                    ag.relationships.SetRel(me.agent, "Hateful");
                    ag.dead = false;
                    ag.relationships.SetRelHate(me.agent, 5);
                    ag.dead = true;
                }

                return(false);
            }
            else if (me.invItem.contents.Exists(c => c.StartsWith("Sharpened:")))
            {
                string sharpenedStr = me.invItem.contents.Find(c => c.StartsWith("Sharpened:"));
                string numStr       = sharpenedStr.Substring("Sharpened:".Length);
                int    num          = int.Parse(numStr);
                me.invItem.contents.Remove(sharpenedStr);
                if (--num > 0)
                {
                    me.invItem.contents.Add("Sharpened:" + num);
                }
                generic = true;

                ag.relationships.SetRel(me.agent, "Hateful");
                ag.relationships.SetRelHate(me.agent, 50);
            }
            return(true);
        }
Пример #5
0
        public static void InvInterface_ShowCursorText(InvInterface __instance, PlayfieldObject myPlayfieldObject)
        {
            __instance.cursorTextString3.color = Color.white;

            CustomItem custom = __instance.mainGUI.targetItem?.GetHook <CustomItem>();

            if (custom is IItemTargetable targetable)
            {
                CustomTooltip tooltip = targetable.TargetCursorText(myPlayfieldObject);
                __instance.cursorTextCanvas3.enabled = !string.IsNullOrEmpty(tooltip.Text);
                __instance.cursorTextString3.text    = tooltip.Text ?? string.Empty;
                __instance.cursorTextString3.color   = tooltip.Color ?? Color.white;
            }
        }
Пример #6
0
 public static void SpawnerMain_SetLighting2(PlayfieldObject myObject)
 {
     if (myObject.CompareTag("ObjectReal"))
     {
         ObjectReal objectReal = (ObjectReal)myObject;
         try { objectReal.spr.GetComponent <Renderer>().sharedMaterial = objectReal.spr.CurrentSprite.material; }
         catch { }
     }
     if (myObject.CompareTag("Item") || myObject.CompareTag("Wreckage"))
     {
         Item item = (Item)myObject;
         try { item.spriteTr.GetComponent <Renderer>().sharedMaterial = item.spr.CurrentSprite.material; }
         catch { }
     }
 }
Пример #7
0
        private static bool BecomeHidden_ShouldDisableHitbox(PlayfieldObject hiddenInObject)
        {
            switch (hiddenInObject.objectName)
            {
            case nameof(ObjectNameDB.rowIds.Bathtub):
            case nameof(ObjectNameDB.rowIds.Plant):
            case nameof(ObjectNameDB.rowIds.TrashCan):
            case nameof(ObjectNameDB.rowIds.PoolTable):
            case nameof(ObjectNameDB.rowIds.TableBig):
                return(true);

            default:
                return(false);
            }
        }
Пример #8
0
        private static void ChangeHealth_Postfix(float healthNum, PlayfieldObject damagerObject, NetworkInstanceId cameFromClient, float clientFinalHealthNum, string damagerObjectName, byte extraVar, StatusEffects __instance)
        {
            // TODO change to transpiler (see todo in Warlord)
            Agent hurtAgent = __instance.agent;

            if (hurtAgent.health <= hurtAgent.healthMax * 0.4f && hurtAgent.health > 0f && hurtAgent.isPlayer == 0 &&
                GameController.gameController.serverPlayer && hurtAgent.CanShakeDown() && hurtAgent.justHitByAgent2 != null &&
                (hurtAgent.justHitByAgent2.isPlayer != 0 || hurtAgent.justHitByAgent2.hasEmployer))
            {
                Agent shakedowningAgent = GameController.gameController.playerAgentList.First(agent => agent.HasTrait <Warlord>());
                if (shakedowningAgent != null)
                {
                    hurtAgent.relationships.SetRel(shakedowningAgent, nameof(relStatus.Submissive));
                    BMHeaderTools.SayDialogue(hurtAgent, cDialogue.WarlordSubmission, vNameType.Dialogue);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// This method removes all buttons from the button-lists with the specified buttonText
        /// </summary>
        /// <param name="playfieldObject">instance of the playfieldObject to remove buttons from</param>
        /// <param name="text">base text of the buttons to remove</param>
        /// <returns>amount of</returns>
        public static int RemoveButton(this PlayfieldObject playfieldObject, string text)
        {
            NormalizeButtons(playfieldObject);
            int removals = 0;

            for (int i = playfieldObject.buttons.Count - 1; i >= 0; i--)
            {
                if (playfieldObject.buttons[i] == text)
                {
                    playfieldObject.buttons.RemoveAt(i);
                    playfieldObject.buttonsExtra.RemoveAt(i);
                    playfieldObject.buttonPrices.RemoveAt(i);
                    removals++;
                }
            }
            return(removals);
        }
Пример #10
0
        public static void TriggerExplosion(Stove stove)
        {
            GameController gc = GameController.gameController;

            if (gc.serverPlayer && !stove.spawnedExplosion)
            {
                stove.spawnedExplosion = true;
                StoveData       stoveData     = GetStoveData(stove);
                PlayfieldObject damagerObject = stoveData.savedDamagerObject;
                Explosion       explosion     = gc.spawnerMain.SpawnExplosion(damagerObject, stove.tr.position, "FireBomb", false, -1, false,
                                                                              stove.FindMustSpawnExplosionOnClients(damagerObject));

                if (stoveData.noOwnCheckCountdown)
                {
                    explosion.noOwnCheck = true;
                }
            }
            gc.audioHandler.Stop(stove, "GeneratorHiss");
        }
Пример #11
0
        private static float BecomeHidden_GetPositionOffset(PlayfieldObject hiddenInObject)
        {
            switch (hiddenInObject.objectName)
            {
            case nameof(ObjectNameDB.rowIds.Bathtub):
                // TODO detect walls here and do case-by-case
                return(0.24f);

            case nameof(ObjectNameDB.rowIds.Plant):
            case nameof(ObjectNameDB.rowIds.TrashCan):
                return(-0.24f);

            case nameof(ObjectNameDB.rowIds.Bush):
            case nameof(ObjectNameDB.rowIds.PoolTable):
            case nameof(ObjectNameDB.rowIds.TableBig):
            default:
                return(0.24f);
            }
        }
Пример #12
0
        protected static void ItemFunctions_TargetObject(InvItem item, Agent agent, PlayfieldObject otherObject, string combineType, ref bool __result)
        {
            CustomItem citem = RogueLibs.Instance.Items.Find(i => i.Id == item.invItemName);

            if (citem?.TargetObject == null)
            {
                return;
            }

            if ((__result = citem.TargetFilter == null || citem.TargetFilter(item, agent, otherObject)) && combineType == "Combine")
            {
                citem.TargetObject(item, agent, otherObject);
                if (item.invItemCount < 1)
                {
                    agent.mainGUI.invInterface.HideDraggedItem();
                    agent.mainGUI.invInterface.HideTarget();
                }
            }
        }
Пример #13
0
 protected static IEnumerator StatusEffects_SpecialAbilityInterfaceCheck2(IEnumerator iEnumerator, StatusEffects __instance)
 {
     while (iEnumerator.MoveNext())
     {
         CustomAbility ability = RogueLibs.GetAbility(__instance.agent?.specialAbility);
         if (ability?.IndicatorCheck != null)
         {
             PlayfieldObject res = ability.IndicatorCheck.Invoke(__instance.agent?.inventory?.equippedSpecialAbility, __instance.agent);
             if (res == null)
             {
                 __instance.agent.specialAbilityIndicator.Revert();
             }
             else
             {
                 __instance.agent.specialAbilityIndicator.ShowIndicator(res, __instance.agent?.specialAbility);
             }
         }
         yield return(iEnumerator.Current);
     }
 }
Пример #14
0
        /// <summary>
        /// This method ensures that there is an equal amount of buttons, buttonsExtra and buttonsPrices on the object
        /// </summary>
        /// <param name="playfieldObject">instance of the playfieldObject to normalize buttons on</param>
        public static void NormalizeButtons(this PlayfieldObject playfieldObject)
        {
            int buttonCount      = playfieldObject.buttons.Count;
            int buttonExtraCount = playfieldObject.buttonsExtra.Count;
            int buttonPriceCount = playfieldObject.buttonPrices.Count;
            int buttonTotal      = Mathf.Max(buttonCount, buttonExtraCount, buttonPriceCount);

            for (int i = buttonCount; i < buttonTotal; i++)
            {
                playfieldObject.buttons.Add(null);
            }

            for (int i = buttonExtraCount; i < buttonTotal; i++)
            {
                playfieldObject.buttonsExtra.Add(null);
            }

            for (int i = buttonPriceCount; i < buttonTotal; i++)
            {
                playfieldObject.buttonPrices.Add(0);
            }
        }
Пример #15
0
        private static string BecomeHidden_GetClipName(PlayfieldObject hiddenInObject)
        {
            switch (hiddenInObject.objectName)
            {
            case nameof(ObjectNameDB.rowIds.Bathtub):
                return(vAudioClip.AgentJoin);

            case nameof(ObjectNameDB.rowIds.PoolTable):
                return(vAudioClip.AgentKnockOut);

            case nameof(ObjectNameDB.rowIds.TableBig):
                return(vAudioClip.AgentKnockout2);

            case nameof(ObjectNameDB.rowIds.TrashCan):
                return(vAudioClip.Hoist);

            case nameof(ObjectNameDB.rowIds.Bush):
            case nameof(ObjectNameDB.rowIds.Plant):
            default:
                return(vAudioClip.Hide);
            }
        }
Пример #16
0
 public bool TargetFilter(PlayfieldObject target) => target is Agent a && a != Owner;
Пример #17
0
        private static void determineMoneyCost_Postfix(int moneyAmt, string transactionType, PlayfieldObject __instance, ref int __result)
        {                        // ↑ [sic]
            logger.LogDebug("PlayfieldObject_determineMoneyCost: transactionType = " + transactionType + "; PFO = " + __instance.name);

            Agent agent              = (Agent)__instance;
            float num                = __result;
            int   levelMultiplier    = Mathf.Clamp(GC.sessionDataBig.curLevelEndless, 1, 15);
            int   gangsizeMultiplier = agent.gangMembers.Count;

            logger.LogDebug("PlayfieldObject_DetermineMoneyCost: num = " + num + "; LevelMult = " + levelMultiplier + "; gangsizeMult = " + gangsizeMultiplier);

            if (transactionType == "Mug_Gangbanger")
            {
                num = (float)(levelMultiplier * 10 + gangsizeMultiplier * 15);
            }
            else if (transactionType == "Hobo_GiveMoney1")
            {
                num = 05f;
            }
            else if (transactionType == "Hobo_GiveMoney2")
            {
                num = 20f;
            }
            else if (transactionType == "Hobo_GiveMoney3")
            {
                num = 50f;
            }
            else
            {
                logger.LogDebug("Bad string passed to PlayfieldObject_determineMoneyCost");
            }

            __result = (int)num;

            logger.LogDebug("PlayfieldObject_determineMoneyCost: result = " + __result);
        }
Пример #18
0
 public static void RegisterDamagedBy(Stove stove, PlayfieldObject damagerObject)
 {
     GetStoveData(stove).savedDamagerObject = damagerObject;
 }
Пример #19
0
        public static bool InvItem_TargetObject(InvItem __instance, PlayfieldObject otherObject, string combineType, ref bool __result)
        {
            bool       debug           = RogueFramework.IsDebugEnabled(DebugFlags.Items);
            bool       actualCombining = combineType == "Combine";
            CustomItem custom          = __instance.GetHook <CustomItem>();

            if (debug && actualCombining)
            {
                RogueFramework.LogDebug($"Targeting {custom} ({__instance.invItemName}) on {otherObject.objectName}:");
            }

            if (Vector2.Distance(__instance.agent.curPosition, otherObject.curPosition) > 15f &&
                InventoryChecks.IsCheckAllowed(custom, "Distance"))
            {
                if (debug && actualCombining)
                {
                    RogueFramework.LogDebug("---- Triggered \"Distance\" inventory check.");
                    RogueFramework.LogDebug("---- Targeting was prevented by an inventory check.");
                }
                __result = false;
                return(false);
            }
            if ((otherObject as Agent)?.butlerBot == true && InventoryChecks.IsCheckAllowed(custom, "ButlerBot"))
            {
                if (debug && actualCombining)
                {
                    RogueFramework.LogDebug("---- Triggered \"ButlerBot\" inventory check.");
                    RogueFramework.LogDebug("---- Targeting was prevented by an inventory check.");
                }
                __result = false;
                return(false);
            }
            if ((otherObject as Agent)?.mechEmpty == true && InventoryChecks.IsCheckAllowed(custom, "EmptyMech"))
            {
                if (debug && actualCombining)
                {
                    RogueFramework.LogDebug("---- Triggered \"EmptyMech\" inventory check.");
                    RogueFramework.LogDebug("---- Targeting was prevented by an inventory check.");
                }
                __result = false;
                return(false);
            }

            __result = custom is IItemTargetable targetable
                                ? targetable.TargetFilter(otherObject)
                                : new ItemFunctions().TargetObject(__instance, __instance.agent, otherObject, string.Empty);

            if (actualCombining)
            {
                OnItemTargetingArgs args = new OnItemTargetingArgs(__instance, otherObject, __instance.agent);
                if (InventoryChecks.onItemTargeting.Raise(args, custom?.ItemInfo.IgnoredChecks))
                {
                    otherObject = args.Target;
                    using (AgentSwapper swapper = new AgentSwapper(__instance, args.User))
                    {
                        if (custom is IItemTargetable targetable2)
                        {
                            bool success = targetable2.TargetObject(otherObject);
                            if (debug)
                            {
                                RogueFramework.LogDebug($"---- Targeting {(success ? "was successful" : "failed")}.");
                            }
                            if (success)
                            {
                                new ItemFunctions().UseItemAnim(__instance, __instance.agent);
                            }
                        }
                        else
                        {
                            if (debug)
                            {
                                RogueFramework.LogDebug("---- Running the original method.");
                            }
                            new ItemFunctions().TargetObject(__instance, __instance.agent, otherObject, "Combine");
                        }

                        if (__instance.invItemCount < 1 || !__instance.database.InvItemList.Contains(__instance) &&
                            InventoryChecks.IsCheckAllowed(custom, "StopOnZero"))
                        {
                            if (debug)
                            {
                                RogueFramework.LogDebug("---- Triggered \"StopOnZero\" inventory check.");
                            }
                            __instance.agent.mainGUI.invInterface.HideDraggedItem();
                            __instance.agent.mainGUI.invInterface.HideTarget();
                        }
                    }
                }
                else
                {
                    if (debug)
                    {
                        RogueFramework.LogDebug("---- Targeting was prevented by an inventory check.");
                    }
                }
            }
            return(false);
        }
Пример #20
0
 private static void FindOperatingTime_Postfix(PlayfieldObject operatingOnObject, float timeToUnlock, Agent __instance, ref float __result)
 {
     __result *= __instance.gc.selectedTimeScale;
 }