public BioAuxCyclopsManager(SubRoot cyclops) : base(cyclops)
 {
 }
Exemplo n.º 2
0
 public ThermalUpgradeHandler(TechType tier1Id, TechType tier2Id, SubRoot cyclops)
     : base(tier1Id, tier2Id, CyclopsThermalChargerMk2.MaxThermalReached(), cyclops)
 {
 }
Exemplo n.º 3
0
        // Token: 0x06002B9D RID: 11165
        public static bool TryPlace()
        {
            MultiplayerBuilder.Initialize();
            if (MultiplayerBuilder.prefab == null || !MultiplayerBuilder.canPlace)
            {
                return(false);
            }
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();
                component.GhostBase.transform.position = overridePosition;
                component.Place();

                componentInParent.transform.position = overridePosition;

                component.transform.position = overridePosition;
                component.transform.rotation = overrideQuaternion;
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                component.GhostBase.transform.position = overridePosition;

                if (component.TargetBase != null)
                {
                    component.TargetBase.transform.position = overridePosition;
                }
            }
            else
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                bool       flag       = false;
                bool       flag2      = false;
                SubRoot    currentSub = Player.main.GetCurrentSub();
                if (currentSub != null)
                {
                    flag  = currentSub.isBase;
                    flag2 = currentSub.isCyclops;
                    gameObject.transform.parent = currentSub.GetModulesRoot();
                }
                else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
                {
                    SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                    if (componentInParent2 != null)
                    {
                        gameObject.transform.parent = componentInParent2.GetModulesRoot();
                    }
                }
                Transform expr_138 = gameObject.transform;
                expr_138.position = MultiplayerBuilder.placePosition;
                expr_138.rotation = MultiplayerBuilder.placeRotation;
                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                global::Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                componentInParent3.SetIsInside(flag | flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);
                gameObject.transform.position = overridePosition;
                gameObject.transform.rotation = overrideQuaternion;
            }
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }
Exemplo n.º 4
0
        private Optional <VehicleMovementData> GetVehicleMovement()
        {
            Vehicle vehicle = Player.main.GetVehicle();
            SubRoot sub     = Player.main.GetCurrentSub();

            NitroxId   id;
            Vector3    position;
            Quaternion rotation;
            Vector3    velocity;
            Vector3    angularVelocity;
            TechType   techType;
            float      steeringWheelYaw = 0f, steeringWheelPitch = 0f;
            bool       appliedThrottle  = false;
            Vector3    leftArmPosition  = new Vector3(0, 0, 0);
            Vector3    rightArmPosition = new Vector3(0, 0, 0);

            if (vehicle != null)
            {
                id       = NitroxEntity.GetId(vehicle.gameObject);
                position = vehicle.gameObject.transform.position;
                rotation = vehicle.gameObject.transform.rotation;
                techType = CraftData.GetTechType(vehicle.gameObject);

                Rigidbody rigidbody = vehicle.gameObject.GetComponent <Rigidbody>();

                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;

                // Required because vehicle is either a SeaMoth or an Exosuit, both types which can't see the fields either.
                steeringWheelYaw   = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelYaw");
                steeringWheelPitch = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelPitch");

                // Vehicles (or the SeaMoth at least) do not have special throttle animations. Instead, these animations are always playing because the player can't even see them (unlike the cyclops which has cameras).
                // So, we need to hack in and try to figure out when thrust needs to be applied.
                if (vehicle && AvatarInputHandler.main.IsEnabled())
                {
                    if (techType == TechType.Seamoth)
                    {
                        bool flag = vehicle.transform.position.y < Ocean.main.GetOceanLevel() && vehicle.transform.position.y < vehicle.worldForces.waterDepth && !vehicle.precursorOutOfWater;
                        appliedThrottle = flag && GameInput.GetMoveDirection().sqrMagnitude > .1f;
                    }
                    else if (techType == TechType.Exosuit)
                    {
                        Exosuit exosuit = vehicle as Exosuit;
                        if (exosuit)
                        {
                            appliedThrottle = (bool)exosuit.ReflectionGet("_jetsActive") && (float)exosuit.ReflectionGet("thrustPower") > 0f;

                            Transform leftAim  = (Transform)exosuit.ReflectionGet("aimTargetLeft", true);
                            Transform rightAim = (Transform)exosuit.ReflectionGet("aimTargetRight", true);

                            Vector3 eulerAngles = exosuit.transform.eulerAngles;
                            eulerAngles.x = MainCamera.camera.transform.eulerAngles.x;
                            Quaternion quaternion = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);

                            leftArmPosition  = leftAim.transform.position = MainCamera.camera.transform.position + quaternion * Vector3.forward * 100f;
                            rightArmPosition = rightAim.transform.position = MainCamera.camera.transform.position + quaternion * Vector3.forward * 100f;
                        }
                    }
                }
            }
            else if (sub != null && Player.main.isPiloting)
            {
                id       = NitroxEntity.GetId(sub.gameObject);
                position = sub.gameObject.transform.position;
                rotation = sub.gameObject.transform.rotation;
                Rigidbody rigidbody = sub.GetComponent <Rigidbody>();
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                techType        = TechType.Cyclops;

                SubControl subControl = sub.GetComponent <SubControl>();
                steeringWheelYaw   = (float)subControl.ReflectionGet("steeringWheelYaw");
                steeringWheelPitch = (float)subControl.ReflectionGet("steeringWheelPitch");
                appliedThrottle    = subControl.appliedThrottle && (bool)subControl.ReflectionGet("canAccel");
            }
            else
            {
                return(Optional.Empty);
            }

            VehicleMovementData model = VehicleMovementFactory.GetVehicleMovementData(techType,
                                                                                      id,
                                                                                      position,
                                                                                      rotation,
                                                                                      velocity,
                                                                                      angularVelocity,
                                                                                      steeringWheelYaw,
                                                                                      steeringWheelPitch,
                                                                                      appliedThrottle,
                                                                                      leftArmPosition,
                                                                                      rightArmPosition);

            return(Optional.Of(model));
        }
