Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
 public void OnDestroy()
 {
     Patches.Remove();
 }