Exemple #1
0
        // Token: 0x06000056 RID: 86 RVA: 0x00004194 File Offset: 0x00002394
        public void KnightPlacer(PlayerController owner)
        {
            try
            {
                AIActor     orLoadByGuid             = EnemyDatabase.GetOrLoadByGuid("ec8ea75b557d4e7b8ceeaacdf6f8238c");
                IntVector2  intVector                = Vector2Extensions.ToIntVector2(owner.unadjustedAimPoint, (VectorConversions)2);
                RoomHandler absoluteRoomFromPosition = GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector);
                bool        flag = absoluteRoomFromPosition != null && absoluteRoomFromPosition == owner.CurrentRoom && owner.IsInCombat;
                if (flag)
                {
                    AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, owner.CenterPosition, absoluteRoomFromPosition, true, (AIActor.AwakenAnimationType) 2, true);
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(aiactor.specRigidbody, null, false);
                    aiactor.CanTargetEnemies   = true;
                    aiactor.CanTargetPlayers   = false;
                    aiactor.IsHarmlessEnemy    = true;
                    aiactor.CanDropCurrency    = false;
                    aiactor.IgnoreForRoomClear = true;
                    aiactor.MovementSpeed      = 5.95f;
                    aiactor.CompanionOwner     = owner;
                    aiactor.IsBuffEnemy        = true;
                    aiactor.isPassable         = true;
                    aiactor.gameObject.AddComponent <KillOnRoomClear>();
                    aiactor.reinforceType = (AIActor.ReinforceType) 2;
                    aiactor.HandleReinforcementFallIntoRoom(0.1f);

                    //added this so the player doesn't collide with the nut when dodge rolling, he goes through companions
                    aiactor.gameObject.AddComponent <CompanionController>();
                    CompanionController component = aiactor.gameObject.GetComponent <CompanionController>();
                    component.Initialize(owner);

                    this.nut = aiactor;
                    MindControlEffect orAddComponent = GameObjectExtensions.GetOrAddComponent <MindControlEffect>(aiactor.gameObject);
                    orAddComponent.owner = (this.gun.CurrentOwner as PlayerController);

                    // to make the nut invincible against the player effects or any other damage effects
                    if (aiactor.healthHaver != null)
                    {
                        aiactor.healthHaver.PreventAllDamage = true;
                    }

                    // to prevent the attacks of the nut from damaging the player
                    if (aiactor.bulletBank != null)
                    {
                        AIBulletBank bulletBank = aiactor.bulletBank;
                        bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, new Action <Projectile>(CopperChariot.OnPostProcessProjectile));
                    }
                    if (aiactor.aiShooter != null)
                    {
                        AIShooter aiShooter = aiactor.aiShooter;
                        aiShooter.PostProcessProjectile = (Action <Projectile>)Delegate.Combine(aiShooter.PostProcessProjectile, new Action <Projectile>(CopperChariot.OnPostProcessProjectile));
                    }
                }
            }
            catch (Exception e)
            {
                Tools.Print("Copper KnightPlacer", "FFFFFF", true);
                Tools.PrintException(e);
            }
        }
Exemple #2
0
        public static SpeculativeRigidbody SetUpSpeculativeRigidbody(this tk2dSprite sprite, IntVector2 offset, IntVector2 dimensions)
        {
            SpeculativeRigidbody orAddComponent = GameObjectExtensions.GetOrAddComponent <SpeculativeRigidbody>(sprite.gameObject);
            PixelCollider        pixelCollider  = new PixelCollider();

            pixelCollider.ColliderGenerationMode = 0;
            pixelCollider.CollisionLayer         = CollisionLayer.EnemyCollider;
            pixelCollider.ManualWidth            = dimensions.x;
            pixelCollider.ManualHeight           = dimensions.y;
            pixelCollider.ManualOffsetX          = offset.x;
            pixelCollider.ManualOffsetY          = offset.y;
            orAddComponent.PixelColliders        = new List <PixelCollider> {
                pixelCollider
            };
            return(orAddComponent);
        }
