public static string StationHoverText_Patch(string __result)
        {
            if (!stationHoverLevel.Value)
            {
                return(__result);
            }

            CraftingStation station = Player.m_localPlayer.GetHoverObject()?.GetComponentInParent <CraftingStation>();

            if (station == null)
            {
                return(__result);
            }

            string stationName   = station.m_name;
            string stationLocale = Localization.instance.Localize(stationName);

            if (stationHoverChildLevel.Value)
            {
                if (stationName == "$piece_stonecutter" || stationName == "$piece_artisanstation" || stationName == "$piece_cauldron")
                {
                    return(__result);
                }
            }

            return(__result.Replace(stationLocale, $"{stationLocale} (Level {station.GetLevel()})"));
        }
Esempio n. 2
0
        private void Awake()
        {
            // Do all your init stuff here
            // Acceptable value ranges can be defined to allow configuration via a slider in the BepInEx ConfigurationManager: https://github.com/BepInEx/BepInEx.ConfigurationManager
            Config.Bind <int>("Main Section", "Example configuration integer", 1, new ConfigDescription("This is an example config, using a range limitation for ConfigurationManager", new AcceptableValueRange <int>(0, 100)));

            // Jotunn comes with its own Logger class to provide a consistent Log style for all mods using it
            Jotunn.Logger.LogInfo("ModStub has landed");

            CustomPiece cpHeart    = null;
            CustomPiece cpExpander = null;

            cpHeart.Piece.m_craftingStation = PrefabManager.Cache.GetPrefab <CraftingStation>("piece_workbench");
            CraftingStation customCraftingStation = cpHeart.PiecePrefab.AddComponent <CraftingStation>();

            customCraftingStation.m_name = "$piece_TS_Expander_CS";

            cpExpander.Piece.m_craftingStation = customCraftingStation;
            cpExpander.Piece.m_resources       = new Piece.Requirement[] {
                MockRequirement.Create("Stone", 10),
                MockRequirement.Create("Wood", 10)
            };
            cpExpander.PiecePrefab.AddComponent <CraftingStation>();
            cpExpander.PiecePrefab.GetComponent <CraftingStation>().m_name       = "$piece_TS_Expander_CS";
            cpExpander.PiecePrefab.GetComponent <CraftingStation>().m_rangeBuild = 45; // 50 or 45 - the range is for the player *not* the piece.
        }
        public static bool Prefix(InventoryGui __instance, Player player)
        {
            // if it's not a rune, do the normal flow
            var data = __instance.m_craftRecipe?.m_item?.m_itemData?.GetRuneData();

            if (data == null)
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }
            // if the player does not have the requeriments, do the normal flow
            var qualityLevel = 1;

            if (!player.HaveRequirements(__instance.m_craftRecipe, discover: false, qualityLevel) && !player.NoCostCheat())
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }
            // getting hte spell inventory
            var inv = SpellsBar.invBarGrid.m_inventory;

            // if there is not an 'empty' slot, do the normal flow
            if (!inv.HaveEmptySlot())
            {
                RunicPower.StopCraftingAll(false);
                return(true);
            }

            var        craftItem = __instance.m_craftRecipe.m_item;
            GameObject go        = Object.Instantiate(craftItem.gameObject);
            ItemDrop   item      = go.GetComponent <ItemDrop>();

            item.m_itemData.m_stack       = __instance.m_craftRecipe.m_amount;
            item.m_itemData.m_quality     = qualityLevel;
            item.m_itemData.m_variant     = __instance.m_craftVariant;
            item.m_itemData.m_durability  = item.m_itemData.GetMaxDurability();
            item.m_itemData.m_crafterID   = player.GetPlayerID();
            item.m_itemData.m_crafterName = player.GetPlayerName();

            var crafted = inv.AddItem(item.m_itemData);

            if (crafted)
            {
                if (!player.NoCostCheat())
                {
                    player.ConsumeResources(__instance.m_craftRecipe.m_resources, qualityLevel);
                }
                __instance.UpdateCraftingPanel();
            }
            // displaying some effects
            CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
            var             effs = (currentCraftingStation != null) ? currentCraftingStation.m_craftItemDoneEffects : __instance.m_craftItemDoneEffects;

            effs.Create(player.transform.position, Quaternion.identity);

            Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
            Gogan.LogEvent("Game", "Crafted", __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_name, qualityLevel);

            return(false);
        }
        private static Boolean isValidPlacement()
        {
            bool water = component.m_waterPiece || component.m_noInWater;

            PlayerInstance.m_placementStatus = 0;

            if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly)
            {
                PlayerInstance.m_placementMarkerInstance.SetActive(false);
            }

            StationExtension component2 = component.GetComponent <StationExtension>();

            if (component2 != null)
            {
                CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position);
                if (craftingStation)
                {
                    component2.StartConnectionEffect(craftingStation);
                }
                else
                {
                    component2.StopConnectionEffect();
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; // Missing Station
                }
                if (component2.OtherExtensionInRange(component.m_spaceRequirement))
                {
                    PlayerInstance.m_placementStatus = Player.PlacementStatus.MoreSpace; // More Space
                }
            }

            if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NoTeleportArea;
            }
            if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NotInDungeon;
            }
            if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.NoBuildZone;
            }
            float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f;

            if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, radius, true))
            {
                PlayerInstance.m_placementStatus = Player.PlacementStatus.PrivateZone;
            }

            if (PlayerInstance.m_placementStatus != 0)
            {
                component.SetInvalidPlacementHeightlight(true);
            }
            else
            {
                component.SetInvalidPlacementHeightlight(false);
            }
            return(true);
        }
