Пример #1
0
        internal static unsafe TestErrorEvent FromNative(IntPtr nativeRaw)
        {
            if (nativeRaw == IntPtr.Zero)
            {
                return(null);
            }

            NativeTypes.FABRIC_TEST_ERROR_EVENT native = *(NativeTypes.FABRIC_TEST_ERROR_EVENT *)nativeRaw;

            var timeStamp = NativeTypes.FromNativeFILETIME(native.TimeStampUtc);

            var reason = ChaosUtility.Decompress(NativeTypes.FromNativeString(native.Reason));

            return(new TestErrorEvent(timeStamp, reason));
        }
Пример #2
0
        private static unsafe List <ChaosEvent> FromNativeEvents(IntPtr pointer)
        {
            var nativeEventsPtr     = (NativeTypes.FABRIC_CHAOS_EVENT_LIST *)pointer;
            var retval              = new List <ChaosEvent>();
            var nativeEventArrayPtr = (NativeTypes.FABRIC_CHAOS_EVENT *)nativeEventsPtr->Items;

            for (int i = 0; i < nativeEventsPtr->Count; ++i)
            {
                var        nativeItem = *(nativeEventArrayPtr + i);
                ChaosEvent chaosEvent = ChaosUtility.FromNativeEvent(nativeItem);
                retval.Add(chaosEvent);
            }

            return(retval);
        }
        internal static unsafe ValidationFailedEvent FromNative(IntPtr nativeRaw)
        {
            if (nativeRaw == IntPtr.Zero)
            {
                return(null);
            }

            var native = *(NativeTypes.FABRIC_VALIDATION_FAILED_EVENT *)nativeRaw;

            var timeStamp = NativeTypes.FromNativeFILETIME(native.TimeStampUtc);

            var reason = ChaosUtility.Decompress(NativeTypes.FromNativeString(native.Reason));

            return(new ValidationFailedEvent(timeStamp, reason));
        }
        public void Teleport()
        {
            PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
            ChaosUtility     chaosUtility  = ETGModMainBehaviour.Instance.gameObject.AddComponent <ChaosUtility>();
            AIActor          DummyEnemy    = EnemyDatabase.GetOrLoadByGuid(ChaosLists.BulletKinEnemyGUID);
            RoomHandler      currentRoom   = primaryPlayer.CurrentRoom;
            IntVector2       newPos        = ChaosUtility.Instance.GetRandomAvailableCellSmart(currentRoom, primaryPlayer, 5, false);

            if (newPos == IntVector2.Zero)
            {
                Invoke("TentacleRelease", 1f);
                Invoke("TentacleShowPlayer", 1.45f);
                Invoke("Unfreeze", 2f);
                return;
            }
            primaryPlayer.TeleportToPoint(newPos.ToCenterVector2(), false);
            Invoke("TentacleRelease", 1f);
            Invoke("TentacleShowPlayer", 1.45f);
            Invoke("Unfreeze", 2f);
        }
Пример #5
0
        private static IntPtr ToNativeEvents(PinCollection pin, List <ChaosEvent> history)
        {
            if (history == default(List <ChaosEvent>))
            {
                return(IntPtr.Zero);
            }

            var eventArray = new NativeTypes.FABRIC_CHAOS_EVENT[history.Count];

            for (int i = 0; i < history.Count; ++i)
            {
                eventArray[i].Value = history[i].ToNative(pin);
                eventArray[i].Kind  = ChaosUtility.GetNativeEventType(history[i]);
            }

            var nativeEvents = new NativeTypes.FABRIC_CHAOS_EVENT_LIST
            {
                Count = (uint)eventArray.Length,
                Items = pin.AddBlittable(eventArray)
            };

            return(pin.AddBlittable(nativeEvents));
        }
Пример #6
0
        public static void Init(AIActor sourceActor = null)
        {
            if (sourceActor == null)
            {
                sourceActor = EnemyDatabase.GetOrLoadByGuid("2feb50a6a40f4f50982e89fd276f6f15");
            }

            BootlegBullatTextures = new List <Texture2D>()
            {
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_charge_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_charge_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_charge_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_charge_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_die_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\Bullat\\bullat_idle_006.png")
            };
            BootlegBullatCollection = ChaosUtility.BuildSpriteCollection(sourceActor.sprite.Collection, null, BootlegBullatTextures, ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"), true);
            DontDestroyOnLoad(BootlegBullatCollection);
        }
Пример #7
0
        public void FaultReplica(bool faultedDueToCodePackageFault, Guid activityId = default(Guid))
        {
            // Confirm replica is available to fault
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultReplica_ReplicaInTransition_TelemetryId,
                !faultedDueToCodePackageFault && !this.IsAvailableToFault,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_ReplicaInTransition,
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            // If not in unsafe mode then confirm that the fault tolerance of this partition is at least 1
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultReplica_PartitionNotFaultTolerant_TelemetryId,
                this.ParentPartitionEntity.GetPartitionFaultTolerance() <= 0 && !this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot.UnsafeModeEnabled,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_PartitionNotFaultTolerantInSafeMode,
                    this.ParentPartitionEntity.Partition.PartitionId(),
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            // Mark current replicas as faulted
            this.MarkReplicaAsInTransitionInternal(activityId);
        }
Пример #8
0
        private void MarkReplicaAsInTransitionInternal(Guid activityId = default(Guid))
        {
            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking replica {1} as faulted",
                activityId,
                this);

            this.ReplicaFlags |= ClusterEntityFlags.Faulted;
            var isPartitionFaultTolerant = this.ParentPartitionEntity.GetPartitionFaultTolerance() > 0;

            if (!isPartitionFaultTolerant)
            {
                // If partition is no longer fault tolerant after this fault then mark all corresponding replicas
                // in the partition as unsafe to fault. The corresponding nodes and code packages are also marked as unsafe to fault
                foreach (ReplicaEntity replica in this.ParentPartitionEntity.ReplicaList)
                {
                    // Unsafe to fault this partition anymore. Mark any node/codepackage/replica for this partition as unsafe to fault
                    var clusterNode =
                        this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot.Nodes.FindMatchingNodeEntity(replica.Replica.NodeName);

                    ChaosUtility.ThrowOrAssertIfTrue(
                        ChaosConstants.MarkReplciaAsInTransition_UnavailableTargetNode_TelemetryId,
                        clusterNode == null,
                        string.Format(
                            StringResources.ChaosEngineError_ReplicaEntity_UnavaliableNode,
                            replica.Replica.NodeName,
                            replica),
                        this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

                    TestabilityTrace.TraceSource.WriteInfo(
                        TraceType,
                        "{0}: Marking node '{1}' as Unsafe for replica '{2}' due to partition being not-fault-tolerant",
                        activityId,
                        clusterNode.CurrentNodeInfo.NodeName,
                        replica);

                    clusterNode.MarkNodeAsUnsafeToFault();

                    var replicaCodePackage = this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.GetCodePackagEntityForReplica(replica);
                    if (replicaCodePackage != null)
                    {
                        TestabilityTrace.TraceSource.WriteInfo(
                            TraceType,
                            "{0}: Marking replicaCodepackage '{1}' as Unsafe for due to partition '{2}' being not-fault-tolerant due to faulting replica '{3}'",
                            activityId,
                            replicaCodePackage,
                            replica.ParentPartitionEntity.Partition.PartitionId(),
                            replica.Replica.Id);

                        replicaCodePackage.MarkCodePackageAsUnsafeToFault();
                    }

                    TestabilityTrace.TraceSource.WriteInfo(
                        TraceType,
                        "{0}: Marking replica '{1}' as Unsafe due to partition being not-fault-tolerant",
                        activityId,
                        replica);

                    replica.MarkReplicaAsUnsafeToFault();
                }
            }

            // Mark the node on which this replica is as used for faults so that it cannot be used for any node faults
            var currentReplicaNodeEntity =
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot.Nodes.FindMatchingNodeEntity(this.Replica.NodeName);

            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.MarkReplicaAsInTransition_UnavailableSourceNode_TelemetryId,
                currentReplicaNodeEntity == null,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_UnavaliableNode,
                    this.Replica.NodeName,
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            // Assert (or throw) if higher level entities are already faulted
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.MarkReplicaAsInTransition_NodeFaulted_TelemetryId,
                currentReplicaNodeEntity.NodeFlags.HasFlag(ClusterEntityFlags.Faulted),
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_FaultedNode,
                    currentReplicaNodeEntity.CurrentNodeInfo.NodeName,
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking currentReplicaNodeEntity {1} as Unavailable for replica {2} due to partition being not-fault-tolerant",
                activityId,
                currentReplicaNodeEntity.CurrentNodeInfo.NodeName,
                this);

            currentReplicaNodeEntity.MarkNodeAsUnavailableForFaults();

            var currentReplicaCodePackage = this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.GetCodePackagEntityForReplica(this);

            if (currentReplicaCodePackage != null)
            {
                TestabilityTrace.TraceSource.WriteInfo(
                    TraceType,
                    "{0}: Marking currentReplicaCodePackage {1} as unavailable due to faulting replica {2}",
                    activityId,
                    currentReplicaCodePackage,
                    this);

                currentReplicaCodePackage.MarkCodePackageAsUnavailableForFaults();

                ChaosUtility.ThrowOrAssertIfTrue(
                    ChaosConstants.MarkReplicaAsInTransition_CodepackageFaulted_TelemetryId,
                    currentReplicaCodePackage.CodePackageFlags.HasFlag(ClusterEntityFlags.Faulted),
                    string.Format(
                        StringResources.ChaosEngineError_ReplicaEntity_FaultCodePackage,
                        currentReplicaCodePackage,
                        currentReplicaCodePackage.NodeName,
                        this),
                    this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);
            }
        }
