Example #1
0
        public Entity CreateSteelWall(float x, float y, int offsetX, int cellType)
        {
            var entity   = CreateEntity(EntityType.SteelWall);
            var sprite   = new Sprite(textureManager.Get(Images.Instance.TileSet), cellSize, Layers.Wall);
            var fsm      = new EntityStateMachine(entity);
            var position = new Position(x, y);

            AddCellToMap(x, y, cellType);

            return(entity
                   .Add(new Wall())
                   .Add(new Health(10000))
                   .Add(new Display(new Clip(sprite, new Vector2(offsetX, 0))))
                   .Add(new Collision(cellSize, 15))
                   .Add(new FSM(fsm))
                   .Add(new Damage(100))
                   .Add(new Position(x, y))
                   .Add(new ActionAfterDeath(() =>
            {
                var cellPos = position.position.Divide(cellSize.X);
                gameField.ClearCell(position.position.Divide(cellSize.X));
                gameField.GetCell(cellPos).Entity.Get <FSM>().list["Default"].ChangeState(States.Destroyed);
                CreateEnemyExplosion(position.position);
                CreateQuake();
            })));
        }
Example #2
0
    protected override void OnConstruct()
    {
        waypoint       = new Vector2(-1, -1);
        queuedWaypoint = new Vector2(-1, -1);
        stateMachine   = new EntityStateMachine <HeroState, Hero>(this);
        stateMachine.RegisterInitialState(HeroState.Standing, new StandingState());
        stateMachine.RegisterState(HeroState.Running, new RunningState());

        boxCollider = this.GetComponentStrict <BoxCollider2D>();
        OrbBehavior = this.GetComponentStrict <OrbBehavior>();
        buffs       = new Buffable <HeroBuffs, Hero, IHero>(this);

        collisionFilter = new ContactFilter2D();
        var layerMask = new LayerMask();

        layerMask.value |= 1 << 8;
        collisionFilter.SetLayerMask(layerMask);

        this.stats.Initialize();

        regenTimer        = new Timer(1);
        isSpellOnCooldown = true;

        this.paddle = AddChild(Game.Resources.LoadPrefab <Paddle>("Heroes/Paddle"), resetPosition: true);
        audioSource = this.GetComponentStrict <AudioSource>();

        this.spell         = AddChild(Game.Objects.CreatePrefab(this.spell));
        spellCooldownTimer = new Timer(this.spell.cooldown);
    }
        private void DoUpdate(EntityStateMachine stateMachine, EntityState newState)
        {
            if (!body || !animator)
            {
                enabled = false;
                return;
            }

            bool isCurrentStateValid = stateNames.Contains(stateMachine.state.GetType().Name);
            bool isNextStateValid    = stateNames.Contains(newState.GetType().Name);

            if ((parameterType == EntityStateParameterType.OnStateEnterTrigger && isNextStateValid) || (parameterType == EntityStateParameterType.OnStateExitTrigger && isCurrentStateValid))
            {
                animator.SetTrigger(parameterName);
            }
            else if (parameterType == EntityStateParameterType.IsInStateBool)
            {
                if (isNextStateValid)
                {
                    animator.SetBool(parameterName, true);
                }
                else if (isCurrentStateValid)
                {
                    animator.SetBool(parameterName, false);
                }
            }
        }
Example #4
0
 private void FixedUpdate()
 {
     if (this.hudElement.targetCharacterBody)
     {
         SkillLocator component = this.hudElement.targetCharacterBody.GetComponent <SkillLocator>();
         if (component && component.secondary)
         {
             EntityStateMachine stateMachine = component.secondary.stateMachine;
             if (stateMachine)
             {
                 SecondaryScope scopeSniper = stateMachine.state as SecondaryScope;
                 if (scopeSniper != null && scopeSniper.scopeComponent != null && scopeSniper.scopeComponent.IsScoped)
                 {
                     if (component.secondary.stock > 0)
                     {
                         image.color      = chargeColor;
                         image.fillAmount = scopeSniper.scopeComponent.charge;
                     }
                     else
                     {
                         image.color      = rechargeColor;
                         image.fillAmount = 1f - component.secondary.rechargeStopwatch / component.secondary.CalculateFinalRechargeInterval();
                     }
                 }
             }
         }
     }
 }