Esempio n. 5
0
 private static void Postfix(CraftingStation __state, Piece piece)
 {
     if (piece != null && Player.m_localPlayer != null)
     {
         piece.m_craftingStation = __state;
     }
 }
Esempio n. 6
0
        public static void Prefix(InventoryGui __instance)
        {
            if (!Configuration.Current.Player.IsEnabled || !Configuration.Current.Player.autoRepair)
            {
                return;
            }

            CraftingStation curr_crafting_station = Player.m_localPlayer.GetCurrentCraftingStation();

            if (curr_crafting_station != null)
            {
                int repair_count = 0;

                while (__instance.HaveRepairableItems())
                {
                    __instance.RepairOneItem();
                    ++repair_count;
                }

                if (repair_count > 0)
                {
                    curr_crafting_station.m_repairItemDoneEffects.Create(curr_crafting_station.transform.position, Quaternion.identity, null, 1.0f);
                }
            }
        }
Esempio n. 7
0
        // ReSharper disable once UnusedMember.Global
        public static void Prefix(ref Player __instance, CraftingStation station)
        {
            if (station != null)
            {
                // only disable additions. in the case that somebody triggers
                if (!Plugin.Settings.CraftingWithContainersEnabled.Value)
                {
                    return;
                }
                var containersInRange = FindAllowedContainersInCraftingStationRange(__instance, station).ToList();

                Plugin.Log.LogDebug($"{__instance.GetPlayerName()} using {station.name}. " +
                                    $"Expanding with {containersInRange.Count}");
                var effects = Plugin.Settings.ShowStationExtensionEffect.Value
                    ? SpawnEffects(station, containersInRange)
                    : new List <GameObject>();
                InventoryTracker.ExpandedPlayerInventories[__instance.GetInventory().GetHashCode()] =
                    new InventoryTracker.LinkedInventories(__instance, station, containersInRange, effects);
            }
            else
            {
                Plugin.Log.LogDebug($"{__instance.GetPlayerName()} no longer using station, cleaning up");
                if (!InventoryTracker.ExpandedPlayerInventories.TryGetValue(__instance.GetInventory().GetHashCode(), out var linkedInventories))
                {
                    return;
                }

                foreach (var effect in linkedInventories.Effects)
                {
                    Object.Destroy(effect);
                }
                InventoryTracker.ExpandedPlayerInventories.Remove(__instance.GetInventory().GetHashCode());
            }
        }
