public void Awake()
        {
            bool attachedPlayer = gameObject.GetComponent <ZNetView>().IsOwner();

            if (attachedPlayer)
            {
                PlanBuild.logger.LogDebug("Removing real textures");
                PlanBuild.showRealTextures = false;
                PlanBuild.UpdateAllPlanPieceTextures();
            }
        }
        public void Register()
        {
            logger.LogDebug("Configuring item drop for PlanCrystal");

            ItemDrop.ItemData.SharedData sharedData = ItemDrop.m_itemData.m_shared;
            sharedData.m_name        = "$item_" + localizationName;
            sharedData.m_description = "$item_" + localizationName + "_description";
            Texture2D    texture      = AssetUtils.LoadTexture(PlanBuild.GetAssetPath(iconPath));
            StatusEffect statusEffect = ScriptableObject.CreateInstance(typeof(StatusEffect)) as StatusEffect;

            statusEffect.m_icon             = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            statusEffect.m_startMessageType = MessageHud.MessageType.Center;
            statusEffect.m_startMessage     = "$message_plan_crystal_start";
            statusEffect.m_stopMessageType  = MessageHud.MessageType.Center;
            statusEffect.m_stopMessage      = "$message_plan_crystal_stop";
            statusEffect.m_startEffects     = new EffectList
            {
                m_effectPrefabs = new EffectList.EffectData[] {
                    new EffectList.EffectData()
                    {
                        m_enabled = true,
                        m_prefab  = startPlanCrystalEffectPrefab,
                        m_attach  = true
                    }
                }
            };
            statusEffect.m_stopEffects = new EffectList
            {
                m_effectPrefabs = new EffectList.EffectData[] {
                    new EffectList.EffectData()
                    {
                        m_enabled = true,
                        m_prefab  = stopPlanCrystalEffectPrefab,
                        m_attach  = true
                    }
                }
            };
            sharedData.m_equipStatusEffect = statusEffect;
            sharedData.m_itemType          = ItemDrop.ItemData.ItemType.Utility;
            sharedData.m_maxStackSize      = 1;
            sharedData.m_centerCamera      = true;
            if (texture == null)
            {
                logger.LogWarning($"planHammer icon not found at {iconPath}");
            }
            else
            {
                sharedData.m_icons = new Sprite[] { Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), Vector2.zero) };
            }
            sharedData.m_maxQuality = 1;
        }
Exemple #3
0
        private void Awake()
        {
            harmony          = new Harmony("marcopogo.PlanBuild");
            Instance         = this;
            logger           = Logger;
            PlanPiece.logger = logger;
            PlanCrystalPrefabConfig.logger = logger;
            PlanPiecePrefabConfig.logger   = logger;
            logger.LogInfo("Harmony patches");
            Patches.Apply(harmony);

            ShaderHelper.planShader = Shader.Find("Lux Lit Particles/ Bumped");

            buildModeHotkeyConfig = base.Config.Bind <string>("General", "Hammer mode toggle Hotkey", "P", new ConfigDescription("Hotkey to switch between Hammer modes", new AcceptableValueList <string>(GetAcceptableKeyCodes())));
            showAllPieces         = base.Config.Bind <bool>("General", "Plan unknown pieces", false, new ConfigDescription("Show all plans, even for pieces you don't know yet"));
            configBuildShare      = base.Config.Bind <bool>("BuildShare", "Place as planned pieces", false, new ConfigDescription("Place .vbuild as planned pieces instead", null, new ConfigurationManagerAttributes {
                IsAdminOnly = true
            }));

            configTransparentGhostPlacement = base.Config.Bind <bool>("Visual", "Transparent Ghost Placement", false, new ConfigDescription("Apply plan shader to ghost placement (currently placing piece)"));

            ShaderHelper.unsupportedColorConfig   = base.Config.Bind <Color>("Visual", "Unsupported color", new Color(1f, 1f, 1f, 0.1f), new ConfigDescription("Color of unsupported plan pieces"));
            ShaderHelper.supportedPlanColorConfig = base.Config.Bind <Color>("Visual", "Supported color", new Color(1f, 1f, 1f, 0.5f), new ConfigDescription("Color of supported plan pieces"));

            ShaderHelper.transparencyConfig = base.Config.Bind <float>("Visual", "Transparency", 0.30f, new ConfigDescription("Additional transparency", new AcceptableValueRange <float>(0f, 1f)));
            ShaderHelper.supportedPlanColorConfig.SettingChanged += UpdateAllPlanPieceTextures;
            ShaderHelper.unsupportedColorConfig.SettingChanged   += UpdateAllPlanPieceTextures;
            ShaderHelper.transparencyConfig.SettingChanged       += UpdateAllPlanPieceTextures;

            buildModeHotkeyConfig.SettingChanged += UpdateBuildKey;
            On.ObjectDB.CopyOtherDB += AddClonedItems;

            PrefabManager.OnPrefabsRegistered += ScanHammer;
            ItemManager.OnItemsRegistered     += OnItemsRegistered;
            PieceManager.OnPiecesRegistered   += LateScanHammer;

            showAllPieces.SettingChanged += UpdateKnownRecipes;

            UpdateBuildKey();
        }