Example #5
0
 public NeutralState(EntityStateMachine ownerFiniteStateMachine) : base(ownerFiniteStateMachine)
 {
     Name = "Wander";
     childStateMachine             = new EntityStateMachine(OwnerEntity);
     childStateMachine.ParentState = this;
     childStateMachine.SetState(new SchoolTogetherState(childStateMachine));
 }
Example #6
0
 public override void OnUpdate(GameEntity entity, EntityStateMachine fsm)
 {
     if (entity.GetComponent <EntityEffector>().GetEffect <Stun>() == null)
     {
         fsm.ChangeState(IdleState);
     }
 }
Example #7
0
 protected override void OnConstruct()
 {
     stateMachine = new EntityStateMachine <BeeState, Bee>(this);
     stateMachine.RegisterInitialState(BeeState.Idle, new IdleState());
     stateMachine.RegisterState(BeeState.Moving, new MovingState());
     stateMachine.RegisterState(BeeState.Hit, new HitState());
 }
Example #8
0
            internal void OnActivation(ActivationBaseState <TSkillData> state)
            {
                this.data = state.CreateSkillData();


                if (this.dataStateMachine is null)
                {
                    var name = this.data.targetStateMachineName;
                    if (!(name is null))
                    {
                        EntityStateMachine[] machs = this.skillSlot.GetComponents <EntityStateMachine>();
                        for (Int32 i = 0; i < machs.Length; ++i)
                        {
                            EntityStateMachine mach = machs[i];
                            if (mach.customName == name)
                            {
                                this.dataStateMachine = mach;
                                break;
                            }
                        }
                    }
                }

                if (!(this.dataStateMachine is null))
                {
                    this.data.targetStateMachine = this.dataStateMachine;
                }
            }
Example #9
0
        // Token: 0x060023CE RID: 9166 RVA: 0x000A8464 File Offset: 0x000A6664
        private void FixedUpdate()
        {
            float fillAmount = 0f;

            if (this.hudElement.targetCharacterBody)
            {
                SkillLocator component = this.hudElement.targetCharacterBody.GetComponent <SkillLocator>();
                if (component && component.secondary)
                {
                    EntityStateMachine stateMachine = component.secondary.stateMachine;
                    if (stateMachine)
                    {
                        ScopeSniper scopeSniper = stateMachine.state as ScopeSniper;
                        if (scopeSniper != null)
                        {
                            fillAmount = scopeSniper.charge;
                        }
                    }
                }
            }
            if (this.image)
            {
                this.image.fillAmount = fillAmount;
            }
        }
 public void Awake()
 {
     this.body        = base.GetComponent <CharacterBody>();
     this.outer       = base.GetComponent <EntityStateMachine>();
     this.musicRemote = base.GetComponent <TTGLMusicRemote>();
     On.RoR2.CharacterBody.RecalculateStats += CharacterBody_RecalculateStats;
 }
        // Token: 0x06001E1D RID: 7709 RVA: 0x00081C8F File Offset: 0x0007FE8F
        private bool IsArmed()
        {
            EntityStateMachine  entityStateMachine  = this.armingStateMachine;
            BaseMineArmingState baseMineArmingState = ((entityStateMachine != null) ? entityStateMachine.state : null) as BaseMineArmingState;

            return(((baseMineArmingState != null) ? baseMineArmingState.damageScale : 0f) > 1f);
        }
        public override void Update()
        {
            base.Update();
            Collider[] colliders = Physics.OverlapSphere(this.gameObject.transform.position, m_SearchRadius, ~(1 << this.gameObject.layer));
            List <EntityController> availableTargets = new List <EntityController>();

            foreach (Collider collider in colliders)
            {
                if (Physics.GetIgnoreLayerCollision(collider.gameObject.layer, this.gameObject.layer))
                {
                    continue;
                }
                EntityController entityController = collider.gameObject.GetComponentInParent <EntityController>();
                if (!entityController)
                {
                    continue;
                }
                if (entityController.Entity.Description.EntityType != EntityType.SpaceShip)
                {
                    continue;
                }
                availableTargets.Add(entityController);
            }
            CommonComponents.EntityController.Target = FindBestTarget(availableTargets);
            if (CommonComponents.EntityController.Target && m_NextState != null)
            {
                EntityStateMachine.SetNextState(m_NextState);
                return;
            }
        }