Esempio n. 8
0
    public bool Craft(CraftingStation craftingStation)
    {
        actionTimer = craftingAnimationTime;
        Lock();
        InCombat = false;

        Equipment.ShowHammer();
        if (lastTrainedSkill != Skill.Crafting)
        {
            lastTrainedSkill = Skill.Crafting;
            playerAnimations.StartCrafting();
            return(true);
        }

        playerAnimations.Craft();

        LookAt(craftingStation.transform);
        if (craftingStation.Craft(this))
        {
            AddExp(craftingStation.GetExperience(this), Skill.Crafting);
            var costs = craftingStation.GetCraftingCost(this);
            RemoveResources(costs);
        }

        return(true);
    }
        public static void Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
        {
            var shippableItem = item.Extended()?.GetComponent <ShippableItemData>();

            var player = __instance as Player;

            if (player == null || (!shippableItem.IsPackaged && !shippableItem.CheckIsPackagable()))
            {
                return;
            }

            UnityEngine.Debug.Log("Station check...");
            if (ShippableMetalBarsConfig.MinimumStationLevel > 0)
            {
                List <CraftingStation> stations = new List <CraftingStation>();
                CraftingStation.FindStationsInRange("forge", (Vector3)player.transform.position, 5f, stations);
                if (!stations.Exists(s => s.GetLevel() >= ShippableMetalBarsConfig.MinimumStationLevel))
                {
                    return;
                }
            }

            if (shippableItem.IsPackaged)
            {
                shippableItem.Unpackage(player, inventory);
            }
            else if (shippableItem.CheckIsPackagable())
            {
                shippableItem.Package(player, inventory);
            }

            return;
        }
Esempio n. 10
0
    // Token: 0x06000F5B RID: 3931 RVA: 0x0006D5B4 File Offset: 0x0006B7B4
    public List <CraftingStation> FindStationsInRange(Vector3 center)
    {
        List <CraftingStation> list = new List <CraftingStation>();

        CraftingStation.FindStationsInRange(this.m_craftingStation.m_name, center, this.m_maxStationDistance, list);
        return(list);
    }
Esempio n. 11
0
        private static void RepairClickedItem(InventoryGrid grid, UIInputHandler element, Inventory inventory)
        {
            Vector2i buttonPos = Traverse.Create(grid).Method("GetButtonPos", new object[] { element.gameObject }).GetValue <Vector2i>();

            ItemDrop.ItemData itemData = inventory.GetItemAt(buttonPos.x, buttonPos.y);

            if (itemData == null)
            {
                return;
            }

            if (Traverse.Create(InventoryGui.instance).Method("CanRepair", new object[] { itemData }).GetValue <bool>())
            {
                CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
                itemData.m_durability = itemData.GetMaxDurability();
                if (currentCraftingStation)
                {
                    currentCraftingStation.m_repairItemDoneEffects.Create(currentCraftingStation.transform.position, Quaternion.identity, null, 1f);
                }
                Player.m_localPlayer.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_repaired", new string[]
                {
                    itemData.m_shared.m_name
                }), 0, null);
            }
        }
Esempio n. 12
0
 private static bool Prefix(ref CraftingStation __instance, ref Player player, ref bool showMessage, ref Boolean __result)
 {
     if (Configuration.Current.Workbench.disableRoofCheck && Configuration.Current.Workbench.IsEnabled)
     {
         __instance.m_craftRequireRoof = false;
     }
     return(true);
 }
 protected void OnDisable()
 {
     if (Station != null)
     {
         Station.OnOutputChanged -= Draw;
         Station = null;
     }
 }
Esempio n. 14
0
 public LinkedInventories(Player player, CraftingStation station, IEnumerable <Container> containers,
                          List <GameObject> effects)
 {
     Player     = player;
     Station    = station;
     Containers = containers;
     Effects    = effects;
 }