Exemplo n.º 5
0
 public ChargeManager(SubRoot cyclops)
 {
     Cyclops = cyclops;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Set the health of a <see cref="CyclopsDamagePoint"/>. This can trigger sending <see cref="CyclopsDamagePointRepaired"/> packets
 /// </summary>
 /// <param name="repairAmount">The max health of the point is 1. 999 is passed to trigger a full repair of the <see cref="CyclopsDamagePoint"/></param>
 private void RepairDamagePoint(SubRoot subRoot, int damagePointIndex, float repairAmount)
 {
     subRoot.damageManager.damagePoints[damagePointIndex].liveMixin.AddHealth(repairAmount);
 }
Exemplo n.º 7
0
 internal UpgradeManager(SubRoot cyclops) : base(cyclops)
 {
     engineRoomUpgradeConsole = Cyclops.upgradeConsole.modules;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AmbientEnergyCharger{T}"/> class.
 /// </summary>
 /// <param name="tier1TechType">TechType value for the tier 1 upgrade module for this charger.</param>
 /// <param name="tier2TechType">TechType value for the tier 2 upgrade module for this charger.</param>
 /// <param name="cyclops">The cyclops reference.</param>
 protected AmbientEnergyCharger(TechType tier1TechType, TechType tier2TechType, SubRoot cyclops) : base(cyclops)
 {
     tier1Id     = tier1TechType;
     tier2Id2    = tier2TechType;
     tier1Sprite = SpriteManager.Get(tier1TechType);
     tier2Sprite = SpriteManager.Get(tier2TechType);
 }
Exemplo n.º 9
0
        private Optional <VehicleModel> GetVehicleModel()
        {
            Vehicle vehicle = Player.main.GetVehicle();
            SubRoot sub     = Player.main.GetCurrentSub();

            string     guid;
            Vector3    position;
            Quaternion rotation;
            Vector3    velocity;
            Vector3    angularVelocity;
            TechType   techType;
            float      steeringWheelYaw = 0f, steeringWheelPitch = 0f;
            bool       appliedThrottle = false;

            if (vehicle != null)
            {
                guid     = GuidHelper.GetGuid(vehicle.gameObject);
                position = vehicle.gameObject.transform.position;
                rotation = vehicle.gameObject.transform.rotation;
                techType = CraftData.GetTechType(vehicle.gameObject);

                Rigidbody rigidbody = vehicle.gameObject.GetComponent <Rigidbody>();

                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;

                // Required because vehicle is either a SeaMoth or an Exosuit, both types which can't see the fields either.
                steeringWheelYaw   = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelYaw");
                steeringWheelPitch = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelPitch");

                // Vehicles (or the SeaMoth at least) do not have special throttle animations. Instead, these animations are always playing because the player can't even see them (unlike the cyclops which has cameras).
                // So, we need to hack in and try to figure out when thrust needs to be applied.
                if (vehicle && AvatarInputHandler.main.IsEnabled())
                {
                    if (techType == TechType.Seamoth)
                    {
                        bool flag = vehicle.transform.position.y < Ocean.main.GetOceanLevel() && vehicle.transform.position.y < vehicle.worldForces.waterDepth && !vehicle.precursorOutOfWater;
                        appliedThrottle = flag && GameInput.GetMoveDirection().sqrMagnitude > .1f;
                    }
                    else if (techType == TechType.Exosuit)
                    {
                        Exosuit exosuit = vehicle as Exosuit;
                        if (exosuit)
                        {
                            appliedThrottle = (bool)exosuit.ReflectionGet("_jetsActive") && (float)exosuit.ReflectionGet("thrustPower") > 0f;
                        }
                    }
                }
            }
            else if (sub != null && Player.main.isPiloting)
            {
                guid     = GuidHelper.GetGuid(sub.gameObject);
                position = sub.gameObject.transform.position;
                rotation = sub.gameObject.transform.rotation;
                Rigidbody rigidbody = sub.GetComponent <Rigidbody>();
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                techType        = TechType.Cyclops;

                SubControl subControl = sub.GetComponent <SubControl>();
                steeringWheelYaw   = (float)subControl.ReflectionGet("steeringWheelYaw");
                steeringWheelPitch = (float)subControl.ReflectionGet("steeringWheelPitch");
                appliedThrottle    = subControl.appliedThrottle && (bool)subControl.ReflectionGet("canAccel");
            }
            else
            {
                return(Optional <VehicleModel> .Empty());
            }

            VehicleModel model = new VehicleModel(techType,
                                                  guid,
                                                  position,
                                                  rotation,
                                                  velocity,
                                                  angularVelocity,
                                                  steeringWheelYaw,
                                                  steeringWheelPitch,
                                                  appliedThrottle);

            return(Optional <VehicleModel> .Of(model));
        }
Exemplo n.º 10
0
 public static bool Prefix(SubRoot __instance, DamageInfo damageInfo)
 {
     return(NitroxServiceLocator.LocateService <SimulationOwnership>().HasAnyLockType(NitroxIdentifier.GetId(__instance.gameObject)));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CyclopsStatusIcon"/> class.
 /// </summary>
 /// <param name="cyclops">The cyclops.</param>
 protected CyclopsStatusIcon(SubRoot cyclops)
 {
     Cyclops = cyclops;
 }
Exemplo n.º 12
0
        private void DrawCyclopsDebugMenu()
        {
            if (GUILayout.Button("Destroy Cyclops static mesh"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        Transform transform = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic");
                        Log.Print("Size 1: " + transform.GetComponentInChildren <MeshFilter>().mesh.triangles.Length);
                        Log.Print("Size 2: " + transform.GetComponentInChildren <MeshFilter>().mesh.vertices.Length);
                        Destroy(transform.gameObject);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Engine RPM SFX Manager"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        EngineRpmSFXManager engine = raycastHit4.rigidbody.GetComponentInChildren <EngineRpmSFXManager>();
                        if (engine == null)
                        {
                            Utilities.Log.Print("EngineRpmSFXManager not found");
                            return;
                        }

                        Log.Print("engineRpmSFX: " + engine.engineRpmSFX?.asset?.path);
                        Log.Print("stopSoundInterval: " + engine.engineRpmSFX?.stopSoundInterval);
                        Log.Print("engineRevUp: " + engine.engineRevUp?.asset?.path);
                        Log.Print("rampUpSpeed: " + engine.rampUpSpeed);
                        Log.Print("rampDownSpeed: " + engine.rampDownSpeed);
                    }
                }
            }

            if (GUILayout.Button("Cyclops render materials"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior");
                        Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("Cyclops_submarine_exterior_glass");
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior_decals");
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0");

                        /*foreach (MeshRenderer mr in gggg1.gameObject.GetComponentsInChildren<MeshRenderer>())
                         * {
                         *  Utilities.Log.Print("Gameobject: " + mr.gameObject.name);
                         *  foreach (Material mat2 in mr.materials)
                         *  {
                         *      Utilities.Log.Print("Material: " + mat2.name);
                         *      Utilities.Log.Print("keywords: " + mat2.shaderKeywords.Length);
                         *      foreach(var s in mat2.shaderKeywords)
                         *      {
                         *          Utilities.Log.Print("Keyword: " + s);
                         *      }
                         *      Utilities.Log.Print("-");
                         *  }
                         *  Utilities.Log.Print("--");
                         * }*/

                        Log.Print("Materials count: " + gggg1.GetComponent <MeshRenderer>().materials.Length);
                        Material mat = gggg1.GetComponent <MeshRenderer>().material;
                        mat.PrintAllMarmosetUBERShaderProperties();
                    }
                }
            }

            if (GUILayout.Button("Cyclops Oxygen Manager"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        OxygenManager[] oxygenManager = raycastHit4.rigidbody.GetComponentsInChildren <OxygenManager>();
                        Log.Print("Oxygen Manager Found Count " + oxygenManager.Length);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Depth Cleaer"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        SubRoot      subRoot = raycastHit4.rigidbody.GetComponent <SubRoot>();
                        MeshRenderer mr      = subRoot.depthClearer as MeshRenderer;
                        Log.Print("DepthClearer type: " + subRoot.depthClearer.GetType());
                        Log.Print("DepthClearer name: " + subRoot.depthClearer.name);
                        Log.Print("DepthClearer material: " + subRoot.depthClearer.material);
                        Log.Print("DepthClearer mesh: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh);
                        Log.Print("DepthClearer mesh name: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh.name);
                        Log.Print("DepthClearer Children count: " + subRoot.depthClearer.transform.childCount);
                        Log.Print("DepthClearer transform pos: " + subRoot.depthClearer.transform.localPosition);
                        Log.Print("DepthClearer transform size: " + subRoot.depthClearer.transform.localScale);
                        Log.Print("DepthClearer transform Parent: " + subRoot.depthClearer.transform.parent?.name);
                        subRoot.depthClearer.material.color = new Color(1f, 0f, 0f, 1f);
                        Log.Print("DepthClearer mat color: " + subRoot.depthClearer.material.color);
                        Log.Print("DepthClearer enabled?: " + subRoot.depthClearer.enabled);

                        Log.Print("DepthClearer Component cound: " + subRoot.depthClearer.GetComponents(typeof(Component)).Length);
                        foreach (Component c in subRoot.depthClearer.GetComponents(typeof(Component)))
                        {
                            Utilities.Log.Print("Component: " + c);
                        }
                    }
                }
            }

            if (GUILayout.Button("Cyclops Ladder"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        Utilities.Log.Print(raycastHit4.rigidbody.gameObject.name);
                        foreach (SkinnedMeshRenderer smr in raycastHit4.rigidbody.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>())
                        {
                            if (smr.gameObject.name.ToLower().Equals("submarine_ladder_04") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_long") ||
                                smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_right") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_left") ||
                                smr.gameObject.name.ToLower().Equals("submarine_ladder_02"))
                            {
                                Utilities.Log.Print("Mesh: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.sharedMesh?.name);
                                Utilities.Log.Print("Bones Length: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.bones?.Length);
                                smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.material?.PrintAllMarmosetUBERShaderProperties();
                            }
                        }
                    }
                }
            }

            if (GUILayout.Button("Cyclops Force Damage Point"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>();
                        if (damage == null)
                        {
                            Log.Print("CyclopsExternalDamageManager not found");
                            return;
                        }

                        MethodInfo mi = SMLHelper.V2.Utility.ReflectionHelper.GetInstanceMethod(damage, "CreatePoint");
                        if (mi == null)
                        {
                            Log.Print("CreatePoint method not found");
                            return;
                        }

                        mi.FastInvoke(damage);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Print Damage Info"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>();
                        if (damage == null)
                        {
                            Log.Print("CyclopsExternalDamageManager not found");
                            return;
                        }

                        CyclopsDamagePoint[] damagePoints = raycastHit4.rigidbody.gameObject.GetComponentsInChildren <CyclopsDamagePoint>();
                        foreach (var dp in damagePoints)
                        {
                            dp.gameObject.GetComponentInChildren <LiveMixin>().PrintAllLiveMixinDetails();
                            Log.Print(" ");
                        }
                    }
                }
            }

            if (GUILayout.Button("Subfire information."))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        SubFire subFire = raycastHit4.rigidbody.GetComponentInChildren <SubFire>();
                        if (subFire == null)
                        {
                            Log.Print("Cyclop's subfire not found.");
                            return;
                        }

                        Utilities.Log.Print("Fire prefab: " + subFire.firePrefab);
                    }
                }
            }
        }
 public BioAuxCyclopsManager(SubRoot cyclops, TechType bioBooster, TechType bioReactor) : base(cyclops)
 {
     CyBioBoosterID = bioBooster;
     CyBioReactorID = bioReactor;
 }
 public override bool Initialize(SubRoot cyclops)
 {
     return(base.Cyclops == cyclops);
 }
 public static bool Prefix(ref SubRoot __instance)
 {
     return(false); // Now handled by UpgradeManager HandleUpgrades
 }
 public T AuxCyclopsManager <T>(SubRoot cyclops)
     where T : class, IAuxCyclopsManager
 {
     return(CyclopsManager.GetManager <T>(cyclops, typeof(T).Name));
 }