Пример #9
0
        public static void Init(AIActor sourceActor = null)
        {
            if (sourceActor == null)
            {
                sourceActor = EnemyDatabase.GetOrLoadByGuid("128db2f0781141bcb505d8f00f9e4d47");
            }

            BootlegRedShotGunManTextures = new List <Texture2D>()
            {
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_front_north_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_front_north_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_front_north_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_burst_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_surprise_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_surprise_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_surprise_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_surprise_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_spawn_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_spawn_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_spawn_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_left_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_run_eft_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_right_run_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_pitfall_right_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_pitfall_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_pitfall_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_pitfall_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_pitfall_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_left_run_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_idle_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_idle_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_idle_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_idle_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_hit_right_forward_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_hit_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_hit_left_forward_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_hit_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_side_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_forward_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_forward_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_side_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_forward_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_forward_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_front_north_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\RedShotGunMan\\shotgunguy_death_front_north_004.png")
            };
            // foreach (Texture2D texture in BootlegRedShotGunManCollection) { DontDestroyOnLoad(texture); }
            BootlegRedShotGunManCollection = ChaosUtility.BuildSpriteCollection(sourceActor.sprite.Collection, null, BootlegRedShotGunManTextures, ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"), true);
            DontDestroyOnLoad(BootlegRedShotGunManCollection);
        }
 public void Start()
 {
     if (!m_configured)
     {
         ConfigureOnPlacement(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(transform.position.IntXY(VectorConversions.Ceil)));
     }
     if (ChaosConsole.GlitchEnemies | ChaosConsole.GlitchEverything)
     {
         if (UnityEngine.Random.value <= m_GlitchOdds)
         {
             m_GlitchModeActive = true;
         }
     }
     transform.position = m_startingPos;
     specRigidbody.Reinitialize();
     aiAnimator.LockFacingDirection = true;
     aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
     if (!m_failedWallConfigure)
     {
         m_fakeWall = ChaosUtility.GenerateWallMesh(m_facingDirection, pos1, "Mimic Wall", null, true, m_GlitchModeActive);
         if (aiActor.ParentRoom != null)
         {
             m_fakeWall.transform.parent = aiActor.ParentRoom.hierarchyParent;
         }
         m_fakeWall.transform.position = pos1.ToVector3().WithZ(pos1.y - 2) + Vector3.down;
         if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             StaticReferenceManager.AllShadowSystemDepthHavers.Add(m_fakeWall.transform);
         }
         else if (m_facingDirection == DungeonData.Direction.WEST)
         {
             m_fakeWall.transform.position = m_fakeWall.transform.position + new Vector3(-0.1875f, 0f);
         }
         m_fakeCeiling = ChaosUtility.GenerateRoomCeilingMesh(GetCeilingTileSet(pos1, pos2, m_facingDirection), "Mimic Ceiling", null, true, m_GlitchModeActive);
         if (aiActor.ParentRoom != null)
         {
             m_fakeCeiling.transform.parent = aiActor.ParentRoom.hierarchyParent;
         }
         m_fakeCeiling.transform.position = pos1.ToVector3().WithZ(pos1.y - 4);
         if (m_facingDirection == DungeonData.Direction.NORTH)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 0f);
         }
         else if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 2f);
         }
         else if (m_facingDirection == DungeonData.Direction.EAST)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 0f);
         }
         m_fakeCeiling.transform.position = m_fakeCeiling.transform.position.WithZ(m_fakeCeiling.transform.position.y - 5f);
         for (int i = 0; i < specRigidbody.PixelColliders.Count; i++)
         {
             specRigidbody.PixelColliders[i].Enabled = false;
         }
         if (m_facingDirection == DungeonData.Direction.NORTH)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 38, 38, 32, 8, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 38, 54, 32, 8, true));
         }
         else if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 38, 38, 32, 16, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 38, 54, 32, 16, true));
         }
         else if (m_facingDirection == DungeonData.Direction.WEST || m_facingDirection == DungeonData.Direction.EAST)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 46, 38, 16, 32, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 46, 38, 16, 32, true));
         }
         specRigidbody.ForceRegenerate(null, null);
     }
     aiActor.HasDonePlayerEnterCheck    = true;
     m_collisionKnockbackStrength       = aiActor.CollisionKnockbackStrength;
     aiActor.CollisionKnockbackStrength = 0f;
     aiActor.CollisionDamage            = 0f;
     m_goopDoer = GetComponent <GoopDoer>();
 }
        private IEnumerator BecomeMimic()
        {
            if (m_hands == null)
            {
                StartCoroutine(DoIntro());
            }

            if (!ChaosConsole.WallMimicsUseRewardManager)
            {
                m_ChaosModeActive = true;
            }
            if (m_GlitchModeActive)
            {
                m_ItemDropOdds += 0.2f; m_FriendlyMimicOdds += 0.2f;
            }

            m_isHidden = false;
            SpeculativeRigidbody specRigidbody = this.specRigidbody;

            specRigidbody.OnRigidbodyCollision = (SpeculativeRigidbody.OnRigidbodyCollisionDelegate)Delegate.Remove(specRigidbody.OnRigidbodyCollision, new SpeculativeRigidbody.OnRigidbodyCollisionDelegate(HandleRigidbodyCollision));
            SpeculativeRigidbody specRigidbody2 = this.specRigidbody;

            specRigidbody2.OnBeamCollision = (SpeculativeRigidbody.OnBeamCollisionDelegate)Delegate.Remove(specRigidbody2.OnBeamCollision, new SpeculativeRigidbody.OnBeamCollisionDelegate(HandleBeamCollision));
            AIAnimator tongueAnimator = aiAnimator.ChildAnimator;

            tongueAnimator.renderer.enabled       = true;
            tongueAnimator.spriteAnimator.enabled = true;
            AIAnimator spitAnimator = tongueAnimator.ChildAnimator;

            spitAnimator.renderer.enabled       = true;
            spitAnimator.spriteAnimator.enabled = true;
            tongueAnimator.PlayUntilFinished("spawn", false, null, -1f, false);
            float delay        = tongueAnimator.CurrentClipLength;
            float timer        = 0f;
            bool  hasPlayedVFX = false;

            while (timer < delay)
            {
                yield return(null);

                timer += BraveTime.DeltaTime;
                if (!hasPlayedVFX && delay - timer < 0.1f)
                {
                    hasPlayedVFX = true;
                    if (WallDisappearVFX)
                    {
                        Vector2 zero  = Vector2.zero;
                        Vector2 zero2 = Vector2.zero;
                        DungeonData.Direction facingDirection = m_facingDirection;
                        if (facingDirection != DungeonData.Direction.SOUTH)
                        {
                            if (facingDirection != DungeonData.Direction.EAST)
                            {
                                if (facingDirection == DungeonData.Direction.WEST)
                                {
                                    zero  = new Vector2(0f, -1f);
                                    zero2 = new Vector2(0f, 1f);
                                }
                            }
                            else
                            {
                                zero  = new Vector2(0f, -1f);
                                zero2 = new Vector2(0f, 1f);
                            }
                        }
                        else
                        {
                            zero  = new Vector2(0f, -1f);
                            zero2 = new Vector2(0f, 1f);
                        }
                        Vector2 min = Vector2.Min(pos1.ToVector2(), pos2.ToVector2()) + zero;
                        Vector2 max = Vector2.Max(pos1.ToVector2(), pos2.ToVector2()) + new Vector2(1f, 1f) + zero2;
                        for (int i = 0; i < 5; i++)
                        {
                            Vector2        v              = BraveUtility.RandomVector2(min, max, new Vector2(0.25f, 0.25f)) + new Vector2(0f, 1f);
                            GameObject     gameObject     = SpawnManager.SpawnVFX(WallDisappearVFX, v, Quaternion.identity);
                            tk2dBaseSprite tk2dBaseSprite = (!gameObject) ? null : gameObject.GetComponent <tk2dBaseSprite>();
                            if (tk2dBaseSprite)
                            {
                                tk2dBaseSprite.HeightOffGround = 8f;
                                tk2dBaseSprite.UpdateZDepth();
                            }
                        }
                    }
                }
            }
            if (!m_failedWallConfigure && m_GlitchModeActive)
            {
                if (aiActor.ParentRoom != null && GlitchEnemyList != null && GlitchEnemyList.Count > 0 && UnityEngine.Random.value <= m_spawnGitchEnemyOdds)
                {
                    float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                    float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                    float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                    float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                    float RandomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                    int count2 = this.specRigidbody.PixelColliders.Count;
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 1);
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 2);
                    StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                    Destroy(m_fakeWall);
                    Destroy(m_fakeCeiling);

                    Vector3 targetPosForSpawn = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();
                    while (timer < delay)
                    {
                        aiAnimator.LockFacingDirection = true;
                        aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                        yield return(null);

                        timer += BraveTime.DeltaTime;
                        transform.position = Vector3.Lerp(m_startingPos, targetPosForSpawn, Mathf.InverseLerp(0.42f, 0.58f, timer));
                        this.specRigidbody.Reinitialize();
                    }
                    yield return(null);

                    Vector3 FinalSpawnLocation             = transform.position;
                    Vector3 VFXExplosionLocation           = transform.position;
                    Vector2 VFXExplosionSource             = Vector2.zero;
                    DungeonData.Direction CurrentDirection = m_facingDirection;
                    if (CurrentDirection == DungeonData.Direction.WEST)
                    {
                        FinalSpawnLocation   += new Vector3(2.5f, 3.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 3.5f);
                        VFXExplosionSource    = new Vector2(1, 0);
                    }
                    else if (CurrentDirection == DungeonData.Direction.EAST)
                    {
                        FinalSpawnLocation   += new Vector3(4f, 3.5f);
                        VFXExplosionLocation += new Vector3(3f, 3.5f);
                    }
                    else if (CurrentDirection == DungeonData.Direction.NORTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 4f);
                        VFXExplosionLocation += new Vector3(3.5f, 3f);
                        VFXExplosionSource    = new Vector2(0, 1);
                    }
                    else if (CurrentDirection == DungeonData.Direction.SOUTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 1.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 2.5f);
                    }
                    yield return(null);

                    string        SelectedEnemy          = BraveUtility.RandomElement(GlitchEnemyList);
                    ExplosionData wallMimicExplosionData = new ExplosionData();
                    wallMimicExplosionData.CopyFrom(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultExplosionData);
                    wallMimicExplosionData.damage = 0f;
                    wallMimicExplosionData.force /= 1.6f;

                    if (SelectedEnemy != "RATCORPSE")
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject     SpawnVFXObject          = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                        tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                        SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                        SpawnVFXObjectComponent.HeightOffGround = 1f;
                        SpawnVFXObjectComponent.UpdateZDepth();
                        AIActor glitchActor = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid(SelectedEnemy), FinalSpawnLocation, aiActor.ParentRoom, true, AIActor.AwakenAnimationType.Awaken, true);

                        /*if (aiActor.ParentRoom != null && !aiActor.ParentRoom.IsSealed && !glitchActor.IgnoreForRoomClear) {
                         *  if (GameManager.Instance.PrimaryPlayer.CurrentRoom == aiActor.ParentRoom && aiActor.ParentRoom.EverHadEnemies) {
                         *      aiActor.ParentRoom.SealRoom();
                         *  }
                         * }*/
                        PickupObject.ItemQuality targetGlitchEnemyItemQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
                        GenericLootTable         glitchEnemyLootTable         = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                        PickupObject             glitchEnemyItem = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetGlitchEnemyItemQuality, glitchEnemyLootTable, false);

                        /*if (BraveUtility.RandomBool()) {
                         *  ChaosUtility.MakeCompanion(glitchActor);
                         * } else {
                         *  ChaosShaders.Instance.ApplyGlitchShader(glitchActor, glitchActor.sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);
                         * }*/

                        ChaosShaders.Instance.ApplyGlitchShader(glitchActor, glitchActor.sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);

                        if (glitchEnemyItem)
                        {
                            glitchActor.AdditionalSafeItemDrops.Add(glitchEnemyItem);
                        }
                    }
                    else
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject     SpawnVFXObject          = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                        tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                        SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                        SpawnVFXObjectComponent.HeightOffGround = 1f;
                        SpawnVFXObjectComponent.UpdateZDepth();
                        GameObject   spawnedRatCorpseObject = Instantiate(ChaosPrefabs.RatCorpseNPC, FinalSpawnLocation, Quaternion.identity);
                        TalkDoerLite talkdoerComponent      = spawnedRatCorpseObject.GetComponent <TalkDoerLite>();
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(talkdoerComponent);
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().TransferInteractableOwnershipToDungeon(talkdoerComponent);
                        talkdoerComponent.playmakerFsm.SetState("Set Mode");
                        ChaosUtility.AddHealthHaver(talkdoerComponent.gameObject, 60, flashesOnDamage: false, exploderSpawnsItem: true);
                    }
                    yield return(null);

                    Destroy(aiActor.gameObject);
                    yield break;
                }
            }
            PickupObject.ItemQuality targetQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
            GenericLootTable         lootTable     = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
            PickupObject             item          = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);

            if (item)
            {
                if (m_ChaosModeActive)
                {
                    if (UnityEngine.Random.value <= m_ItemDropOdds)
                    {
                        aiActor.AdditionalSafeItemDrops.Add(item);
                    }
                    else
                    {
                        aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        if (BraveUtility.RandomBool())
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                        if (m_GlitchModeActive)
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                    }
                    if (UnityEngine.Random.value <= m_FriendlyMimicOdds)
                    {
                        m_isFriendlyMimic = true;
                    }
                }
                else
                {
                    aiActor.AdditionalSafeItemDrops.Add(item);
                }
            }
            else
            {
                if (m_ChaosModeActive && UnityEngine.Random.value <= m_FriendlyMimicOdds)
                {
                    m_isFriendlyMimic = true;
                }
            }
            aiActor.enabled            = true;
            behaviorSpeculator.enabled = true;
            if (aiActor.ParentRoom != null && aiActor.ParentRoom.IsSealed && !m_isFriendlyMimic)
            {
                aiActor.IgnoreForRoomClear = false;
            }
            // if (m_isFriendlyMimic) { ChaosUtility.MakeCompanion(aiActor); }
            if (m_isFriendlyMimic)
            {
                aiActor.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
            }
            if (!m_failedWallConfigure)
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count - 2; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
                this.specRigidbody.PixelColliders.RemoveAt(count - 1);
                this.specRigidbody.PixelColliders.RemoveAt(count - 2);
                StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                Destroy(m_fakeWall);
                Destroy(m_fakeCeiling);
            }
            else
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
            }
            for (int k = 0; k < m_hands.Length; k++)
            {
                m_hands[k].gameObject.SetActive(true);
            }
            aiActor.ToggleRenderers(true);
            if (aiShooter)
            {
                aiShooter.ToggleGunAndHandRenderers(true, "ChaosWallMimicController");
            }
            aiActor.IsGone           = false;
            healthHaver.IsVulnerable = true;
            aiActor.State            = AIActor.ActorState.Normal;
            for (int l = 0; l < m_hands.Length; l++)
            {
                m_hands[l].gameObject.SetActive(false);
            }
            m_isFinished = true;
            delay        = 0.58f;
            timer        = 0f;
            Vector3 targetPos = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();

            while (timer < delay)
            {
                aiAnimator.LockFacingDirection = true;
                aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                yield return(null);

                timer += BraveTime.DeltaTime;
                transform.position = Vector3.Lerp(m_startingPos, targetPos, Mathf.InverseLerp(0.42f, 0.58f, timer));
                this.specRigidbody.Reinitialize();
            }
            aiAnimator.LockFacingDirection = false;
            knockbackDoer.SetImmobile(false, "ChaosWallMimicController");
            aiActor.CollisionDamage            = 0.5f;
            aiActor.CollisionKnockbackStrength = m_collisionKnockbackStrength;
            yield break;
        }