Esempio n. 15
0
 internal bool HasRequiredCraftingStationInRange()
 {
     if (originalPiece.m_craftingStation)
     {
         return(CraftingStation.HaveBuildStationInRange(originalPiece.m_craftingStation.m_name, transform.position));
     }
     return(true);
 }
Esempio n. 16
0
        public bool Interact(Humanoid user, bool hold)
        {
            if (hold)
            {
                if (Time.time - m_lastUseTime < m_holdRepeatInterval)
                {
                    return(false);
                }
                m_lastUseTime = Time.time;

                return(AddAllMaterials(user));
            }

            foreach (Piece.Requirement req in originalPiece.m_resources)
            {
                string resourceName = GetResourceName(req);
                if (!PlayerHaveResource(user, resourceName))
                {
                    continue;
                }
                int currentCount = GetResourceCount(resourceName);
                if (currentCount < req.m_amount)
                {
                    m_nView.InvokeRPC("AddResource", resourceName, 1);
                    user.GetInventory().RemoveItem(resourceName, 1);
                    UpdateHoverText();
                    return(true);
                }
            }
            if (!HasAllResources())
            {
                user.Message(MessageHud.MessageType.Center, "$msg_missingrequirement");
                return(false);
            }
            if (user.GetInventory().GetItem("$item_hammer") == null &&
                user.GetInventory().GetItem(PlanHammerPrefabConfig.itemName) == null)
            {
                user.Message(MessageHud.MessageType.Center, "$message_plan_piece_need_hammer");
                return(false);
            }
            if ((bool)originalPiece.m_craftingStation)
            {
                CraftingStation craftingStation = CraftingStation.HaveBuildStationInRange(originalPiece.m_craftingStation.m_name, user.transform.position);
                if (!craftingStation)
                {
                    user.Message(MessageHud.MessageType.Center, "$msg_missingstation");
                    return(false);
                }
            }
            if (!hasSupport)
            {
                user.Message(MessageHud.MessageType.Center, "$message_plan_piece_not_enough_support");
                return(false);
            }
            m_nView.InvokeRPC("Refund", false);
            m_nView.InvokeRPC("SpawnPieceAndDestroy");
            return(false);
        }
Esempio n. 17
0
 private void OnCollisionExit(Collision other)
 {
     if (other.transform.tag == "Craft" && onTable == true)
     {
         cS = other.transform.GetComponent <CraftingStation>();
         cS.RemoveItem(this.gameObject);
         onTable = false;
     }
 }
Esempio n. 18
0
    // Token: 0x0600051B RID: 1307 RVA: 0x0002AD30 File Offset: 0x00028F30
    private void SetupPieceInfo(Piece piece)
    {
        if (piece == null)
        {
            this.m_buildSelection.text   = Localization.instance.Localize("$hud_nothingtobuild");
            this.m_pieceDescription.text = "";
            this.m_buildIcon.enabled     = false;
            for (int i = 0; i < this.m_requirementItems.Length; i++)
            {
                this.m_requirementItems[i].SetActive(false);
            }
            return;
        }
        Player localPlayer = Player.m_localPlayer;

        this.m_buildSelection.text   = Localization.instance.Localize(piece.m_name);
        this.m_pieceDescription.text = Localization.instance.Localize(piece.m_description);
        this.m_buildIcon.enabled     = true;
        this.m_buildIcon.sprite      = piece.m_icon;
        for (int j = 0; j < this.m_requirementItems.Length; j++)
        {
            if (j < piece.m_resources.Length)
            {
                Piece.Requirement req = piece.m_resources[j];
                this.m_requirementItems[j].SetActive(true);
                InventoryGui.SetupRequirement(this.m_requirementItems[j].transform, req, localPlayer, false, 0);
            }
            else
            {
                this.m_requirementItems[j].SetActive(false);
            }
        }
        if (piece.m_craftingStation)
        {
            CraftingStation craftingStation = CraftingStation.HaveBuildStationInRange(piece.m_craftingStation.m_name, localPlayer.transform.position);
            GameObject      gameObject      = this.m_requirementItems[piece.m_resources.Length];
            gameObject.SetActive(true);
            Image     component  = gameObject.transform.Find("res_icon").GetComponent <Image>();
            Text      component2 = gameObject.transform.Find("res_name").GetComponent <Text>();
            Text      component3 = gameObject.transform.Find("res_amount").GetComponent <Text>();
            UITooltip component4 = gameObject.GetComponent <UITooltip>();
            component.sprite  = piece.m_craftingStation.m_icon;
            component2.text   = Localization.instance.Localize(piece.m_craftingStation.m_name);
            component4.m_text = piece.m_craftingStation.m_name;
            if (craftingStation != null)
            {
                craftingStation.ShowAreaMarker();
                component.color  = Color.white;
                component3.text  = "";
                component3.color = Color.white;
                return;
            }
            component.color  = Color.gray;
            component3.text  = "None";
            component3.color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white);
        }
    }
