コード例 #1
0
 static void Prefix(GhostCrafter __instance, TechType techType)
 {
     if (techType == TechType.Titanium && extraPowerConsumption > 0f)
     {
         CrafterLogic.ConsumeEnergy(__instance.powerRelay, extraPowerConsumption);
     }
 }
コード例 #2
0
        public static void Postfix(GhostCrafter __instance)
        {
            if (__instance.logic.craftingTechType == TechType.Seaglide)
            {
                DeathRun.saveData.runData.updateVehicle(RunData.BEST_SEAGLIDE, RunData.FLAG_SEAGLIDE);
            }

            if (__instance.logic.craftingTechType == TechType.Builder)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_HABITAT);
            }

            if (__instance.logic.craftingTechType == TechType.HatchingEnzymes)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_CURE);
            }

            if (__instance.logic.craftingTechType == TechType.Beacon)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_BEACON);
            }

            if (__instance.logic.craftingTechType == TechType.DiveReel)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_DIVEREEL);
            }

            if (__instance.logic.craftingTechType == TechType.RadiationSuit)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_RADIATION);
            }

            if (__instance.logic.craftingTechType == TechType.ReinforcedDiveSuit)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_REINFORCED);
            }

            if (__instance.logic.craftingTechType == TechType.LaserCutter)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_LASERCUTTER);
            }

            if ((__instance.logic.craftingTechType == TechType.UltraGlideFins) || (__instance.logic.craftingTechType == TechType.SwimChargeFins))
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_ULTRAGLIDE);
            }


            if (__instance.logic.craftingTechType == TechType.DoubleTank)
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_DOUBLETANK);
            }

            if ((__instance.logic.craftingTechType == TechType.HighCapacityTank) || (__instance.logic.craftingTechType == TechType.PlasteelTank))
            {
                DeathRun.saveData.runData.updateVehicle(0, RunData.FLAG_PLASTEEL_TANK);
            }
        }
コード例 #3
0
        public override void Process(GhostCrafterBeginCrafting packet)
        {
            GameObject   gameObject   = NitroxEntity.RequireObjectFrom(packet.GhostCrafterId);
            GhostCrafter ghostCrafter = gameObject.RequireComponentInChildren <GhostCrafter>(true);

            float buildDuration = packet.Duration + 0.2f; // small increase to prevent this player from swiping item from remote player

            ghostCrafter.logic.Craft(packet.TechType.ToUnity(), buildDuration);
        }
コード例 #4
0
        public override void Process(GhostCrafterBeginCrafting packet)
        {
            GameObject   gameObject   = NitroxEntity.RequireObjectFrom(packet.GhostCrafterId);
            GhostCrafter ghostCrafter = gameObject.RequireComponentInChildren <GhostCrafter>(true);

            float buildDuration = packet.Duration + 0.2f; // small increase to prevent this player from swiping item from remote player

            FieldInfo    logic        = typeof(Crafter).GetField("_logic", BindingFlags.Instance | BindingFlags.NonPublic);
            CrafterLogic crafterLogic = (CrafterLogic)logic.GetValue(ghostCrafter);

            crafterLogic.Craft(packet.TechType.ToUnity(), buildDuration);
        }
コード例 #5
0
            static void craftFixEnergyConsumption(GhostCrafter __instance, TechType techType)
            {
                if (!Main.config.bulkCrafting.changePowerConsumption)
                {
                    return;
                }

                if (isAmountChanged(techType))
                {
                    CrafterLogic.ConsumeEnergy(__instance.powerRelay, (currentCraftAmount - 1) * 5f);                     // and 5f also consumed in the vanilla method
                }
            }
コード例 #6
0
 public static void Postfix(GhostCrafter __instance, TechType techType, float duration)
 {
     NitroxServiceLocator.LocateService <Crafting>().GhostCrafterCrafingStarted(__instance.gameObject, techType, duration);
 }
コード例 #7
0
        public override GameObject GetGameObject()
        {
            // Instantiate CyclopsFabricator object
            var fabricatorPrefab = GameObject.Instantiate(Fabricator_Decorations.OriginalFabricator);

            // Update prefab name
            fabricatorPrefab.name = this.ClassID;

            // Add prefab ID
            PrefabIdentifier prefabId = fabricatorPrefab.GetComponent <PrefabIdentifier>();

            if (prefabId == null)
            {
                prefabId = fabricatorPrefab.AddComponent <PrefabIdentifier>();
            }
            prefabId.ClassId = this.ClassID;
            prefabId.name    = LanguageHelper.GetFriendlyWord("DecorationsFabricatorName");

            // Add tech tag
            TechTag techTag = fabricatorPrefab.GetComponent <TechTag>();

            if (techTag == null)
            {
                techTag = fabricatorPrefab.AddComponent <TechTag>();
            }
            techTag.type = this.TechType;

            // Adjust position
            GameObject model = fabricatorPrefab.FindChild("submarine_fabricator_01");

            model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y, model.transform.localPosition.z + 0.035f);

            // Associate custom craft tree to the fabricator
            Fabricator fabricator = fabricatorPrefab.GetComponent <Fabricator>();

            fabricator.craftTree    = this.TreeTypeID;
            fabricator.handOverText = HandOverText;

            // Associate power relay
            GhostCrafter ghost      = fabricator.GetComponent <GhostCrafter>();
            var          powerRelay = new PowerRelay();
            FieldInfo    fieldInfo  = typeof(GhostCrafter).GetField("powerRelay", BindingFlags.NonPublic | BindingFlags.Instance);

            fieldInfo.SetValue(ghost, powerRelay); // This isn't correct, but nothing else seems to work.

            // Set where this can be built.
            Constructable constructible = fabricatorPrefab.GetComponent <Constructable>();

            constructible.allowedInBase           = true;
            constructible.allowedInSub            = true;
            constructible.allowedOutside          = ConfigSwitcher.AllowBuildOutside;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = false;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.techType = this.TechType;

            // Set the custom texture
            SkinnedMeshRenderer skinnedMeshRenderer = fabricatorPrefab.GetComponentInChildren <SkinnedMeshRenderer>();

            skinnedMeshRenderer.material.mainTexture = this.ColoredTexture;

            return(fabricatorPrefab);
        }