Пример #12
0
        private async Task StartAndRunAsync(CancellationToken cancellationToken)
        {
            if (!this.stateSemaphore.Wait(ChaosConstants.SchedulerLockWaitMilliseconds, cancellationToken))
            {
                TestabilityTrace.TraceSource.WriteWarning(TraceComponent, "StartAndRunAsync - initial setup - did not acquire lock in provisioned time. Not progressing.");
                return;
            }

            try
            {
                TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "stateSemaphore Acquired by scheduler in StartAndRunAsync initialization");
                await this.WriteStateToReliableStoreAsync(this.state, cancellationToken).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                string exceptionMessage = string.Format("StartAndRunAsync - failed to set initial state. Exception:{0}", ex.Message);
                TestabilityTrace.TraceSource.WriteError(TraceComponent, exceptionMessage);
                ChaosUtility.ThrowOrAssertIfTrue("ChaosScheduler::StartAndRunAsync", true, exceptionMessage);

                return;
            }
            finally
            {
                this.stateSemaphore.Release();
                TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "stateSemaphore Released by scheduler in StartAndRunAsync initialization");
            }

            while (!cancellationToken.IsCancellationRequested)
            {
                if (!this.stateSemaphore.Wait(ChaosConstants.SchedulerLockWaitMilliseconds, cancellationToken))
                {
                    TestabilityTrace.TraceSource.WriteWarning(TraceComponent, "StartAndRunAsync - scheduler loop - did not acquire lock in provisioned time.");
                    continue;
                }

                try
                {
                    TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "stateSemaphore Acquired by scheduler in StartAndRunAsync work loop");

                    SchedulerState stateSnapshot = new SchedulerState(this.state);

                    if (this.state.Equals(SchedulerState.NoChaosSchedulePending))
                    {
                        await this.TryMatureScheduleAsync(cancellationToken).ConfigureAwait(false);
                    }
                    else if (this.state.Equals(SchedulerState.NoChaosScheduleActive))
                    {
                        await this.TryExpireSchedule(cancellationToken).ConfigureAwait(false);

                        await this.TryStartChaosAsync(cancellationToken).ConfigureAwait(false);
                    }
                    else if (this.state.Equals(SchedulerState.ChaosScheduleActive))
                    {
                        await this.TryExpireSchedule(cancellationToken).ConfigureAwait(false);

                        await this.TryFinishChaosAsync(cancellationToken).ConfigureAwait(false);
                    }
                    //// Scheduler takes no action on all other states.
                }
                catch (InvalidOperationException ex)
                {
                    TestabilityTrace.TraceSource.WriteError(TraceComponent, "Scheduler encountered a bad state transaction {0}", ex.Message);

                    await this.WriteStateToReliableStoreAsync(SchedulerState.NoChaosScheduleStopped, cancellationToken).ConfigureAwait(false);

                    await this.chaosMessageProcessor.ProcessStopChaosOldAsync(true).ConfigureAwait(false);

                    this.state = new SchedulerState(SchedulerState.NoChaosScheduleStopped);
                }
                finally
                {
                    this.stateSemaphore.Release();
                    TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "stateSemaphore Released by scheduler in StartAndRunAsync work loop");
                }

                await Task.Delay(TimeSpan.FromMilliseconds(ChaosConstants.SchedulerCycleWaitIntervalMilliseconds), cancellationToken).ConfigureAwait(false);
            }
        }
        private void SelfDestructOnKick()
        {
            int   currentCurse                 = PlayerStats.GetTotalCurse();
            int   currentCoolness              = PlayerStats.GetTotalCoolness();
            float ExplodeOnKickChances         = 0.25f;
            float ExplodeOnKickDamageToEnemies = 150f;

            bool ExplodeOnKickDamagesPlayer = BraveUtility.RandomBool();

            if (willDefinitelyExplode)
            {
                ExplodeOnKickChances         = 1f;
                ExplodeOnKickDamagesPlayer   = false;
                ExplodeOnKickDamageToEnemies = 200f;
            }
            else
            {
                if (currentCoolness >= 3)
                {
                    ExplodeOnKickDamagesPlayer   = false;
                    ExplodeOnKickDamageToEnemies = 175f;
                }
                if (currentCurse >= 3)
                {
                    ExplodeOnKickChances         = 0.35f;
                    ExplodeOnKickDamageToEnemies = 200f;
                }
            }

            if (spawnObjectOnSelfDestruct && SpawnedObject != null && !m_objectSpawned)
            {
                m_objectSpawned = true;
                GameObject PlacedGlitchObject = ChaosUtility.GenerateDungeonPlacable(SpawnedObject, false, true).InstantiateObject(transform.position.GetAbsoluteRoom(), (specRigidbody.GetUnitCenter(ColliderType.HitBox) - transform.position.GetAbsoluteRoom().area.basePosition.ToVector2()).ToIntVector2(VectorConversions.Floor));
                PlacedGlitchObject.transform.parent = transform.position.GetAbsoluteRoom().hierarchyParent;

                if (PlacedGlitchObject.GetComponent <PickupObject>() != null)
                {
                    PickupObject PlacedGltichObjectComponent = PlacedGlitchObject.GetComponent <PickupObject>();
                    PlacedGltichObjectComponent.RespawnsIfPitfall = true;
                }
            }

            if (UnityEngine.Random.value <= ExplodeOnKickChances)
            {
                if (useDefaultExplosion)
                {
                    Exploder.DoDefaultExplosion(specRigidbody.GetUnitCenter(ColliderType.HitBox), Vector2.zero, null, true, CoreDamageTypes.None);
                    Exploder.DoRadialDamage(ExplodeOnKickDamageToEnemies, sprite.WorldCenter, 4f, ExplodeOnKickDamagesPlayer, true, true);
                }
                else
                {
                    Exploder.Explode(specRigidbody.GetUnitCenter(ColliderType.HitBox), TableExplosionData, Vector2.zero, null, false, CoreDamageTypes.None, false);
                }

                /*if (gameObject.GetComponent<FlippableCover>() != null) {
                 *  FlippableCover flippableCover = gameObject.GetComponent<FlippableCover>();
                 *      flippableCover.DestroyCover();
                 * } else if (gameObject.GetComponent<MajorBreakable>() != null) {
                 *  MajorBreakable majorBreakableComponent = gameObject.GetComponent<MajorBreakable>();
                 *  if (m_lastDirectionKicked.HasValue) {
                 *      majorBreakableComponent.Break(m_lastDirectionKicked.Value.ToVector2());
                 *  } else {
                 *      majorBreakableComponent.Break(new Vector2(0, 0));
                 *  }
                 * } else if (gameObject.GetComponent<MinorBreakable>() != null) {
                 *  MinorBreakable minorBreakableComponent = gameObject.GetComponent<MinorBreakable>();
                 *  minorBreakableComponent.Break();
                 * } else {
                 *  Destroy(gameObject);
                 * }*/
                Destroy(gameObject);
                return;
            }
            return;
        }