Esempio n. 19
0
    // Token: 0x06000F5D RID: 3933 RVA: 0x0006D5FC File Offset: 0x0006B7FC
    private void PokeEffect()
    {
        CraftingStation craftingStation = this.FindClosestStationInRange(base.transform.position);

        if (craftingStation)
        {
            this.StartConnectionEffect(craftingStation);
        }
    }
Esempio n. 20
0
 public override void Action(GameObject g)
 {
     //if you click on the crafting table with the hammar
     if (g.CompareTag("Craft"))
     {
         CraftingStation craftingStation = g.GetComponent <CraftingStation>();
         craftingStation.Craft();
     }
 }
Esempio n. 21
0
 private static void CraftingStation_Start(CraftingStation __instance, ref List <CraftingStation> ___m_allStations)
 {
     if (__instance.name == "CraftyCarts.CraftingStation")
     {
         if (!___m_allStations.Contains(__instance))
         {
             ___m_allStations.Add(__instance);
         }
     }
 }
Esempio n. 22
0
 private void OnCollisionEnter(Collision collision)
 {
     //if u collide with the crafting table, and ur not on the table
     if (collision.transform.CompareTag("Craft") && !onTable)
     {
         CraftingStation cS = collision.transform.GetComponent <CraftingStation>();
         cS.Add(this.gameObject);
         onTable = true;
     }
 }
Esempio n. 23
0
 private void OnCollisionExit(Collision collision)
 {
     //if u exit  the crafting table, and  on the table
     if (collision.transform.CompareTag("Craft") && onTable)
     {
         CraftingStation cS = collision.transform.GetComponent <CraftingStation>();
         cS.Remove(this.gameObject);
         onTable = false;
     }
 }
Esempio n. 24
0
 // Token: 0x06000F58 RID: 3928 RVA: 0x0006D44C File Offset: 0x0006B64C
 public static void FindExtensions(CraftingStation station, Vector3 pos, List <StationExtension> extensions)
 {
     foreach (StationExtension stationExtension in StationExtension.m_allExtensions)
     {
         if (Vector3.Distance(stationExtension.transform.position, pos) < stationExtension.m_maxStationDistance && stationExtension.m_craftingStation.m_name == station.m_name && !StationExtension.ExtensionInList(extensions, stationExtension))
         {
             extensions.Add(stationExtension);
         }
     }
 }