Example #13
0
        public override void OnUpdate(GameEntity entity, EntityStateMachine fsm)
        {
            var movable  = entity.GetComponent <MovableEntity>();
            var movement = (fsm as EntityController).Movement;

            movement.y = 0;
            entity.GetComponent <AnimationController>().PlayAnimation(AnimatorController, movement.x);
            movable.Move(movement);
            if (movable.velocity.y < 0)
            {
                movable.GravityScale = 1.4f;
            }
            else
            {
                movable.GravityScale = 1;
            }
            if (movable.OnGround)
            {
                movable.GravityScale = 1f;
                fsm.ChangeState(IdleState);
            }
            if (ClimbState)
            {
                fsm.ChangeState(ClimbState);
            }
        }
        public override void Update()
        {
            base.Update();

            if (CommonComponents.TranslationalController == null)
            {
                return;
            }
            if (CommonComponents.EntityController.Target && m_OnTargetFoundState)
            {
                EntityStateMachine.SetNextState(m_OnTargetFoundState);
                return;
            }

            float radius = Mathf.PerlinNoise(Age, m_Seed) * (m_MaxOrbitRadius - m_MinOrbitRadius);

            radius = Mathf.Clamp(radius + m_MinOrbitRadius, m_MinOrbitRadius, m_MaxOrbitRadius);
            if (radius != 0.0f)
            {
                m_OrbitPerSecond = m_OrbitSpeed * CommonComponents.EnemyController.Entity.GetStat("core.modtypes.ship.movementspeed").Current / radius;
                m_Angle         += Time.deltaTime * m_OrbitPerSecond * m_OrbitSpeedMultiplier;
            }

            Vector3 targetPosition = Vector3.forward * radius;

            targetPosition  = Quaternion.Euler(0, m_Angle, 0) * targetPosition;
            targetPosition += CommonComponents.EnemyController.Entity.Description.Parent.EntityController.Head.position;
            CommonComponents.TranslationalController.MoveTowardsPosition(targetPosition);
        }
Example #15
0
        public override bool OnEnter(GameEntity entity, EntityState previousState, EntityStateMachine fsm)
        {
            var effector = entity.GetComponent <EntityEffector>();
            var trigger  = effector.GetEffect <Damage>()?.GetTrigger <ImpactData>()
                           ?? effector.GetEffect <BlowUp>()?.GetTrigger <ImpactData>()
                           ?? effector.GetEffect <Interruption>()?.GetTrigger <ImpactData>();
            var blowUp    = effector.GetEffect <BlowUp>();
            var interrupt = effector.GetEffect <Interruption>();

            if (trigger == null)
            {
                return(false);
            }
            if (blowUp != null)
            {
                return(true);
            }
            if (fsm.State is EntityMove)
            {
                return(false);
            }
            if (interrupt is null && fsm.State is EntitySkill)
            {
                return(false);
            }
            if (interrupt != null && !entity.GetComponent <SkillController>().Interrupt(Mathf.RoundToInt(interrupt.Strength)))
            {
                return(false);
            }
            return(true);
        }
 public DontSchoolTogetherState(EntityStateMachine ownerFiniteStateMachine) : base(ownerFiniteStateMachine)
 {
     steeringBehaviours.Add(new WanderBehaviour(OwnerEntity));
     steeringBehaviours.Add(new DistancingBehaviour(OwnerEntity));
     steeringBehaviours.Add(new ObstacleAvoidance(OwnerEntity));
     Name = "DontSchoolTogetherState";
 }
        public sealed override BaseSkillInstanceData OnAssigned(GenericSkill skillSlot)
        {
            EntityStateMachine reloadTargetStatemachine = null;

            EntityStateMachine[] stateMachines = skillSlot.GetComponents <EntityStateMachine>();
            for (Int32 i = 0; i < stateMachines.Length; ++i)
            {
                EntityStateMachine mach = stateMachines[i];
                if (mach.customName == this.reloadStateMachineName)
                {
                    reloadTargetStatemachine = mach;
                }
            }

#if ASSERT
            if (reloadTargetStatemachine == null)
            {
                Log.Error("No state machine found for reload");
            }
#endif

            skillSlot.stock = this.actualMaxStock;

            return(new SniperPrimaryInstanceData(this, reloadTargetStatemachine, this.reloadParams, skillSlot));
        }