Exemplo n.º 17
0
        public static void Postfix(PowerRelay __instance, PowerRelay potentialRelay, ref bool __result)
        {
            if (__result)
            {
                if (__instance is null || potentialRelay is null)
                {
                    return;
                }

                SubRoot subRoot1 = __instance.gameObject.GetComponentInParent <SubRoot>();
                SubRoot subRoot2 = potentialRelay.gameObject.GetComponentInParent <SubRoot>();

                if (!(__instance is OtherConnectionRelay) && !(__instance is BaseInboundRelay) && !__instance.gameObject.name.Contains("Transmitter") && subRoot1 != null && subRoot1 == subRoot2)
                {
                    __result = false;
                    return;
                }

                if (__instance is BaseInboundRelay && (subRoot1 is null || subRoot1 != subRoot2))
                {
                    __result = false;
                    return;
                }

                if (potentialRelay is OtherConnectionRelay)
                {
                    __result = false;
                    return;
                }

                if (__instance is OtherConnectionRelay && potentialRelay is BasePowerRelay)
                {
                    __result = false;
                    return;
                }

                if (__instance is OtherConnectionRelay && potentialRelay.gameObject.name.Contains("Transmitter"))
                {
                    __result = false;
                    return;
                }

                if (!(__instance is OtherConnectionRelay) && !(__instance is BaseInboundRelay) && __instance.gameObject.name.Contains("Transmitter") && !potentialRelay.gameObject.name.Contains("Transmitter"))
                {
                    __result = false;
                    return;
                }

                if (potentialRelay is BaseInboundRelay)
                {
                    __result = false;
                    return;
                }

                if (__instance is BaseInboundRelay && !(potentialRelay is BasePowerRelay))
                {
                    __result = false;
                    return;
                }

                if (potentialRelay is BasePowerRelay && __instance.gameObject.name.Contains("Transmitter") && !(__instance is BaseInboundRelay))
                {
                    __result = false;
                    return;
                }

                if (potentialRelay != __instance.outboundRelay && potentialRelay.GetType() == typeof(PowerRelay) && potentialRelay.inboundPowerSources.Where((x) => x.GetType() == typeof(OtherConnectionRelay)).Any())
                {
                    __result = false;
                    return;
                }

                if (__instance is OtherConnectionRelay || __instance is BaseInboundRelay)
                {
                    return;
                }

                if (Main.config.LOSBlue && __instance.gameObject.name.Contains("Transmitter") && Physics.Linecast(__instance.GetConnectPoint(), potentialRelay.GetConnectPoint(), Voxeland.GetTerrainLayerMask()))
                {
                    __result = false;
                    return;
                }

                Vector3 position1 = __instance.GetConnectPoint(potentialRelay.GetConnectPoint(__instance.GetConnectPoint(potentialRelay.GetConnectPoint())));
                Vector3 position2 = potentialRelay.GetConnectPoint(position1);

                if (Vector3.Distance(position1, position2) > __instance.maxOutboundDistance)
                {
                    __result = false;
                    return;
                }
            }
        }
 public T CyclopsCharger <T>(SubRoot cyclops) where T : CyclopsCharger
 {
     return(CyclopsManager.GetManager(cyclops)?.Charge.GetCharger <T>(typeof(T).Name));
 }