Esempio n. 25
0
    void OnDisable()
    {
        TargetStation = GetComponent <CraftingStation>();

        if (TargetStation != null)
        {
            TargetStation.OnRecipeChanged  -= RecipeChange;
            TargetStation.OnRecipeOver     -= RecipeDone;
            TargetStation.OnRecipeProgress -= RecipeProgress;
        }
    }
    public void OnRecordPersistentData()
    {
        TargetStation = GetComponent <CraftingStation>();

        VariableName = TargetStation.Name + transform.position.x + transform.position.y;

        DialogueLua.SetVariable(VariableName + "CurrentProgress", TargetStation.CurrentProgress);
        DialogueLua.SetVariable(VariableName + "TargetProgress", TargetStation.TargetProgress);

        DialogueLua.SetVariable(VariableName + "RecipeIndex", TargetStation.RecipeIndex);

        DialogueLua.SetVariable(VariableName + "QueueAmount", TargetStation.Queue.Count);

        for (int i = 0; i < TargetStation.Queue.Count; i++)
        {
            DialogueLua.SetVariable(VariableName + "Queue" + i, TargetStation.Queue[i].UniqueName);
        }
        DialogueLua.SetVariable(VariableName + "ChosenItems", TargetStation.ChosenItems.Count);

        for (int i = 0; i < TargetStation.ChosenItems.Count; i++)
        {
            DialogueLua.SetVariable(VariableName + "ChosenID" + i, TargetStation.ChosenItems[i].ContainedItem.ID);
            DialogueLua.SetVariable(VariableName + "ChosenType", TargetStation.ChosenItems[i].ContainedItem.Type.ToString());
            DialogueLua.SetVariable(VariableName + "ChosenAmount" + i, TargetStation.ChosenItems[i].Amount);
        }

        if (TargetStation.CurrentRecipe != null)
        {
            DialogueLua.SetVariable(VariableName + "CurrentRecipe", TargetStation.CurrentRecipe.UniqueName);
        }
        else
        {
            DialogueLua.SetVariable(VariableName + "CurrentRecipe", "Null");
        }

        DialogueLua.SetVariable(VariableName + "CanProgress", TargetStation.CanProgress);


        DialogueLua.SetVariable(VariableName + "RecipesInInput", TargetStation.RecipesInInput.Count);

        for (int i = 0; i < TargetStation.RecipesInInput.Count; i++)
        {
            DialogueLua.SetVariable(VariableName + "InputName" + i, TargetStation.RecipesInInput[i].UniqueName);
        }

        if (TargetStation.ChosenRecipe != null)
        {
            DialogueLua.SetVariable(VariableName + "ChosenRecipe", TargetStation.ChosenRecipe.UniqueName);
        }
        else
        {
            DialogueLua.SetVariable(VariableName + "ChosenRecipe", "Null");
        }
    }
    public void Open(CraftingStation pStation)
    {
        InventoryUI.CurrentStorage = GameManager.Instance.Player.GetComponent <PlayerInventory>();
        IsOpen  = true;
        Station = pStation;
        Station.OnOutputChanged += Draw;

        Draw(Station);

        Window.Open();
    }
Esempio n. 28
0
        public static void ChangeStationRange(CraftingStation station, float newRange)
        {
            if (station.m_rangeBuild != newRange)
            {
                station.m_rangeBuild = newRange;
                station.m_areaMarker.GetComponent <CircleProjector>().m_radius       = newRange;
                station.m_areaMarker.GetComponent <CircleProjector>().m_nrOfSegments = (int)Math.Ceiling(Math.Max(5f, 4f * newRange));

                logger.LogInfo($"{station.m_name} ({station.GetInstanceID()}) set to {newRange} range");
            }
        }
Esempio n. 29
0
 public static void CraftingStation_Start(ref CraftingStation __instance)
 {
     if (disableWeatherDamageForCraftingStation.Value)
     {
         WearNTear wearNTear = __instance.GetComponent <WearNTear>();
         if (wearNTear)
         {
             wearNTear.m_noRoofWear = false;
         }
     }
 }
Esempio n. 30
0
        public override bool IsAllowedAtThisStation(CraftingStation station)
        {
            if (station == null)
            {
                return(false);
            }

            var isArtisan            = station.m_name == "$piece_artisanstation";
            var isForgeWithEnchanter = station.m_name == "$piece_forge" && station.m_attachedExtensions.Find(x => x.name.StartsWith("piece_enchanter"));

            return(isArtisan || isForgeWithEnchanter);
        }