Пример #14
0
        private async Task TryStartChaosAsync(CancellationToken cancellationToken)
        {
            // Must only be called when inside the semaphore
            TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "Enter TryStartChaosAsync");

            ChaosParameters parameters = new ChaosParameters();
            var             peak       = this.PeakMoveState(Command.StartChaos);

            if (peak.Equals(SchedulerState.ChaosScheduleActive))
            {
                if (!this.eventInstancesEnumerator.HasEvents())
                {
                    // schedule is empty, no point trying to check for events.
                    return;
                }

                DateTime datetimeNow = DateTime.UtcNow;

                // if current time is after current event, check next event
                while (this.eventInstancesEnumerator.Current.CompareTo(datetimeNow) == -1)
                {
                    this.eventInstancesEnumerator.MoveNext();
                }

                if (this.eventInstancesEnumerator.Current.Start <= datetimeNow &&
                    datetimeNow <= this.eventInstancesEnumerator.Current.End)
                {
                    // start chaos
                    parameters = new ChaosParameters(this.eventInstancesEnumerator.Current.ChaosParameters);

                    if (datetimeNow.Add(this.eventInstancesEnumerator.Current.End - datetimeNow) >= this.scheduleDescription.Schedule.ExpiryDate)
                    {
                        // Give Chaos time to run that will not go past expiry of schedule.
                        parameters.TimeToRun = this.scheduleDescription.Schedule.ExpiryDate - datetimeNow;
                    }
                    else
                    {
                        parameters.TimeToRun = this.eventInstancesEnumerator.Current.End - datetimeNow;
                    }

                    if (parameters.TimeToRun.TotalSeconds < 1)
                    {
                        TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "TryStartChaosAsync not starting Chaos because time to run Chaos is less than 1 second");
                        return;
                    }

                    try
                    {
                        await this.chaosMessageProcessor.ProcessStartChaosOldAsync(parameters, cancellationToken).ConfigureAwait(false);

                        TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "Chaos started.");
                    }
                    catch (Exception ex)
                    {
                        string exceptionMessage = string.Format("TryStartChaosAsync - Failed to start chaos. Reason {0}", ex.Message);
                        TestabilityTrace.TraceSource.WriteError(TraceComponent, exceptionMessage);

                        await this.chaosMessageProcessor.ProcessStopChaosOldAsync(true).ConfigureAwait(false);

                        await this.TryMoveStateAsync(Command.StopChaos, cancellationToken).ConfigureAwait(false);

                        ChaosUtility.ThrowOrAssertIfTrue("ChaosScheduler::TryStartChaosAsync", true, exceptionMessage);

                        return;
                    }

                    await this.TryMoveStateAsync(Command.StartChaos, cancellationToken).ConfigureAwait(false);

                    this.CheckStateAndThrowOnError(SchedulerState.ChaosScheduleActive);
                }
                //// else we are before the start of the next event, so we just simply wait until then and do nothing.
            }
        }
Пример #15
0
        private void SpawnObjects(GameObject[] selectedObjects)
        {
            ObjectPrefabSpawnCount = selectedObjects.Length;
            if (ObjectPrefabSpawnCount < 0 | selectedObjects == null)
            {
                if (ChaosConsole.debugMimicFlag)
                {
                    ETGModConsole.Log("[DEBUG] ERROR: Object array is empty or null! Nothing to spawn!");
                }
                return;
            }
            IntVector2 pos = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor);

            if (aiActor.IsFalling && !allowSpawnOverPit)
            {
                return;
            }
            if (GameManager.Instance.Dungeon.CellIsPit(specRigidbody.UnitCenter.ToVector3ZUp(0f)) && !allowSpawnOverPit)
            {
                return;
            }
            RoomHandler roomFromPosition     = GameManager.Instance.Dungeon.GetRoomFromPosition(pos);
            List <SpeculativeRigidbody> list = new List <SpeculativeRigidbody>();

            list.Add(specRigidbody);
            Vector2 unitBottomLeft = specRigidbody.UnitBottomLeft;

            for (int i = 0; i < ObjectPrefabSpawnCount; i++)
            {
                if (objectsToSpawn == null)
                {
                    return;
                }
                GameObject SelectedObject = selectedObjects[i];
                if (spawnRatCorpse)
                {
                    SelectedObject = ChaosPrefabs.RatCorpseNPC;
                }
                GameObject SpawnedObject = null;
                if (!usesExternalObjectArray)
                {
                    if (spawnRatCorpse)
                    {
                        SpawnedObject = Instantiate(SelectedObject, (specRigidbody.GetUnitCenter(ColliderType.HitBox) - new Vector2(0.6f, 0.6f)).ToVector3ZUp(), Quaternion.identity);
                    }
                    else if (SelectedObject.GetComponent <Chest>() != null)
                    {
                        if (GameManager.Instance.Dungeon.GetRoomFromPosition(aiActor.transform.PositionVector2().ToIntVector2()) != null)
                        {
                            // RoomHandler currentRoom = aiActor.GetAbsoluteParentRoom();
                            RoomHandler        currentRoom  = GameManager.Instance.Dungeon.GetRoomFromPosition(aiActor.transform.PositionVector2().ToIntVector2());
                            Chest              TruthChest   = SelectedObject.GetComponent <Chest>();
                            WeightedGameObject wChestObject = new WeightedGameObject();
                            wChestObject.rawGameObject = SelectedObject;
                            WeightedGameObjectCollection wChestObjectCollection = new WeightedGameObjectCollection();
                            wChestObjectCollection.Add(wChestObject);
                            Chest PlacedTruthChest = currentRoom.SpawnRoomRewardChest(wChestObjectCollection, aiActor.transform.PositionVector2().ToIntVector2());
                            SpawnedObject = PlacedTruthChest.gameObject;
                        }
                    }
                    else
                    {
                        SpawnedObject = Instantiate(SelectedObject, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor).ToVector3(), Quaternion.identity);
                    }
                    if (SpawnedObject == null)
                    {
                        return;
                    }
                }

                if (SpawnedObject == null)
                {
                    return;
                }

                if (ChaosConsole.DebugExceptions)
                {
                    ETGModConsole.Log("About to Spawn an object after death.");
                    ETGModConsole.Log("Object: " + SpawnedObject.name);
                    ETGModConsole.Log("AIActor:" + aiActor.GetActorName());
                }

                float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                float RandomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                if (!spawnRatCorpse)
                {
                    if (SpawnedObject.GetComponent <tk2dBaseSprite>() != null)
                    {
                        ChaosShaders.Instance.ApplyGlitchShader(null, SpawnedObject.GetComponent <tk2dBaseSprite>(), true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorProbFloat);
                    }
                    else if (SpawnedObject.GetComponentInChildren <tk2dBaseSprite>() != null && SpawnedObject.GetComponent <Chest>() == null)
                    {
                        ChaosShaders.Instance.ApplyGlitchShader(null, SpawnedObject.GetComponentInChildren <tk2dBaseSprite>(), true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorProbFloat);
                    }
                }
                if (SpawnedObject != null)
                {
                    if (!usesExternalObjectArray && SpawnedObject.GetComponent <MysteryMimicManController>() != null)
                    {
                        Destroy(SpawnedObject.GetComponent <MysteryMimicManController>());
                    }

                    if (!usesExternalObjectArray && SpawnedObject.GetComponent <TalkDoerLite>() != null)
                    {
                        TalkDoerLite talkdoerComponent = SpawnedObject.GetComponent <TalkDoerLite>();
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(talkdoerComponent);
                        if (SpawnedObject.name == ChaosPrefabs.RatCorpseNPC.name && !usesExternalObjectArray)
                        {
                            talkdoerComponent.transform.position.XY().GetAbsoluteRoom().TransferInteractableOwnershipToDungeon(talkdoerComponent);
                        }
                        else if (spawnRatCorpse)
                        {
                            talkdoerComponent.transform.position.XY().GetAbsoluteRoom().TransferInteractableOwnershipToDungeon(talkdoerComponent);
                        }
                        if (SpawnedObject.name.StartsWith(ChaosPrefabs.RatCorpseNPC.name))
                        {
                            talkdoerComponent.playmakerFsm.SetState("Set Mode");
                            ChaosUtility.AddHealthHaver(talkdoerComponent.gameObject, 60, flashesOnDamage: false, exploderSpawnsItem: ratCorpseSpawnsItemOnExplosion);
                            if (ratCorpseSpawnsKey)
                            {
                                HealthHaver ratCorpseHealthHaver = talkdoerComponent.gameObject.GetComponent <HealthHaver>();
                                ratCorpseHealthHaver.gameObject.AddComponent <ChaosSpawnGlitchObjectOnDeath>();
                                ChaosSpawnGlitchObjectOnDeath ratCorpseObjectSpawnOnDeath = ratCorpseHealthHaver.gameObject.GetComponent <ChaosSpawnGlitchObjectOnDeath>();
                                ratCorpseObjectSpawnOnDeath.spawnRatKey = true;
                            }
                        }
                    }

                    if (!usesExternalObjectArray && SpawnedObject.GetComponentInChildren <KickableObject>() != null && SpawnedObject.GetComponent <TalkDoerLite>() == null)
                    {
                        KickableObject kickableObjectComponent = SpawnedObject.GetComponentInChildren <KickableObject>();
                        kickableObjectComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(kickableObjectComponent);
                        kickableObjectComponent.ConfigureOnPlacement(kickableObjectComponent.transform.position.XY().GetAbsoluteRoom());
                    }

                    if (!usesExternalObjectArray && SpawnedObject.GetComponent <FlippableCover>() != null)
                    {
                        FlippableCover tableComponent = SpawnedObject.GetComponent <FlippableCover>();
                        tableComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(tableComponent);
                        tableComponent.ConfigureOnPlacement(tableComponent.transform.position.XY().GetAbsoluteRoom());
                        SpawnedObject.AddComponent <ChaosKickableObject>();
                        ChaosKickableObject chaosKickableComponent = SpawnedObject.GetComponent <ChaosKickableObject>();
                        chaosKickableComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(chaosKickableComponent);
                    }

                    if (!usesExternalObjectArray && SpawnedObject.GetComponent <NoteDoer>() != null)
                    {
                        NoteDoer noteComponent = SpawnedObject.GetComponent <NoteDoer>();
                        noteComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(noteComponent);
                        noteComponent.alreadyLocalized     = true;
                        noteComponent.useAdditionalStrings = false;
                        noteComponent.stringKey            = ("Here lies " + aiActor.GetActorName() + "\nHe was annoying anyways....");
                    }

                    /*if (!usesExternalObjectArray && SpawnedObject.GetComponent<HeartDispenser>() != null) {
                     *  HeartDispenser heartDispenserComponent = SpawnedObject.GetComponent<HeartDispenser>();
                     *  heartDispenserComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(heartDispenserComponent);
                     * }*/

                    if (SpawnedObject.GetComponentInChildren <SpeculativeRigidbody>() != null &&
                        SpawnedObject.GetComponentInChildren <KickableObject>() == null &&
                        SpawnedObject.GetComponent <TrapController>() == null &&
                        SpawnedObject.GetComponent <FlippableCover>() == null &&
                        SpawnedObject.GetComponent <Chest>() == null &&
                        SelectedObject.name != "NPC_ResourcefulRat_Beaten" &&
                        !usesExternalObjectArray)
                    {
                        SpeculativeRigidbody SpawnedObjectRigidBody = SpawnedObject.GetComponentInChildren <SpeculativeRigidbody>();
                        SpawnedObjectRigidBody.PrimaryPixelCollider.Enabled = false;
                        SpawnedObjectRigidBody.HitboxPixelCollider.Enabled  = false;
                        SpawnedObjectRigidBody.CollideWithOthers            = false;
                    }
                }

                if (SpawnedObject.GetComponentInChildren <SpeculativeRigidbody>() != null && SpawnedObject.name.ToLower().StartsWith("Table"))
                {
                    try {
                        SpeculativeRigidbody objectSpecRigidBody = SpawnedObject.GetComponentInChildren <SpeculativeRigidbody>();
                        objectSpecRigidBody.Initialize();
                        Vector2 a      = unitBottomLeft - (objectSpecRigidBody.UnitBottomLeft - SpawnedObject.transform.position.XY());
                        Vector2 vector = a + new Vector2(Mathf.Max(0f, specRigidbody.UnitDimensions.x - objectSpecRigidBody.UnitDimensions.x), 0f);
                        SpawnedObject.transform.position = Vector2.Lerp(a, vector, (ObjectPrefabSpawnCount != 1) ? i / (ObjectPrefabSpawnCount - 1f) : 0f);
                        objectSpecRigidBody.Reinitialize();
                        a      -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                        vector += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                        Vector2       a2            = Vector2.Lerp(a, vector, (ObjectPrefabSpawnCount != 1) ? i / (ObjectPrefabSpawnCount - 1f) : 0.5f);
                        IntVector2    intVector     = PhysicsEngine.UnitToPixel(a2 - SpawnedObject.transform.position.XY());
                        CollisionData collisionData = null;
                        if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(objectSpecRigidBody, intVector, out collisionData, true, true, null, false, list.ToArray()))
                        {
                            intVector = collisionData.NewPixelsToMove;
                        }
                        CollisionData.Pool.Free(ref collisionData);
                        SpawnedObject.transform.position += PhysicsEngine.PixelToUnit(intVector).ToVector3ZUp(1f);
                        objectSpecRigidBody.Reinitialize();
                        list.Add(objectSpecRigidBody);
                    } catch (Exception ex) {
                        if (ChaosConsole.DebugExceptions)
                        {
                            ETGModConsole.Log("[DEBUG]: Warning: Exception caught while setting up rigid body settings in ChaosSpawnGlitchedObjectONDeath!");
                            Debug.Log("Warning: Exception caught while setting up rigid body settings in ChaosSpawnGlitchedObjectONDeath!");
                            Debug.LogException(ex);
                        }
                    }
                }
            }
            if (list.Count > 0)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    for (int k = 0; k < list.Count; k++)
                    {
                        if (j != k)
                        {
                            list[j].RegisterGhostCollisionException(list[k]);
                        }
                    }
                }
            }
        }
        private void Start()
        {
            PlayerReflection.TargetPlayer = GameManager.Instance.PrimaryPlayer;
            PlayerReflection.MirrorSprite = MirrorSprite;
            if (!isGlitched)
            {
                if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER)
                {
                    CoopPlayerReflection.TargetPlayer = GameManager.Instance.SecondaryPlayer;
                    CoopPlayerReflection.MirrorSprite = MirrorSprite;
                }
                else
                {
                    CoopPlayerReflection.gameObject.SetActive(false);
                }
            }
            else
            {
                PlayerReflection.gameObject.SetActive(false);
                CoopPlayerReflection.gameObject.SetActive(false);
                tk2dBaseSprite[] AllMirrorSprites = gameObject.GetComponents <tk2dBaseSprite>();
                if (AllMirrorSprites != null && AllMirrorSprites.Length > 0)
                {
                    ChaosShaders.Instance.ApplyGlitchShader(null, AllMirrorSprites[0]);
                }
            }

            IntVector2 MirrorChestPosition = (base.transform.position.IntXY(VectorConversions.Round) + new IntVector2(0, -2) - m_ParentRoom.area.basePosition);

            if (spawnBellosChest)
            {
                MirrorChest = ChaosUtility.GenerateChest(MirrorChestPosition, m_ParentRoom, PickupObject.ItemQuality.A, 0, false);
                MirrorChest.forceContentIds = new List <int>()
                {
                    435, 493
                };
            }
            else
            {
                MirrorChest = ChaosUtility.GenerateChest(MirrorChestPosition, m_ParentRoom, null, -1f);
            }
            MirrorChest.PreventFuse = true;
            SpriteOutlineManager.RemoveOutlineFromSprite(MirrorChest.sprite, false);
            Transform transform = MirrorChest.gameObject.transform.Find("Shadow");

            if (transform)
            {
                MirrorChest.ShadowSprite = transform.GetComponent <tk2dSprite>();
            }
            MirrorChest.IsMirrorChest = true;
            MirrorChest.ConfigureOnPlacement(m_ParentRoom);
            m_ParentRoom.RegisterInteractable(MirrorChest);
            if (spawnBellosChest)
            {
                MirrorChest.DeregisterChestOnMinimap();
            }
            if (MirrorChest.majorBreakable)
            {
                MirrorChest.majorBreakable.TemporarilyInvulnerable = true;
            }
            ChestSprite = MirrorChest.sprite;
            ChestSprite.renderer.enabled = false;
            ChestReflection.TargetSprite = ChestSprite;
            ChestReflection.MirrorSprite = MirrorSprite;
            SpeculativeRigidbody specRigidbody = MirrorSprite.specRigidbody;

            specRigidbody.OnRigidbodyCollision = (SpeculativeRigidbody.OnRigidbodyCollisionDelegate)Delegate.Combine(specRigidbody.OnRigidbodyCollision, new SpeculativeRigidbody.OnRigidbodyCollisionDelegate(HandleRigidbodyCollisionWithMirror));
            MinorBreakable componentInChildren = GetComponentInChildren <MinorBreakable>();

            componentInChildren.OnlyBrokenByCode = true;
            componentInChildren.heightOffGround  = 4f;

            IPlayerInteractable[] TableInterfacesInChildren = GameObjectExtensions.GetInterfacesInChildren <IPlayerInteractable>(gameObject);
            for (int i = 0; i < TableInterfacesInChildren.Length; i++)
            {
                if (!m_ParentRoom.IsRegistered(TableInterfacesInChildren[i]))
                {
                    m_ParentRoom.RegisterInteractable(TableInterfacesInChildren[i]);
                }
            }
            // Destroy(gameObject.GetComponent<MirrorController>());

            // SpeculativeRigidbody InteractableRigidMirror = gameObject.GetComponent<SpeculativeRigidbody>();
            // InteractableRigidMirror.Initialize();
            // PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(InteractableRigidMirror, null, false);
        }