Example #18
0
        //Adds tesla mine to projectile register list
        internal static void RegisterTeslaMine()
        {
            //Start with the base engi mine
            teslaMinePrefab = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/engimine").InstantiateClone("TeslaMine", true);
            //If it exists (AKA if shit no break)
            if (teslaMinePrefab)
            {
                //Change the forward speed on it a bit, not sure why but it feels nice so keeping it
                teslaMinePrefab.GetComponent <ProjectileSimple>().desiredForwardSpeed = 40f;

                //Grab the arming state machine (Handler for the arming states, I think)
                EntityStateMachine teslaArmingStateMachine = teslaMinePrefab.GetComponentsInChildren <EntityStateMachine>().First(machine => machine.customName == "Arming");
                //Replace the initial and main states of the arming state to our own, cooler states
                teslaArmingStateMachine.initialStateType = new SerializableEntityStateType(typeof(TeslaArmingUnarmedState));
                teslaArmingStateMachine.mainStateType    = new SerializableEntityStateType(typeof(TeslaArmingUnarmedState));

                //Grab the main state machine (Handler for the mine after it has landed and is ready to splode)
                EntityStateMachine teslaMainStateMachine = teslaMinePrefab.GetComponentsInChildren <EntityStateMachine>().First(machine => machine.customName == "Main");
                //Replace initial and main with our own: Initial is the waiting for target, main state is predet state
                //Note that the main state is also called when a mine is about to be unloaded (For ex too many mines)
                teslaMainStateMachine.initialStateType = new SerializableEntityStateType(typeof(TeslaWaitForStick));
                teslaMainStateMachine.mainStateType    = new SerializableEntityStateType(typeof(TeslaPreDetState));

                //Add it to the projectile queue after modifying it
                projList.Add(teslaMinePrefab);
            }
        }