Exemplo n.º 19
0
        /// <summary>
        /// Add/remove <see cref="CyclopsDamagePoint"/>s until it matches the <paramref name="damagePointIndexes"/> array passed. Can trigger <see cref="CyclopsDamagePointRepaired"/> packets
        /// </summary>
        private void SetActiveDamagePoints(SubRoot cyclops, int[] damagePointIndexes)
        {
            CyclopsExternalDamageManager damageManager      = cyclops.gameObject.RequireComponentInChildren <CyclopsExternalDamageManager>();
            List <CyclopsDamagePoint>    unusedDamagePoints = (List <CyclopsDamagePoint>)damageManager.ReflectionGet("unusedDamagePoints");

            // CyclopsExternalDamageManager.damagePoints is an unchanged list. It will never have items added/removed from it. Since packet.DamagePointIndexes is also an array
            // generated in an ordered manner, we can match them without worrying about unordered items.
            if (damagePointIndexes != null && damagePointIndexes.Length > 0)
            {
                int packetDamagePointsIndex = 0;

                for (int damagePointsIndex = 0; damagePointsIndex < damageManager.damagePoints.Length; damagePointsIndex++)
                {
                    // Loop over all of the packet.DamagePointIndexes as long as there's more to match
                    if (packetDamagePointsIndex < damagePointIndexes.Length &&
                        damagePointIndexes[packetDamagePointsIndex] == damagePointsIndex)
                    {
                        if (!damageManager.damagePoints[damagePointsIndex].gameObject.activeSelf)
                        {
                            // Copied from CyclopsExternalDamageManager.CreatePoint(), except without the random index pick.
                            damageManager.damagePoints[damagePointsIndex].gameObject.SetActive(true);
                            damageManager.damagePoints[damagePointsIndex].RestoreHealth();
                            GameObject prefabGo = damageManager.fxPrefabs[UnityEngine.Random.Range(0, damageManager.fxPrefabs.Length - 1)];
                            damageManager.damagePoints[damagePointsIndex].SpawnFx(prefabGo);
                            unusedDamagePoints.Remove(damageManager.damagePoints[damagePointsIndex]);
                        }

                        packetDamagePointsIndex++;
                    }
                    else
                    {
                        // If it's active, but not in the list, it must have been repaired.
                        if (damageManager.damagePoints[damagePointsIndex].gameObject.activeSelf)
                        {
                            RepairDamagePoint(cyclops, damagePointsIndex, 999);
                        }
                    }
                }

                // Looks like the list came in unordered. I've uttered "That shouldn't happen" enough to do sanity checks for what should be impossible.
                if (packetDamagePointsIndex < damagePointIndexes.Length)
                {
                    Log.Error("[CyclopsDamageProcessor packet.DamagePointIds did not fully iterate! Id: " + damagePointIndexes[packetDamagePointsIndex].ToString()
                              + " had no matching Id in damageManager.damagePoints, or the order is incorrect!]");
                }
            }
            else
            {
                // None should be active.
                for (int i = 0; i < damageManager.damagePoints.Length; i++)
                {
                    if (damageManager.damagePoints[i].gameObject.activeSelf)
                    {
                        RepairDamagePoint(cyclops, i, 999);
                    }
                }
            }

            // unusedDamagePoints is checked against damagePoints to determine if there's enough damage points. Failing to set the new list
            // of unusedDamagePoints will cause random DamagePoints to appear.
            damageManager.ReflectionSet("unusedDamagePoints", unusedDamagePoints);
            // Visual update only to show the water leaking through the window and various hull points based on missing health.
            damageManager.ReflectionCall("ToggleLeakPointsBasedOnDamage", false, false, null);
        }
 public UpgradeHandler CyclopsUpgradeHandler(SubRoot cyclops, TechType upgradeId)
 {
     return(CyclopsManager.GetManager(cyclops).Upgrade?.GetUpgradeHandler <UpgradeHandler>(upgradeId));
 }