Пример #17
0
        public void MarkAllUnsafeEntities()
        {
            TestabilityTrace.TraceSource.WriteNoise(TraceType, "Inside of MarkAllUnsafeEntities ...");

            var codepackages = this.GetAllCodePackages().ToArray();

            foreach (var cp in codepackages)
            {
                CodePackageEntity codePackage = cp;
                var node = this.Nodes.FirstOrDefault(n => n.CurrentNodeInfo.NodeName == codePackage.NodeName);

                ChaosUtility.ThrowOrAssertIfTrue(
                    ChaosConstants.MarkReplicaAsInTransition_NodeFaulted_TelemetryId,
                    node == null,
                    string.Format(
                        "Node entity {0} not found for code package {1}:{2}:{3}.",
                        codePackage.NodeName,
                        codePackage.ParentApplicationEntity.Application.ApplicationName,
                        codePackage.CodePackageResult.ServiceManifestName,
                        codePackage.CodePackageResult.CodePackageName));

                if (codePackage.Health.AggregatedHealthState != HealthState.Ok)
                {
                    codePackage.MarkCodePackageAsUnsafeToFault();
                    node.MarkNodeAsUnsafeToFault();
                }
                else
                {
                    // TODO: RDBug 7635808 : Test and see if DeployedPartition
                    // loop in the Chaos engine mark unsafe can be eliminated
                    //
                    var deployedPartitions = codePackage.DeployedPartitions;

                    foreach (var deployedPartition in deployedPartitions)
                    {
                        if (deployedPartition.GetPartitionFaultTolerance() <= 0 ||
                            deployedPartition.Partition.HealthState != HealthState.Ok)
                        {
                            codePackage.MarkCodePackageAsUnsafeToFault();
                            node.MarkNodeAsUnsafeToFault();
                        }
                    }
                }
            }

            // One way would have been to go through every replica and along with its health also check its ancestors' health
            // but we know that a partition's health state always reflect the worst healthstate among its replicas, so going
            // through the partitions is enough
            //
            var allPartitions = this.GetAllPartitions(null, null, !this.ShouldFaultSystem).ToArray();

            foreach (var p in allPartitions)
            {
                PartitionEntity partition = p;

                if (partition.GetPartitionFaultTolerance() <= 0 ||
                    partition.Partition.HealthState != HealthState.Ok ||
                    partition.ParentServiceEntity.Service.HealthState != HealthState.Ok ||
                    partition.ParentServiceEntity.ParentApplicationEntity.Application.HealthState != HealthState.Ok)
                {
                    this.MarkPartitionAsUnsafe(partition);
                }
            }

            foreach (var unhealthyNode in this.Nodes.Where(n => n.CurrentNodeInfo.HealthState != HealthState.Ok))
            {
                unhealthyNode.MarkNodeAsUnsafeToFault();
            }
        }
        public IEnumerator ResizeEnemy(AIActor target, Vector2 ScaleValue, bool onlyDoRescale = true, bool isBigEnemy = false, bool delayed = false)
        {
            if (target == null | ScaleValue == null)
            {
                yield break;
            }

            if (delayed)
            {
                yield return(new WaitForSeconds(0.8f));
            }

            HealthHaver targetHealthHaver = target.GetComponent <HealthHaver>();
            float       knockBackValue    = 2f;

            int cachedLayer        = target.gameObject.layer;
            int cachedOutlineLayer = cachedLayer;

            target.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            cachedOutlineLayer      = SpriteOutlineManager.ChangeOutlineLayer(target.sprite, LayerMask.NameToLayer("Unpixelated"));
            // target.ClearPath();
            if (!onlyDoRescale)
            {
                if (target.knockbackDoer)
                {
                    if (isBigEnemy)
                    {
                        target.knockbackDoer.weight *= knockBackValue;
                    }
                    else
                    {
                        target.knockbackDoer.weight /= knockBackValue;
                    }
                }
                if (!isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!targetHealthHaver.IsBoss && !ChaosLists.DontDieOnCollisionWhenTinyGUIDList.Contains(target.EnemyGuid))
                    {
                        target.DiesOnCollison   = true;
                        target.EnemySwitchState = "Blobulin";
                    }

                    target.CollisionDamage          = 0f;
                    target.CollisionDamageTypes     = 0;
                    target.PreventFallingInPitsEver = false;
                    // target.CollisionKnockbackStrength = target.CollisionKnockbackStrength - 0.6f;
                    target.PreventBlackPhantom = true;

                    if (targetHealthHaver.IsBoss)
                    {
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 1.5f, null, false);
                        }
                        // aiActor.BaseMovementSpeed *= 1.1f;
                        // aiActor.MovementSpeed *= 1.1f;
                    }
                    else if (targetHealthHaver != null && !onlyDoRescale)
                    {
                        target.BaseMovementSpeed *= 1.15f;
                        target.MovementSpeed     *= 1.15f;
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 2f, null, false);
                        }
                    }
                    target.OverrideDisplayName = ("Tiny " + target.GetActorName());
                }
                else if (isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!target.IsFlying && !targetHealthHaver.IsBoss && !ChaosLists.OverrideFallIntoPitsList.Contains(target.EnemyGuid))
                    {
                        target.PreventFallingInPitsEver = true;
                    }
                    if (targetHealthHaver.IsBoss)
                    {
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.2f, null, false);
                        // aiActor.BaseMovementSpeed *= 0.8f;
                        // aiActor.MovementSpeed *= 0.8f;
                    }
                    else
                    {
                        target.BaseMovementSpeed /= 1.25f;
                        target.MovementSpeed     /= 1.25f;
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.5f, null, false);
                    }
                    target.OverrideDisplayName = ("Big " + target.GetActorName());
                }
            }
            Vector2 startScale = target.EnemyScale;
            float   elapsed    = 0f;
            float   ShrinkTime = 0.5f;

            while (elapsed < ShrinkTime)
            {
                elapsed          += BraveTime.DeltaTime;
                target.EnemyScale = Vector2.Lerp(startScale, ScaleValue, elapsed / ShrinkTime);
                if (target.specRigidbody)
                {
                    target.specRigidbody.UpdateCollidersOnScale = true;
                    target.specRigidbody.RegenerateColliders    = true;
                }
                yield return(null);
            }
            yield return(new WaitForSeconds(1.5f));

            ChaosUtility.CorrectForWalls(target);

            /*if (target.CorpseObject != null) {
             *  target.CorpseObject.transform.localScale = ScaleValue.ToVector3ZUp(1f);
             *  int cachedCorpseLayer = target.CorpseObject.layer;
             *  int cachedCorpseOutlineLayer = cachedCorpseLayer;
             *  target.CorpseObject.layer = LayerMask.NameToLayer("CorpseUnpixelated");
             *  cachedCorpseOutlineLayer = SpriteOutlineManager.ChangeOutlineLayer(target.CorpseObject.GetComponentInChildren<tk2dBaseSprite>(), LayerMask.NameToLayer("CorpseUnpixelated"));
             * }*/
            yield break;
        }
            protected override async Task ExecuteActionAsync(FabricTestContext testContext, GetClusterStateSnapshotAction action, CancellationToken cancellationToken)
            {
                Dictionary <string, int> ExceptionHistory = new Dictionary <string, int>();

                int retries = 0;

                GetClusterStateSnapshotAction.ServiceCount   = 0;
                GetClusterStateSnapshotAction.PartitionCount = 0;
                GetClusterStateSnapshotAction.ReplicaCount   = 0;

                Stopwatch stopWatch = Stopwatch.StartNew();

                ClusterStateSnapshot clusterSnapshot = null;

                do
                {
                    ++retries;

                    await Task.Delay(Constants.DefaultChaosSnapshotRecaptureBackoffInterval, cancellationToken).ConfigureAwait(false);

                    try
                    {
                        clusterSnapshot = await this.CaptureClusterStateSnapshotAndPopulateEntitiesAsync(
                            testContext,
                            action,
                            cancellationToken).ConfigureAwait(false);
                    }
                    catch (Exception exception) when(exception is FabricException || exception is ChaosInconsistentClusterSnapshotException)
                    {
                        string exceptionString = exception.Message;

                        if (ExceptionHistory.ContainsKey(exceptionString))
                        {
                            ExceptionHistory[exceptionString]++;
                        }
                        else
                        {
                            ExceptionHistory[exceptionString] = 1;
                        }
                    }

                    string allExceptions = string.Join(ExceptionDelimeter, ExceptionHistory);

                    if (retries >= action.MaximumNumberOfRetries)
                    {
                        TestabilityTrace.TraceSource.WriteWarning(TraceType, "While taking a consistent cluster snapshot, following exceptions occurred: {0}", allExceptions);
                    }

                    ChaosUtility.ThrowOrAssertIfTrue(
                        ChaosConstants.GetClusterSnapshotAction_MaximumNumberOfRetriesAchieved_TelemetryId,
                        retries >= action.MaximumNumberOfRetries,
                        string.Format(StringResources.ChaosEngineError_GetClusterSnapshotAction_MaximumNumberOfRetriesAchieved, action.MaximumNumberOfRetries, allExceptions));
                }while (clusterSnapshot == null);

                stopWatch.Stop();

                var elapsedInGatherSnapshot = stopWatch.Elapsed;

                stopWatch = Stopwatch.StartNew();

                clusterSnapshot.ApplyChaosTargetFilter(action.ChaosTargetFilter);

                clusterSnapshot.MarkAllUnsafeEntities();

                stopWatch.Stop();

                var elapsedInMarkAllUnsafe = stopWatch.Elapsed;

                if (UniformRandomNumberGenerator.NextDouble() < action.TelemetrySamplingProbability)
                {
                    FabricEvents.Events.ChaosSnapshot(
                        Guid.NewGuid().ToString(),
                        clusterSnapshot.Nodes.Count,
                        clusterSnapshot.Applications.Count,
                        GetClusterStateSnapshotAction.ServiceCount,
                        GetClusterStateSnapshotAction.PartitionCount,
                        GetClusterStateSnapshotAction.ReplicaCount,
                        elapsedInGatherSnapshot.TotalSeconds,
                        elapsedInMarkAllUnsafe.TotalSeconds,
                        retries);
                }

                TestabilityTrace.TraceSource.WriteInfo(TraceType, "For '{0}' nodes, '{1}' apps, '{2}' services, '{3}' partitions, '{4}' replicas, snapshot took '{5}', mark unsafe took '{6}', took '{7}' retries.",
                                                       clusterSnapshot.Nodes.Count,
                                                       clusterSnapshot.Applications.Count,
                                                       GetClusterStateSnapshotAction.ServiceCount,
                                                       GetClusterStateSnapshotAction.PartitionCount,
                                                       GetClusterStateSnapshotAction.ReplicaCount,
                                                       elapsedInGatherSnapshot,
                                                       elapsedInMarkAllUnsafe,
                                                       retries);

                action.Result     = clusterSnapshot;
                ResultTraceString = "GetClusterStateSnapshotAction succeeded";
            }