Example #19
0
        protected override bool PerformEquipmentAction(EquipmentSlot slot)
        {
            if (!slot || !slot.characterBody)
            {
                return(false);
            }
            var cpt = slot.characterBody.GetComponent <RewindComponent>();

            if (!cpt || cpt.frames.Count == 0)
            {
                return(false);
            }
            var esm = EntityStateMachine.FindByCustomName(slot.characterBody.gameObject, "Body");

            if (esm == null || esm.state is RewindState)
            {
                return(false);
            }
            new MsgRewind(slot.characterBody).Send(R2API.Networking.NetworkDestination.Clients);
            if (Compat_ClassicItems.enabled)
            {
                if (Util.CheckRoll(Mathf.Pow(0.5f, Compat_ClassicItems.CheckEmbryoProc(slot, equipmentDef)) * 100f))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #20
0
            public override void OnEnter()
            {
                base.OnEnter();

                this.skinController = base.GetModelTransform().GetComponent <WispModelBitSkinController>();
                var model = this.skinController.GetComponent <CharacterModel>();

                this.bodyParticles = model.GetComponent <ParticleHolder>().systems[0];
                this.flareSprite   = base.gameObject.GetComponentInChildren <SpriteRenderer>();
                this.eyeFlare      = this.flareSprite.GetComponent <EyeFlare>();

                this.eyeFlare.localScale = baseFlareIntensity;
                var emis = this.bodyParticles.emission;

                emis.rateOverTime = baseEmissionRate;

                base.characterBody.skinIndex = baseSkin;

                this.skinController.Apply(WispBitSkin.GetWispSkin(baseSkin));

                this.flareSprite.color    = this.skinController.activeLightColor;
                this.flareSprite.material = this.skinController.activeTracerMaterial;


                this.weaponStateMachine = base.outer.GetComponents <EntityStateMachine>().Where <EntityStateMachine>((esm) => esm.customName == "Weapon").Single <EntityStateMachine>();
            }
Example #21
0
        public Entity CreateTile(float x, float y, int gid, Ground g)
        {
            var offsetX          = gid > 66 ? gid * cellSize.X - 2010 : gid * cellSize.X;
            var offsetY          = gid > 66 ? 30 : 0;
            var destroyedPos     = Vector2.Zero;
            var randForDestroyed = r.Next(3) * cellSize.X;

            if (g == Ground.Ground)
            {
                destroyedPos = new Vector2(510 + randForDestroyed, 0);
            }
            else if (g == Ground.Asphalt)
            {
                destroyedPos = new Vector2(1560 + randForDestroyed, 30);
            }
            else if (g == Ground.Sand)
            {
                destroyedPos = new Vector2(630 + randForDestroyed, 30);
            }

            var sprite = new Sprite(textureManager.Get(Images.Instance.TileSet), cellSize, Layers.Ground);
            var entity = CreateEntity();
            var fsm    = new EntityStateMachine(entity);

            fsm.CreateState(States.Alive)
            .Add <Display>().WithInstance(new Display(new Clip(sprite, new Vector2(offsetX, offsetY))));
            fsm.CreateState(States.Destroyed)
            .Add <Display>().WithInstance(new Display(new Clip(sprite, destroyedPos)));
            fsm.ChangeState(States.Alive);

            return(entity
                   .Add(new FSM(fsm))
                   .Add(new Position(x, y)));
        }
Example #22
0
        public override void OnLoad()
        {
            base.OnLoad();
            itemDef.name = "MysticsItems_DasherDisc";
            SetItemTierWhenAvailable(ItemTier.Tier3);
            itemDef.tags = new ItemTag[]
            {
                ItemTag.Utility
            };
            MysticsItemsContent.Resources.unlockableDefs.Add(GetUnlockableDef());
            itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Dasher Disc/Model.prefab"));
            itemDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Dasher Disc/Icon.png");
            Material mat = itemDef.pickupModelPrefab.transform.Find("mdlDasherDisc").GetComponent <MeshRenderer>().sharedMaterial;

            HopooShaderToMaterial.Standard.Apply(mat);
            HopooShaderToMaterial.Standard.Emission(mat, 4f);
            HopooShaderToMaterial.Standard.Gloss(mat);
            MysticsItemsDasherDiscSpinner spinner = itemDef.pickupModelPrefab.transform.Find("mdlDasherDisc").gameObject.AddComponent <MysticsItemsDasherDiscSpinner>();

            spinner.trail     = itemDef.pickupModelPrefab.transform.Find("mdlDasherDisc").Find("Particle System").gameObject;
            itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false));
            itemDisplayPrefab.transform.Find("mdlDasherDisc").localScale = Vector3.one * 5f;

            controllerPrefab.AddComponent <GenericOwnership>();
            NetworkedBodyAttachment networkedBodyAttachment = controllerPrefab.AddComponent <NetworkedBodyAttachment>();

            networkedBodyAttachment.forceHostAuthority = true;
            EntityStateMachine stateMachine = controllerPrefab.AddComponent <EntityStateMachine>();

            stateMachine.mainStateType = stateMachine.initialStateType = new SerializableEntityStateType(typeof(DiscBaseState.Ready));
            NetworkStateMachine networkStateMachine = controllerPrefab.AddComponent <NetworkStateMachine>();

            networkStateMachine.SetFieldValue("stateMachines", new EntityStateMachine[] {
                stateMachine
            });
            DiscController component = controllerPrefab.AddComponent <DiscController>();
            GameObject     follower  = PrefabAPI.InstantiateClone(itemDisplayPrefab, "DasherDiscFollower", false);

            follower.transform.SetParent(controllerPrefab.transform);
            component.follower    = follower;
            component.disc        = follower.transform.Find("mdlDasherDisc").gameObject;
            component.discSpinner = component.disc.GetComponent <MysticsItemsDasherDiscSpinner>();

            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(DiscBaseState));
            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(DiscBaseState.Ready));
            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(DiscBaseState.Trigger));
            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(DiscBaseState.Invincible));

            On.RoR2.CharacterBody.Awake += (orig, self) =>
            {
                orig(self);
                self.onInventoryChanged += delegate()
                {
                    if (NetworkServer.active)
                    {
                        self.AddItemBehavior <MysticsItemsDasherDiscBehaviour>(self.inventory.GetItemCount(itemDef));
                    }
                };
            };
        }