Exemplo n.º 21
0
 internal CyclopsHUDManager(SubRoot cyclops, int totalIcons)
 {
     Cyclops             = cyclops;
     totalPowerInfoIcons = Math.Max(totalIcons, 1); // Include a minimum of 1 for the vanilla thermal charger
 }
 public T CyclopsUpgradeHandler <T>(SubRoot cyclops, TechType upgradeId) where T : UpgradeHandler
 {
     return(CyclopsManager.GetManager(cyclops).Upgrade?.GetUpgradeHandler <T>(upgradeId));
 }
Exemplo n.º 23
0
 internal UpgradeManager(SubRoot cyclops)
 {
     Cyclops = cyclops;
 }
 public T CyclopsGroupUpgradeHandler <T>(SubRoot cyclops, TechType upgradeId, params TechType[] additionalIds) where T : UpgradeHandler, IGroupHandler
 {
     return(CyclopsManager.GetManager(cyclops).Upgrade?.GetGroupHandler <T>(upgradeId));
 }
Exemplo n.º 25
0
 public SolarChargeHandler(ChargeManager chargeManager)
 {
     Cyclops       = chargeManager.Cyclops;
     ChargeManager = chargeManager;
 }
 public IPowerRatingManager GetPowerRatingManager(SubRoot cyclops)
 {
     return(CyclopsManager.GetManager(cyclops)?.Engine);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Triggers a <see cref="CyclopsDamage"/> packet
 /// </summary>
 public void OnCreateDamagePoint(SubRoot subRoot)
 {
     BroadcastDamageState(subRoot, Optional.Empty);
 }
 public void ApplyPowerRatingModifier(SubRoot cyclops, TechType techType, float modifier)
 {
     CyclopsManager.GetManager(cyclops)?.Engine.ApplyPowerRatingModifier(techType, modifier);
 }
 public AutoDefenser(TechType autoDefense, SubRoot cyclops)
     : base(autoDefense, cyclops)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AmbientEnergyUpgradeHandler"/> class.
        /// </summary>
        /// <param name="tier1Id">The tier1 identifier.</param>
        /// <param name="tier2Id">The tier2 identifier.</param>
        /// <param name="maxedOutMsg">The maxed out MSG.</param>
        /// <param name="cyclops">The cyclops.</param>
        public AmbientEnergyUpgradeHandler(TechType tier1Id, TechType tier2Id, string maxedOutMsg, SubRoot cyclops)
            : base(cyclops)
        {
            this.MaxCount      = this.MaxChargers;
            maxCountReachedMsg = maxedOutMsg;

            OnClearUpgrades = () =>
            {
                updating = true;
                batteries.Clear();
            };

            tier1 = CreateStackingTier(tier1Id);
            tier2 = CreateStackingTier(tier2Id);

            tier1.MaxCount = this.MaxChargers;
            tier2.MaxCount = this.MaxChargers;

            tier1.IsAllowedToAdd += CheckCombinedTotal;
            tier2.IsAllowedToAdd += CheckCombinedTotal;

            OnUpgradeCountedDetailed += AddBatteryDetails;

            OnFinishedUpgrades = () =>
            {
                updating = false;

                if (this.Count > 1)
                {
                    // Stacking multiple solar/thermal chargers has diminishing returns on how much extra energy you can get after the first.
                    // The diminishing returns are themselves also variable.
                    // Heavy diminishing returns for tier 1 modules.
                    // Better returns and multiplier for tier 2 modules.

                    // The diminishing returns follow a geometric sequence with a factor always less than 1.
                    // You can check the math on this over here https://www.purplemath.com/modules/series5.htm

                    float diminishingReturnFactor = 0.45f + (0.045f * tier2.Count);
                    float chargeMultiplier        = (1 - Mathf.Pow(diminishingReturnFactor, this.Count)) /
                                                    (1 - diminishingReturnFactor);
                    chargeMultiplier += 0.015f * tier2.Count;

                    this.ChargeMultiplier = Mathf.Max(1f, chargeMultiplier);
                }
            };

            OnFirstTimeMaxCountReached = () =>
            {
                ErrorMessage.AddMessage(maxCountReachedMsg);
            };
        }