Пример #20
0
        private void EnemyModRandomizer(AIActor targetActor)
        {
            // Finding too many issues being caused with Bosses to allow shader modifications on them.
            if (targetActor.healthHaver != null && targetActor.healthHaver.IsBoss)
            {
                return;
            }

            bool hasAltSkin = false;
            bool hasShader  = false;

            if (GameManager.Instance.Dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.PHOBOSGEON)
            {
                if (targetActor.EnemyGuid == "ba928393c8ed47819c2c5f593100a5bc")
                {
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.StoneCubeCollection_West);
                }
            }

            if (ChaosConsole.isHardMode | ChaosConsole.isUltraMode)
            {
                if (ChaosLists.PreventBeingJammedOverrideList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventBlackPhantom = true;
                }
                if (ChaosLists.PreventDeathOnBossKillList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventAutoKillOnBossDeath = true;
                }
                if (targetActor.EnemyGuid == "eeb33c3a5a8e4eaaaaf39a743e8767bc")
                {
                    targetActor.AlwaysShowOffscreenArrow = true;
                }

                if ((targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | targetActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259") && UnityEngine.Random.value < 0.3f)
                {
                    if (RedShotGunMan.BootlegRedShotGunManCollection == null)
                    {
                        RedShotGunMan.Init();
                    }
                    targetActor.optionalPalette             = null;
                    targetActor.procedurallyOutlined        = false;
                    targetActor.sprite.OverrideMaterialMode = tk2dBaseSprite.SpriteMaterialOverrideMode.NONE;
                    targetActor.sprite.renderer.material.SetTexture("_PaletteTex", null);
                    FieldInfo field = typeof(AIActor).GetField("m_isPaletteSwapped", BindingFlags.Instance | BindingFlags.NonPublic);
                    field.SetValue(targetActor, false);
                    if (targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47")
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RedShotGunMan.BootlegRedShotGunManCollection);
                    }
                    else
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BlueShotGunMan.BootlegBlueShotGunManCollection);
                    }
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if ((targetActor.EnemyGuid == "01972dee89fc4404a5c408d50007dad5" | targetActor.EnemyGuid == "db35531e66ce41cbb81d507a34366dfe") && UnityEngine.Random.value < 0.3f)
                {
                    float Selector = UnityEngine.Random.Range(0, 3);
                    if (Selector < 1)
                    {
                        if (BulletMan.BootlegBulletManCollection == null)
                        {
                            BulletMan.Init(targetActor);
                        }
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManMonochromeCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("1-Bit " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 1)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManUpsideDownCollection);
                        targetActor.OverrideDisplayName = ("Bizarro " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 2)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletMan.BootlegBulletManCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    return;
                }
                if (targetActor.EnemyGuid == "88b6b6a93d4b4234a67844ef4728382c" && UnityEngine.Random.value < 0.32f)
                {
                    if (BulletManBandana.BootlegBulletManBandanaCollection == null)
                    {
                        BulletManBandana.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletManBandana.BootlegBulletManBandanaCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if (targetActor.EnemyGuid == "14ea47ff46b54bb4a98f91ffcffb656d" && BraveUtility.RandomBool())
                {
                    if (RatGrenade.RatGrenadeCollection == null)
                    {
                        RatGrenade.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RatGrenade.RatGrenadeCollection);
                    targetActor.healthHaver.gameObject.AddComponent <ChaosExplodeOnDeath>();
                    ExplodeOnDeath RatExplodeComponent = targetActor.healthHaver.gameObject.GetComponent <ExplodeOnDeath>();
                    RatExplodeComponent.explosionData            = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().explosionData;
                    RatExplodeComponent.deathType                = OnDeathBehavior.DeathType.Death;
                    RatExplodeComponent.triggerName              = string.Empty;
                    RatExplodeComponent.immuneToIBombApp         = false;
                    RatExplodeComponent.LinearChainExplosion     = false;
                    RatExplodeComponent.LinearChainExplosionData = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().LinearChainExplosionData;
                    targetActor.CorpseObject = null;
                    hasAltSkin = true;
                    return;
                }

                if (targetActor.EnemyGuid == "2feb50a6a40f4f50982e89fd276f6f15" && BraveUtility.RandomBool())
                {
                    if (Bullat.BootlegBullatCollection == null)
                    {
                        Bullat.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: Bullat.BootlegBullatCollection);
                    AIActor TinyBlobulord = EnemyDatabase.GetOrLoadByGuid("d1c9781fdac54d9e8498ed89210a0238");
                    targetActor.behaviorSpeculator.OtherBehaviors    = TinyBlobulord.behaviorSpeculator.OtherBehaviors;
                    targetActor.behaviorSpeculator.TargetBehaviors   = TinyBlobulord.behaviorSpeculator.TargetBehaviors;
                    targetActor.behaviorSpeculator.OverrideBehaviors = TinyBlobulord.behaviorSpeculator.OverrideBehaviors;
                    targetActor.behaviorSpeculator.AttackBehaviors   = TinyBlobulord.behaviorSpeculator.AttackBehaviors;
                    targetActor.behaviorSpeculator.MovementBehaviors = TinyBlobulord.behaviorSpeculator.MovementBehaviors;
                    targetActor.DiesOnCollison       = true;
                    targetActor.procedurallyOutlined = false;
                    targetActor.OverrideDisplayName  = ("Bootleg " + targetActor.GetActorName());
                    hasAltSkin = true;
                    return;
                }

                if (!hasAltSkin && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4")
                {
                    if (UnityEngine.Random.value <= 0.2f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeHologram(targetActor, BraveUtility.RandomBool());
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.16f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.ApplySpaceShader(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.15f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeRainbow(targetActor);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.1f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeCosmicHorror(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.065f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeGalaxy(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                }
            }

            if (!hasAltSkin && !hasShader && ChaosConsole.GlitchEnemies && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4" && !targetActor.IsBlackPhantom && UnityEngine.Random.value <= ChaosConsole.GlitchRandomActors)
            {
                float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                float RnadomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                if (!targetActor.sprite.usesOverrideMaterial && !ChaosLists.DontGlitchMeList.Contains(targetActor.EnemyGuid))
                {
                    ChaosShaders.Instance.BecomeGlitched(targetActor, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RnadomColorIntensityFloat);
                    if (!targetActor.healthHaver.IsBoss && !ChaosLists.blobsAndCritters.Contains(targetActor.EnemyGuid) && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null)
                    {
                        if (UnityEngine.Random.value <= 0.25)
                        {
                            targetActor.gameObject.AddComponent <ChaosSpawnGlitchObjectOnDeath>();
                        }
                    }
                    ChaosGlitchedEnemies.GlitchExistingEnemy(targetActor);
                    if (!ChaosConsole.randomEnemySizeEnabled)
                    {
                        if (targetActor.healthHaver != null)
                        {
                            if (!targetActor.healthHaver.IsBoss)
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.5f, null, false);
                            }
                            else
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.25f, null, false);
                            }
                        }
                    }
                    if (UnityEngine.Random.value <= 0.1f && targetActor.EnemyGuid != "4d37ce3d666b4ddda8039929225b7ede" && targetActor.EnemyGuid != "19b420dec96d4e9ea4aebc3398c0ba7a" && targetActor.GetComponent <ExplodeOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchEnemyOnDeath>() == null)
                    {
                        try { targetActor.gameObject.AddComponent <ChaosExplodeOnDeath>(); } catch (Exception) { }
                    }
                }
                return;
            }
        }
Пример #21
0
        public void MoveReplica(string nodeName, Guid activityId = default(Guid))
        {
            // Confirm replica is available to fault
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.MoveReplica_Unavailable_TelemetryId,
                !this.IsAvailableToFault,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_ReplicaInTransition,
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            // If not in unsafe mode then confirm that the fault tolerance of this partition is at least 1
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.MoveReplica_PartitionNotFaultTolerant_TelemetryId,
                this.ParentPartitionEntity.GetPartitionFaultTolerance() <= 0 && !this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot.UnsafeModeEnabled,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_PartitionNotFaultTolerantInSafeMode,
                    this.ParentPartitionEntity.Partition.PartitionId(),
                    this),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking current replica {1} as Faulted with MarkReplicaAsInTransitionInternal",
                activityId,
                this);

            // Mark current replica as faulted
            this.MarkReplicaAsInTransitionInternal(activityId);


            //
            // Mark the node moving to and any replica/code package on new node as unavailable
            //
            var clusterNode = this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot.Nodes.FirstOrDefault(n => n.CurrentNodeInfo.NodeName == nodeName);

            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.MoveReplica_InvalidNode_TelemetryId,
                clusterNode == null,
                string.Format(
                    StringResources.ChaosEngineError_ReplicaEntity_NodeInfoNotFound,
                    nodeName),
                this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.ClusterSnapshot);

            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking node {1} to which the replica {2} is moving as Unavailable",
                activityId,
                clusterNode.CurrentNodeInfo.NodeName,
                this);

            // The new node where the current replica is moving to is marked as used and cannot be used for any other node faults
            // after this fault
            clusterNode.MarkNodeAsUnavailableForFaults();

            // check if new node already has a replica (In case of MovePrimary) and if so fault it.
            var newNodeReplica = this.ParentPartitionEntity.FindReplicaEntityGivenNodeName(nodeName);

            if (newNodeReplica != null)
            {
                TestabilityTrace.TraceSource.WriteInfo(
                    TraceType,
                    "{0}: Marking newNodeReplica {1} as Faulted with MarkReplicaAsInTransitionInternal",
                    activityId,
                    newNodeReplica);

                // We call the internal version of the method since it is possible the replica has already been faulted by the call to
                // MarkReplicaAsInTransitionInternal for this current replica due to GetPartitionFaultTolerance() <= 0
                newNodeReplica.MarkReplicaAsInTransitionInternal(activityId);

                // Since we are moving to this new replica we want to mark its code package as not available for faults
                var newNodeReplicaCodePackage = this.ParentPartitionEntity.ParentServiceEntity.ParentApplicationEntity.GetCodePackagEntityForReplica(newNodeReplica);
                if (newNodeReplicaCodePackage != null)
                {
                    TestabilityTrace.TraceSource.WriteInfo(
                        TraceType,
                        "{0}: Marking newNodeReplicaCodepackage {1} as Unavailable",
                        activityId,
                        newNodeReplicaCodePackage);

                    newNodeReplicaCodePackage.MarkCodePackageAsUnavailableForFaults();
                }
            }
        }
        public static void Init(AIActor sourceActor = null)
        {
            if (sourceActor == null)
            {
                sourceActor = EnemyDatabase.GetOrLoadByGuid("88b6b6a93d4b4234a67844ef4728382c");
            }

            BootlegBulletManBandana = new List <Texture2D>()
            {
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_leap_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_leap_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_leap_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_leap_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_leap_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_idle_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_idle_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_leap_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_leap_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_leap_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_leap_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_right_leap_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_back_south_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_back_south_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_back_south_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_back_south_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_front_north_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_front_north_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_front_north_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_front_north_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_front_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_left_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_front_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_death_right_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_die_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_hand_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_hit_back_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_hit_back_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_hit_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_hit_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_idle_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_pitfall_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_pitfall_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_pitfall_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_pitfall_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_pitfall_right_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_left_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_run_right_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_shooting_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_shooting_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_spawn_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_spawn_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_spawn_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_left_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_left_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_surprise_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_idle_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletManBandana\\bullet_cover_left_idle_002.png")
            };
            BootlegBulletManBandanaCollection = ChaosUtility.BuildSpriteCollection(sourceActor.sprite.Collection, null, BootlegBulletManBandana, ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"), true);
            DontDestroyOnLoad(BootlegBulletManBandanaCollection);
        }
Пример #23
0
        /// <summary>
        /// Attempt to recover from status of the Chaos schedule and Chaos scheduler status from RD. Chaos will be running if it should be running.
        /// </summary>
        /// <returns>boolean representing if the recovery was successful.</returns>
        private async Task <bool> TryRecoveryFromSchedule(CancellationToken cancellationToken)
        {
            TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "TryRecoveryFromSchedule entered.");

            SchedulerState           schedulerState           = new SchedulerState(SchedulerState.NoChaosScheduleStopped);
            ChaosScheduleDescription chaosScheduleDescription = new ChaosScheduleDescription();

            this.StatusDictionary = this.StatusDictionary ?? await this.StateManager.GetOrAddAsync <IReliableDictionary <string, byte[]> >(FASConstants.ChaosSchedulerStateName).ConfigureAwait(false);

            using (ITransaction tx = this.StateManager.CreateTransaction())
            {
                var schedulerResult = await FaultAnalysisServiceUtility.RunAndReportFaultOnRepeatedFailure <ConditionalValue <byte[]> >(
                    Guid.Empty,
                    () => this.StatusDictionary.TryGetValueAsync(tx, FASConstants.ChaosSchedulerStatusDictionaryScheduleKey),
                    this.partition,
                    "RestartRecoveryAsync",
                    FASConstants.MaxRetriesForReliableDictionary,
                    cancellationToken).ConfigureAwait(false);

                var schedulerStateResult = await FaultAnalysisServiceUtility.RunAndReportFaultOnRepeatedFailure <ConditionalValue <byte[]> >(
                    Guid.Empty,
                    () => this.StatusDictionary.TryGetValueAsync(tx, FASConstants.ChaosSchedulerStatusDictionaryStateKey),
                    this.partition,
                    "RestartRecoveryAsync",
                    FASConstants.MaxRetriesForReliableDictionary,
                    cancellationToken).ConfigureAwait(false);

                if (!schedulerResult.HasValue || !schedulerStateResult.HasValue)
                {
                    TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "TryRecoveryFromSchedule failed to recover. Scheduler state or schedule was non existent.");
                    return(false);
                }

                chaosScheduleDescription.FromBytes(schedulerResult.Value);
                schedulerState.FromBytes(schedulerStateResult.Value);

                await tx.CommitAsync().ConfigureAwait(false);
            }

            try
            {
                if (schedulerState.ScheduleStatus.Equals(ChaosScheduleStatus.Pending))
                {
                    TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "TryRecoveryFromSchedule scheduler state is pending");
                    await this.SetScheduleInternalAsync(chaosScheduleDescription, cancellationToken).ConfigureAwait(false);
                }
                else if (schedulerState.ScheduleStatus.Equals(ChaosScheduleStatus.Active))
                {
                    TestabilityTrace.TraceSource.WriteInfo(TraceComponent, "TryRecoveryFromSchedule scheduler state is active");
                    await this.SetScheduleAndTryResumeAsync(chaosScheduleDescription, cancellationToken).ConfigureAwait(false);
                }

                // expire and stopped ChaosScheduleStatus will result in no action being taken
                // the schedule and status is still correct in the RD because that is where the values were read from
            }
            catch (System.ArgumentException ex)
            {
                string exceptionMessage = string.Format("RestartRecoveryAsync - failed to recover chaos schedule. Reason {0}", ex.Message);
                TestabilityTrace.TraceSource.WriteError(TraceComponent, exceptionMessage);

                ChaosUtility.ThrowOrAssertIfTrue("ChaosScheduler::RestartRecoveryAsync", true, exceptionMessage);
            }

            return(true);
        }