Exemple #3
0
        public static SpeculativeRigidbody GenerateOrAddToRigidBody(GameObject targetObject, CollisionLayer collisionLayer, PixelCollider.PixelColliderGeneration colliderGenerationMode = PixelCollider.PixelColliderGeneration.Tk2dPolygon, bool collideWithTileMap = false, bool CollideWithOthers = true, bool CanBeCarried = true, bool CanBePushed = false, bool RecheckTriggers = false, bool IsTrigger = false, bool replaceExistingColliders = false, bool UsesPixelsAsUnitSize = false, IntVector2?dimensions = null, IntVector2?offset = null)
        {
            SpeculativeRigidbody m_CachedRigidBody = GameObjectExtensions.GetOrAddComponent <SpeculativeRigidbody>(targetObject);

            m_CachedRigidBody.CollideWithOthers         = CollideWithOthers;
            m_CachedRigidBody.CollideWithTileMap        = collideWithTileMap;
            m_CachedRigidBody.Velocity                  = Vector2.zero;
            m_CachedRigidBody.MaxVelocity               = Vector2.zero;
            m_CachedRigidBody.ForceAlwaysUpdate         = false;
            m_CachedRigidBody.CanPush                   = false;
            m_CachedRigidBody.CanBePushed               = CanBePushed;
            m_CachedRigidBody.PushSpeedModifier         = 1f;
            m_CachedRigidBody.CanCarry                  = false;
            m_CachedRigidBody.CanBeCarried              = CanBeCarried;
            m_CachedRigidBody.PreventPiercing           = false;
            m_CachedRigidBody.SkipEmptyColliders        = false;
            m_CachedRigidBody.RecheckTriggers           = RecheckTriggers;
            m_CachedRigidBody.UpdateCollidersOnRotation = false;
            m_CachedRigidBody.UpdateCollidersOnScale    = false;

            IntVector2 Offset     = IntVector2.Zero;
            IntVector2 Dimensions = IntVector2.Zero;

            if (colliderGenerationMode != PixelCollider.PixelColliderGeneration.Tk2dPolygon)
            {
                if (dimensions.HasValue)
                {
                    Dimensions = dimensions.Value;
                    if (!UsesPixelsAsUnitSize)
                    {
                        Dimensions = (new IntVector2(Dimensions.x * 16, Dimensions.y * 16));
                    }
                }
                if (offset.HasValue)
                {
                    Offset = offset.Value;
                    if (!UsesPixelsAsUnitSize)
                    {
                        Offset = (new IntVector2(Offset.x * 16, Offset.y * 16));
                    }
                }
            }
            PixelCollider m_CachedCollider = new PixelCollider()
            {
                ColliderGenerationMode = colliderGenerationMode,
                CollisionLayer         = collisionLayer,
                IsTrigger = IsTrigger,
                BagleUseFirstFrameOnly = (colliderGenerationMode == PixelCollider.PixelColliderGeneration.Tk2dPolygon),
                SpecifyBagelFrame      = string.Empty,
                BagelColliderNumber    = 0,
                ManualOffsetX          = Offset.x,
                ManualOffsetY          = Offset.y,
                ManualWidth            = Dimensions.x,
                ManualHeight           = Dimensions.y,
                ManualDiameter         = 0,
                ManualLeftX            = 0,
                ManualLeftY            = 0,
                ManualRightX           = 0,
                ManualRightY           = 0
            };

            if (replaceExistingColliders | m_CachedRigidBody.PixelColliders == null)
            {
                m_CachedRigidBody.PixelColliders = new List <PixelCollider> {
                    m_CachedCollider
                };
            }
            else
            {
                m_CachedRigidBody.PixelColliders.Add(m_CachedCollider);
            }

            if (m_CachedRigidBody.sprite && colliderGenerationMode == PixelCollider.PixelColliderGeneration.Tk2dPolygon)
            {
                Bounds bounds = m_CachedRigidBody.sprite.GetBounds();
                m_CachedRigidBody.sprite.GetTrueCurrentSpriteDef().colliderVertices = new Vector3[] { bounds.center - bounds.extents, bounds.center + bounds.extents };
                // m_CachedRigidBody.ForceRegenerate();
                // m_CachedRigidBody.RegenerateCache();
            }

            return(m_CachedRigidBody);
        }
        // Token: 0x06000056 RID: 86 RVA: 0x00004194 File Offset: 0x00002394
        public void KnightPlacer(PlayerController owner)
        {
            try
            {
                AIActor     orLoadByGuid             = EnemyDatabase.GetOrLoadByGuid("ec8ea75b557d4e7b8ceeaacdf6f8238c");
                IntVector2  intVector                = Vector2Extensions.ToIntVector2(owner.unadjustedAimPoint, (VectorConversions)2);
                RoomHandler absoluteRoomFromPosition = GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector);
                bool        flag = absoluteRoomFromPosition != null && absoluteRoomFromPosition == owner.CurrentRoom && owner.IsInCombat;
                if (flag)
                {
                    AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, owner.CenterPosition, absoluteRoomFromPosition, true, (AIActor.AwakenAnimationType) 2, true);
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(aiactor.specRigidbody, null, false);
                    aiactor.CanTargetEnemies   = true;
                    aiactor.CanTargetPlayers   = false;
                    aiactor.IsHarmlessEnemy    = true;
                    aiactor.CanDropCurrency    = false;
                    aiactor.IgnoreForRoomClear = true;
                    aiactor.MovementSpeed      = 5.95f;
                    aiactor.CompanionOwner     = owner;
                    aiactor.IsBuffEnemy        = true;
                    aiactor.isPassable         = true;
                    aiactor.gameObject.AddComponent <KillOnRoomClear>();
                    aiactor.reinforceType = (AIActor.ReinforceType) 2;
                    aiactor.HandleReinforcementFallIntoRoom(0.1f);

                    aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(
                        CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox, CollisionLayer.EnemyCollider, CollisionLayer.PlayerHitBox,
                                                  CollisionLayer.Projectile, CollisionLayer.PlayerCollider, CollisionLayer.PlayerBlocker, CollisionLayer.BeamBlocker)
                        );
                    aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable, CollisionLayer.Trap));

                    /*
                     * aiactor.gameObject.AddComponent<CompanionController>();
                     * CompanionController component = aiactor.gameObject.GetComponent<CompanionController>();
                     * component.Initialize(owner);
                     */


                    this.nut = aiactor;
                    MindControlEffect orAddComponent = GameObjectExtensions.GetOrAddComponent <MindControlEffect>(aiactor.gameObject);
                    orAddComponent.owner = (this.gun.CurrentOwner as PlayerController);
                    if (aiactor.healthHaver != null)
                    {
                        aiactor.healthHaver.PreventAllDamage = true;
                    }
                    if (aiactor.bulletBank != null)
                    {
                        AIBulletBank bulletBank = aiactor.bulletBank;
                        bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, new Action <Projectile>(this.OnPostProcessProjectile));
                    }
                    if (aiactor.aiShooter != null)
                    {
                        AIShooter aiShooter = aiactor.aiShooter;
                        aiShooter.PostProcessProjectile = (Action <Projectile>)Delegate.Combine(aiShooter.PostProcessProjectile, new Action <Projectile>(this.OnPostProcessProjectile));
                    }
                    aiactor.LocalTimeScale = 3;
                }
            }
            catch (Exception e)
            {
                Tools.Print("Copper KnightPlacer", "FFFFFF", true);
                Tools.PrintException(e);
            }
        }