Example #23
0
        internal virtual void InitializeCharacter()
        {
            // this creates a config option to enable the character- feel free to remove if the character is the only thing in your mod
            characterEnabled = Modules.Config.CharacterEnableConfig(bodyName);

            if (characterEnabled.Value)
            {
                InitializeUnlockables();

                bodyPrefab = Modules.Prefabs.CreatePrefab(bodyName + "Body", "mdl" + bodyName, bodyInfo);

                EntityStateMachine entityStateMachine = bodyPrefab.GetComponent <EntityStateMachine>();
                entityStateMachine.mainStateType    = new EntityStates.SerializableEntityStateType(characterMainState);
                entityStateMachine.initialStateType = new EntityStates.SerializableEntityStateType(characterSpawnState);

                Modules.Prefabs.SetupCharacterModel(bodyPrefab, customRendererInfos, mainRendererIndex);

                displayPrefab = Modules.Prefabs.CreateDisplayPrefab(bodyName + "Display", bodyPrefab, bodyInfo);
                if (!displayPrefab)
                {
                    displayPrefab = GameObject.Instantiate(bodyPrefab.GetComponent <ModelLocator>().modelBaseTransform.gameObject);
                }

                Modules.Prefabs.RegisterNewSurvivor(bodyPrefab, displayPrefab, Color.grey, bodyName.ToUpper(), characterUnlockableDef, survivorSortPosition);

                InitializeHitboxes();
                InitializeSkills();
                InitializeSkins();
                InitializeItemDisplays();
                InitializeDoppelganger();
            }
        }
Example #24
0
        public Entity CreateTank(float x, float y, int level = 0)
        {
            var entity   = CreateEntity(EntityType.RedTank);
            var position = new Position(x, y, AntEnum.Parse <Direction>(r.Next(1, 5).ToString()));
            var myvars   = vars.LightTank[level];
            var view     = new TankView(myvars[5], 0, position.direction);

            var listFsm   = new Dictionary <string, EntityStateMachine>();
            var moveFSM   = new EntityStateMachine(entity);
            var aiFSM     = new EntityStateMachine(entity);
            var motionFSM = new EntityStateMachine(entity);

            moveFSM.CreateState(States.Stand).Add <Stand>().WithInstance(new Stand());
            moveFSM.CreateState(States.Turn).Add <Turn>().WithInstance(new Turn());
            moveFSM.CreateState(States.Walk).Add <Walk>().WithInstance(new Walk());
            moveFSM.ChangeState(States.Stand);

            aiFSM.CreateState(States.Idle).Add <Idle>().WithInstance(new Idle(7));
            aiFSM.CreateState(States.Pursuit).Add <Pursuit>().WithInstance(new Pursuit());
            aiFSM.CreateState(States.Attack).Add <Attack>().WithInstance(new Attack());
            aiFSM.ChangeState(States.Idle);

            var addSpeed = Mathf.FromPercent(0.5f, myvars[0]);

            motionFSM.CreateState(States.Fast).Add <Controls>()
            .WithInstance(new Controls(new Vector2(myvars[0] + addSpeed)));
            motionFSM.CreateState(States.Slow).Add <Controls>()
            .WithInstance(new Controls(new Vector2(myvars[0] - addSpeed)));
            motionFSM.CreateState(States.Normal).Add <Controls>()
            .WithInstance(new Controls(new Vector2(myvars[0])));
            motionFSM.ChangeState(States.Normal);

            listFsm.Add("MoveFSM", moveFSM);
            listFsm.Add("AiFSM", aiFSM);
            listFsm.Add("MotionFSM", motionFSM);

            entity
            .Add(position)
            .Add(view.GetView())
            .Add(new Health(myvars[2], myvars[4]))
            .Add(new Damage(100))
            .Add(new Tank())
            .Add(new FSM(listFsm))
            .Add(new AI(360, 210, new[] { EntityType.GreenTank }))
            .Add(new Gun(myvars[1], myvars[3]))
            .Add(new Collision(cellSize, 15))
            .Add(new Motion(Vector2.Zero, r.Next(CellType.Segment, 10000)))
            .Add(new ActionAfterDeath(() =>
            {
                gameField.ClearCell(position.prevCell);
                CreateEnemyExplosion(position.position);
                CreateQuake();
            }));

            CreateRedOverlay(entity);
            CreateGreenHealthBar(entity);

            return(entity);
        }
Example #25
0
        public IEnumerator Starts_In_Idle_State()
        {
            yield return(Helpers.LoadEntityStateMachineTestsScene());

            EntityStateMachine stateMachine = GameObject.FindObjectOfType <EntityStateMachine>();

            Assert.AreEqual(typeof(Idle), stateMachine.CurrentStateType);
        }
