Ejemplo n.º 1
0
        public static void Patch()
        {
            try
            {
                QuickLogger.Info($"Started patching. Version: {QuickLogger.GetAssemblyVersion(Assembly.GetExecutingAssembly())}");

#if DEBUG
                QuickLogger.DebugLogsEnabled = true;
                QuickLogger.Debug("Debug logs enabled");
#endif

                GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI.GlobalBundleName);

                Configuration = Mod.LoadConfiguration();

                OptionsPanelHandler.RegisterModOptions(new Options());

                AuxPatchers.AdditionalPatching();

                DSSModelPrefab.GetPrefabs();

                AddTechFabricatorItems();

                var antenna = new AntennaBuildable();
                antenna.Patch();

                //Floor Mounted Rack Has Been Cut
                //var floorMountedRack = new FloorMountedRackBuildable();
                //floorMountedRack.Patch();

                var wallMountedRack = new WallMountedRackBuildable();
                wallMountedRack.Patch();

                var terminal = new DSSTerminalC48Buildable();
                terminal.Patch();

                var serverFormattingStation = new ServerFormattingStationBuildable();
                serverFormattingStation.Patch();

                var harmony = new Harmony("com.datastoragesolutions.fstudios");

                harmony.PatchAll(Assembly.GetExecutingAssembly());

                PatchEasyCraft(harmony);
                PatchToolTipFactory(harmony);

                IsDockedVehicleStorageAccessInstalled = QModServices.Main.ModPresent("DockedVehicleStorageAccess");

                QuickLogger.Info("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error(ex);
            }
        }
        public override GameObject GetGameObject()
        {
            try
            {
                if (DSSModelPrefab.GetPrefabs())
                {
                    var prefab = GameObject.Instantiate(DSSModelPrefab.ServerPrefab);

                    prefab.name = this.PrefabFileName;

                    PrefabIdentifier prefabID = prefab.EnsureComponent <PrefabIdentifier>();
                    prefabID.ClassId = this.ClassID;

                    var techTag = prefab.EnsureComponent <TechTag>();
                    techTag.type = TechType;

                    var center = new Vector3(0f, 0.06423706f, 0.01254272f);
                    var size   = new Vector3(0.3725086f, 0.06717008f, 0.4063118f);

                    GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                    //Make the rigid body isKinematic so it doesnt shake the cyclops
                    var rb = prefab.AddComponent <Rigidbody>();
                    rb.isKinematic = true;

                    // Set collider
                    var collider = prefab.GetComponentInChildren <Collider>();
                    collider.enabled   = true;
                    collider.isTrigger = true;

                    QuickLogger.Debug("Collider");

                    // Make the object drop slowly in water
                    var wf = prefab.EnsureComponent <WorldForces>();
                    wf.underwaterGravity = 0;
                    wf.underwaterDrag    = 10f;
                    wf.enabled           = true;

                    // Add fabricating animation
                    var fabricatingA = prefab.EnsureComponent <VFXFabricating>();
                    fabricatingA.localMinY   = -0.1f;
                    fabricatingA.localMaxY   = 0.6f;
                    fabricatingA.posOffset   = new Vector3(0f, 0f, 0f);
                    fabricatingA.eulerOffset = new Vector3(0f, 0f, 0f);
                    fabricatingA.scaleFactor = 1.0f;

                    //// Set proper shaders (for crafting animation)
                    var renderer = prefab.GetComponentInChildren <Renderer>();


                    // Update sky applier
                    var applier = prefab.EnsureComponent <SkyApplier>();
                    applier.renderers = new Renderer[] { renderer };
                    applier.anchorSky = Skies.Auto;

                    // We can pick this item
                    var pickupable = prefab.EnsureComponent <Pickupable>();
                    pickupable.isPickupable = true;
                    pickupable.randomizeRotationWhenDropped = true;

                    //Allow this kit to be placed on surfaces in these situations
                    var placeTool = prefab.EnsureComponent <PlaceTool>();
                    placeTool.allowedInBase          = true;
                    placeTool.allowedOnBase          = false;
                    placeTool.allowedOnCeiling       = false;
                    placeTool.allowedOnConstructable = true;
                    placeTool.allowedOnGround        = true;
                    placeTool.allowedOnRigidBody     = true;
                    placeTool.allowedOnWalls         = false;
                    placeTool.allowedOutside         = false;
                    placeTool.rotationEnabled        = true;
                    placeTool.enabled              = true;
                    placeTool.hasAnimations        = false;
                    placeTool.hasBashAnimation     = false;
                    placeTool.hasFirstUseAnimation = false;
                    placeTool.mainCollider         = collider;
                    placeTool.pickupable           = pickupable;
                    placeTool.drawTime             = 0.5f;
                    placeTool.dropTime             = 1;
                    placeTool.holsterTime          = 0.35f;
                    prefab.AddComponent <FCSFilteredStorage>();
                    prefab.AddComponent <DSSServerController>();

                    //Add the FCSTechFabricatorTag component
                    prefab.AddComponent <FCSTechFabricatorTag>();

                    return(prefab);
                }
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }
            return(null);
        }