Пример #24
0
        public static void Init(AIActor sourceActor = null)
        {
            if (sourceActor == null)
            {
                sourceActor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
            }

            BootlegBulletMan = new List <Texture2D>()
            {
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_leap_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_leap_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_leap_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_leap_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_leap_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_idle_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_idle_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_leap_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_leap_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_leap_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_leap_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_right_leap_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_back_south_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_back_south_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_back_south_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_back_south_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_front_north_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_front_north_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_front_north_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_front_north_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_front_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_left_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_front_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_front_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_front_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_front_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_front_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_side_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_side_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_side_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_death_right_side_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_die_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_hand_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_hit_back_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_hit_back_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_hit_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_hit_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_idle_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_pitfall_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_pitfall_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_pitfall_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_pitfall_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_pitfall_right_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_left_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_005.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_run_right_back_006.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_shooting_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_shooting_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_spawn_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_spawn_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_spawn_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_left_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_left_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_left_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_left_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_right_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_right_002.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_right_003.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_surprise_right_004.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_idle_001.png"),
                ResourceExtractor.GetTextureFromResource("Textures\\BootlegEnemies\\BulletMan\\bullet_cover_left_idle_002.png")
            };
            // foreach (Texture2D texture in BootlegBulletMan) { DontDestroyOnLoad(texture); }
            BootlegBulletManCollection = ChaosUtility.BuildSpriteCollection(sourceActor.sprite.Collection, null, BootlegBulletMan, ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"), true);
            DontDestroyOnLoad(BootlegBulletManCollection);
        }
        private void TransitionToDepart(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip)
        {
            if (!m_depatureIsPlayerless)
            {
                if (OverrideTargetFloor == GlobalDungeonData.ValidTilesets.PHOBOSGEON)
                {
                    Pixelator.Instance.RegisterAdditionalRenderPass(ChaosShaders.GlitchScreenShader);
                }
            }

            GameManager.Instance.MainCameraController.DoDelayedScreenShake(departureShake, 0.25f, null);
            if (!m_depatureIsPlayerless)
            {
                for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
                {
                    GameManager.Instance.AllPlayers[i].PrepareForSceneTransition();
                }
                // float delay = 0.5f;
                float delay = 0.7f;
                Pixelator.Instance.FadeToBlack(delay, false, 0f);
                GameUIRoot.Instance.HideCoreUI(string.Empty);
                GameUIRoot.Instance.ToggleLowerPanels(false, false, string.Empty);
                if (GameManager.Instance.CurrentGameMode == GameManager.GameMode.SUPERBOSSRUSH)
                {
                    GameManager.Instance.DelayedLoadBossrushFloor(delay);
                }
                else if (GameManager.Instance.CurrentGameMode == GameManager.GameMode.BOSSRUSH)
                {
                    GameManager.Instance.DelayedLoadBossrushFloor(delay);
                }
                else
                {
                    if (!GameManager.Instance.IsFoyer && GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.NONE)
                    {
                        GlobalDungeonData.ValidTilesets nextTileset = GameManager.Instance.GetNextTileset(GameManager.Instance.Dungeon.tileIndices.tilesetId);
                        GameManager.DoMidgameSave(nextTileset);
                    }
                    if (UsesOverrideTargetFloor)
                    {
                        GlobalDungeonData.ValidTilesets overrideTargetFloor = OverrideTargetFloor;
                        if (overrideTargetFloor == GlobalDungeonData.ValidTilesets.CATACOMBGEON)
                        {
                            GameManager.Instance.DelayedLoadCustomLevel(delay, "tt_catacombs");
                        }
                        else if (overrideTargetFloor == GlobalDungeonData.ValidTilesets.FORGEGEON)
                        {
                            GameManager.Instance.DelayedLoadCustomLevel(delay, "tt_forge");
                        }
                        else if (overrideTargetFloor == GlobalDungeonData.ValidTilesets.OFFICEGEON)
                        {
                            ChaosConsole.elevatorHasBeenUsed = true;
                            if (BraveUtility.RandomBool())
                            {
                                string[] flowPath = new string[] { "custom_glitchchest_flow", "custom_glitchchestalt_flow", "custom_glitch_flow" };
                                ChaosUtility.PrepareGlitchFlow(BraveUtility.RandomElement(flowPath));
                                GameManager.Instance.DelayedLoadNextLevel(delay);
                            }
                            else
                            {
                                string[] flows = new string[] { "custom_glitchchest_flow", "custom_glitchchestalt_flow" };
                                GameManager.Instance.StartCoroutine(ChaosUtility.DelayedGlitchLevelLoad(delay, BraveUtility.RandomElement(flows), useNakatomiTileset: BraveUtility.RandomBool()));
                            }
                        }
                        else if (overrideTargetFloor == GlobalDungeonData.ValidTilesets.PHOBOSGEON)
                        {
                            ChaosUtility.RatDungeon = DungeonDatabase.GetOrLoadByName("Base_ResourcefulRat");
                            ChaosUtility.RatDungeon.LevelOverrideType = GameManager.LevelOverrideState.NONE;
                            // ChaosUtility.RatDungeon.tileIndices.tilesetId = GlobalDungeonData.ValidTilesets.PHOBOSGEON;
                            // ChaosUtility.RatDungeon.tileIndices.tilesetId = GlobalDungeonData.ValidTilesets.JUNGLEGEON;
                            ChaosPrefabs.InitCanyonTileSet(ChaosUtility.RatDungeon, GlobalDungeonData.ValidTilesets.PHOBOSGEON);
                            GameManager.Instance.StartCoroutine(ChaosUtility.DelayedGlitchLevelLoad(delay, "SecretGlitchFloor_Flow", true));
                        }
                        else
                        {
                            GameManager.Instance.DelayedLoadNextLevel(delay);
                        }
                    }
                    else
                    {
                        GameManager.Instance.DelayedLoadNextLevel(delay);
                    }
                    AkSoundEngine.PostEvent("Stop_MUS_All", gameObject);
                }
            }
            elevatorFloor.SetActive(false);
            animator.AnimationCompleted = (Action <tk2dSpriteAnimator, tk2dSpriteAnimationClip>)Delegate.Remove(animator.AnimationCompleted, new Action <tk2dSpriteAnimator, tk2dSpriteAnimationClip>(TransitionToDepart));
            animator.PlayAndDisableObject(elevatorDepartAnimName, null);
        }
Пример #26
0
        public void FaultCodePackage(Guid activityId = default(Guid))
        {
            // Confirm first that neither the code package nor any of its children entities is faulted
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultCodePackage_CodepackageEntityInTransition_TelemetryId,
                !this.IsAvailableToFault,
                string.Format(
                    StringResources.ChaosEngineError_CodePackageEntityInTransition,
                    this),
                this.ParentApplicationEntity.ClusterSnapshot);

            var node = this.ParentApplicationEntity.ClusterSnapshot.Nodes.FirstOrDefault(n => n.CurrentNodeInfo.NodeName == this.NodeName);

            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultCodePackage_NullNode_TelemetryId,
                node == null,
                string.Format(
                    StringResources.ChaosEngineError_CodePackageEntity_NullNode,
                    this.NodeName),
                this.ParentApplicationEntity.ClusterSnapshot);

            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultCodePackage_FaultedNode_TelemetryId,
                node.NodeFlags.HasFlag(ClusterEntityFlags.Faulted),
                string.Format(
                    StringResources.ChaosEngineError_CodePackageEntity_FaultedNode,
                    this.NodeName,
                    this),
                this.ParentApplicationEntity.ClusterSnapshot);

            // Here we fault all the replicas in this code package so that they are marked correctly and the
            // fault generator does not use them again
            foreach (var partitionEntity in this.DeployedPartitions)
            {
                // If !UnsafeModeEnabled then the fault tolerance of any partition hosted in this code package should not be at or
                // below 0 i.e. it should at least be 1
                ChaosUtility.ThrowOrAssertIfTrue(
                    ChaosConstants.FaultCodePackage_PartitionNotFaultTolerant_TelemetryId,
                    partitionEntity.GetPartitionFaultTolerance() <= 0 && !this.ParentApplicationEntity.ClusterSnapshot.UnsafeModeEnabled,
                    string.Format(
                        StringResources.ChaosEngineError_CodePackageEntity_PartitionNotFaultTolerantInSafeMode,
                        partitionEntity.Partition.PartitionId(),
                        this),
                    this.ParentApplicationEntity.ClusterSnapshot);

                // Fault the corresponding deployed replica so that it cannot be reused for faults
                var deployedReplica = partitionEntity.FindReplicaEntityGivenNodeName(this.NodeName);
                if (deployedReplica != null)
                {
                    TestabilityTrace.TraceSource.WriteInfo(
                        TraceType,
                        "{0}: Going to fault replica '{1}' due to faulting codepackage '{2}'",
                        activityId,
                        deployedReplica,
                        this);

                    deployedReplica.FaultReplica(true /*faultedDueToCodePackageFault*/, activityId);
                }
            }

            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking node '{1}' due to faulting codepackage '{2}'",
                activityId,
                node,
                this);

            // Mark the node the code package is hosted on as unavailable so that it cannot be used for any
            // other faults in this iteration
            node.MarkNodeAsUnavailableForFaults();

            TestabilityTrace.TraceSource.WriteInfo(
                TraceType,
                "{0}: Marking codepackage '{1}' as faulted",
                activityId,
                this);

            // Mark code package as faulted
            this.CodePackageFlags |= ClusterEntityFlags.Faulted;
        }