Example #26
0
        internal static void UtilityStateMachineSetup()
        {
            EntityStateMachine entityStateMachine = characterPrefab.AddComponent <EntityStateMachine>();

            entityStateMachine.customName       = "ROCKETEER_Utility";
            entityStateMachine.initialStateType = new SerializableEntityStateType(typeof(BaseState));
            entityStateMachine.mainStateType    = new SerializableEntityStateType(typeof(RocketeerSmallJet));
        }
Example #27
0
        private void JetpackStateMachineSetup(GameObject go)
        {
            EntityStateMachine jetpackMachine = go.AddComponent <EntityStateMachine>();

            jetpackMachine.customName       = "Jetpack";
            jetpackMachine.initialStateType = new SerializableEntityStateType(typeof(EntityStates.BaseBodyAttachmentState));
            jetpackMachine.mainStateType    = new SerializableEntityStateType(typeof(EntityStates.BaseBodyAttachmentState));
        }
Example #28
0
        public override IEnumerator Begin(GameEntity entity, EntityStateMachine fsm)
        {
            var trigger  = entity.GetComponent <EntityEffector>()?.GetEffect <Damage>()?.GetTrigger <ImpactData>();
            var blowUp   = entity.GetComponent <EntityEffector>()?.GetEffect <BlowUp>();
            var effector = entity.GetComponent <EntityEffector>();

            if (trigger != null)
            {
                if (blowUp != null)
                {
                    var locker = (fsm as EntityController).Lock(this);
                    // Debug.Log($"locked {(fsm as EntityController).Locker.Locked}");
                    entity.GetComponent <SkillController>().Abort();
                    var movable = entity.GetComponent <MovableEntity>();
                    var v       = (blowUp.Effect as BlowUp).Blow;
                    v.x *= MathUtility.SignInt(blowUp.GetTrigger <ImpactData>().Position.x - entity.transform.position.x);
                    entity.GetComponent <MovableEntity>().Frozen = true;
                    entity.GetComponent <MovableEntity>().SetVelocity(v);
                    entity.GetComponent <AnimationController>().PlayAnimation(BlowUpAction, trigger.Position.x - entity.transform.position.x);
                    yield return(null);

                    while (!movable.OnGround)
                    {
                        yield return(null);
                    }
                    movable.Frozen = false;
                    entity.GetComponent <Animator>().SetTrigger("end");
                    yield return(new WaitForSeconds(BlowUpSleepTime));

                    entity.GetComponent <EntityEffector>().RemoveEffect(blowUp.Effect);
                    (fsm as EntityController).UnLock(locker);
                    while (!fsm.ChangeState(MoveState) && !fsm.ChangeState(JumpState))
                    {
                        yield return(null);
                    }
                    // Debug.Log($"unlocked {(fsm as EntityController).Locker.Locked}");
                    yield break;
                }
                else
                {
                    var interrupt = effector.GetEffect <Interruption>();
                    if (interrupt != null && entity.GetComponent <SkillController>().Interrupt(Mathf.RoundToInt(interrupt.Strength)))
                    {
                        entity.GetComponent <AnimationController>().PlayAnimation(HitAction, trigger.Position.x - entity.transform.position.x);
                        while (!entity.GetComponent <AnimationController>().IsEnd())
                        {
                            yield return(null);

                            if (fsm.ChangeState(JumpState) || fsm.ChangeState(MoveState))
                            {
                                yield break;
                            }
                        }
                    }
                }
            }
            fsm.ChangeState(IdleState);
        }
Example #29
0
        public void Start()
        {
            var hereticPrefab = Resources.Load <GameObject>("prefabs/charactermasters/hereticmonstermaster");

            hereticSkillDrivers = hereticPrefab.GetComponents <AISkillDriver>();
            hereticESM          = hereticPrefab.GetComponent <EntityStateMachine>();
            On.RoR2.CharacterMaster.TransformBody += CharacterMaster_TransformBody;
            //On.RoR2.CharacterMaster.TransformBody += CharacterMaster_TransformBody1; //spawn
        }
Example #30
0
 public override bool OnEnter(GameEntity entity, EntityState previousState, EntityStateMachine fsm)
 {
     if ((fsm as EntityController).Jumped && entity.GetComponent <MovableEntity>().Jump())
     {
         base.OnEnter(entity, previousState, fsm);
         fsm.ChangeState(AirState);
     }
     return(false);
 }