コード例 #8
0
        public override GameObject GetGameObject()
        {
            // Instantiate Fabricator object
            var prefab = GameObject.Instantiate(CraftData.GetPrefabForTechType(TechType.Fabricator));

            // Update prefab name
            prefab.name = NameID;

            // Add prefab ID
            PrefabIdentifier prefabId = prefab.GetComponent <PrefabIdentifier>();

            if (prefabId != null)
            {
                prefabId.ClassId = NameID;
                prefabId.name    = this.FriendlyName;
            }

            // Add tech tag
            TechTag techTag = prefab.GetComponent <TechTag>();

            if (techTag != null)
            {
                techTag.type = this.TechType;
            }

            // Update sky applier
            SkyApplier skyApplier = prefab.GetComponent <SkyApplier>();

            skyApplier.renderers = prefab.GetComponentsInChildren <Renderer>();
            skyApplier.anchorSky = Skies.Auto;

            // Associate custom craft tree to the fabricator
            GhostCrafter fabricator = prefab.GetComponent <Fabricator>();

            fabricator.craftTree    = this.TreeTypeID;
            fabricator.handOverText = Language.main.Get(HandOverKey);

            // Modify existing constructable - This is just a modified Fabricator which already had a Constructible component.
            Constructable constructible = prefab.GetComponent <Constructable>();

            constructible.allowedInBase           = true;
            constructible.allowedInSub            = true;
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = false;
            constructible.allowedOnWall           = true;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = false;
            constructible.techType = this.TechType; // This was necessary to correctly associate the recipe at building time

            // Set the custom texture
            Texture2D           customTexture       = ImageUtils.LoadTextureFromFile(@"./QMods/CyclopsNuclearUpgrades/Assets/NuclearFabricatorT.png");
            SkinnedMeshRenderer skinnedMeshRenderer = prefab.GetComponentInChildren <SkinnedMeshRenderer>();

            skinnedMeshRenderer.material.mainTexture = customTexture;

            // Associate power relay
            var powerRelay = new PowerRelay();

            // This is actually a dirty hack
            // The problem is that the parent SubRoot isn't correctly associated at this time.
            // The power relay should be getting set in the GhostCrafter Start() method.
            // But the parent components are coming up null.
            fabricator.powerRelay = powerRelay;

            return(prefab);
        }
コード例 #9
0
        public override GameObject GetGameObject()
        {
            // Instantiate CyclopsFabricator object
            var cyclopsFabPrefab = GameObject.Instantiate(Resources.Load <GameObject>("Submarine/Build/CyclopsFabricator"));

            // Retrieve sub game objects
            GameObject cyclopsFabLight = cyclopsFabPrefab.FindChild("fabricatorLight");
            GameObject cyclopsFabModel = cyclopsFabPrefab.FindChild("submarine_fabricator_03");

            // Update prefab name
            cyclopsFabPrefab.name = NameID;

            // Add prefab ID
            PrefabIdentifier prefabId = cyclopsFabPrefab.AddComponent <PrefabIdentifier>();

            prefabId.ClassId = NameID;
            prefabId.name    = FriendlyName;

            // Add tech tag
            TechTag techTag = cyclopsFabPrefab.AddComponent <TechTag>();

            techTag.type = this.TechType;

            // Translate CyclopsFabricator model and light
            cyclopsFabModel.transform.localPosition = new Vector3(
                cyclopsFabModel.transform.localPosition.x,                                         // Same X position
                cyclopsFabModel.transform.localPosition.y - 0.8f,                                  // Push towards the wall slightly
                cyclopsFabModel.transform.localPosition.z);                                        // Same Z position
            cyclopsFabLight.transform.localPosition = new Vector3(
                cyclopsFabLight.transform.localPosition.x,                                         // Same X position
                cyclopsFabLight.transform.localPosition.y - 0.8f,                                  // Push towards the wall slightly
                cyclopsFabLight.transform.localPosition.z);                                        // Same Z position

            // Update sky applier
            SkyApplier skyApplier = cyclopsFabPrefab.GetComponent <SkyApplier>();

            skyApplier.renderers = cyclopsFabPrefab.GetComponentsInChildren <Renderer>();
            skyApplier.anchorSky = Skies.Auto;

            // Associate custom craft tree to the fabricator
            Fabricator fabricator = cyclopsFabPrefab.GetComponent <Fabricator>();

            fabricator.craftTree    = this.TreeTypeID;
            fabricator.handOverText = HandOverText;

            // Associate power relay
            GhostCrafter ghost      = fabricator.GetComponent <GhostCrafter>();
            var          powerRelay = new PowerRelay(); // This isn't correct, but nothing else seems to work.

            ghost.SetPrivateField("powerRelay", powerRelay);

            // Add constructable - This prefab normally isn't constructed.
            Constructable constructible = cyclopsFabPrefab.AddComponent <Constructable>();

            constructible.allowedInBase           = true;
            constructible.allowedInSub            = true;
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = false;
            constructible.allowedOnWall           = true;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = false;
            constructible.techType = this.TechType; // This was necessary to correctly associate the recipe at building time
            constructible.model    = cyclopsFabModel;

            return(cyclopsFabPrefab);
        }