Пример #1
0
        public static void ExecutePhysicalAttack(EntityManager entityManager, string pokemonName, Entity pokemonEntity, PokemonEntityData ped, Scale scale)
        {
            //change the Entity's CollisionFilter From player/entity to attacking player/ entity
            entityManager.AddComponentData(pokemonEntity, PokemonDataClass.getPokemonPhysicsCollider(pokemonName,
                                                                                                     ped,
                                                                                                     new CollisionFilter {
                BelongsTo    = TriggerEventClass.PokemonAttacking,
                CollidesWith = uint.MaxValue,
                GroupIndex   = 1
            }, scale.Value, new Unity.Physics.Material {
                Flags = Unity.Physics.Material.MaterialFlags.IsTrigger
            })
                                           );
            //start physical attack animation

            //let the systems do the rest
        }
Пример #2
0
    public void Update(EntityManager entityManager, Entity entity)
    {
        if (!EditMode)
        {
            position = entityManager.GetComponentData <Translation>(entity).Value;
            scale    = entityManager.GetComponentData <Scale>(entity).Value;
            temp     = entityManager.GetName(entity).Split(':');
            //	coreData.Name = temp[0];
            //	coreData.BaseName = temp.Length > 1 ? temp[1] : "";
            if (!coreData.IsUpdated(entityManager, entity))
            {
                coreData.Update(entityManager, entity, scale);
            }
            if (entityManager.HasComponent <PhysicsVelocity>(entity) && !physicsVelocity.IsUpdated(entityManager, entity))
            {
                physicsVelocity.Update(entityManager, entity);
            }
            if (entityManager.HasComponent <PhysicsDamping>(entity) && !physicsDamping.IsUpdated(entityManager, entity))
            {
                physicsDamping.Update(entityManager, entity);
            }
            if (entityManager.HasComponent <PhysicsMass>(entity) && !physicsMass.IsUpdated(entityManager, entity))
            {
                physicsMass.Update(entityManager, entity);
            }
            if (entityManager.HasComponent <PokemonEntityData>(entity) && !pokemonEntityData.IsUpdated(entityManager, entity))
            {
                pokemonEntityData.Update(entityManager, entity);
            }
        }
        if (applyChange)
        {
            if (!DoNotChangePosition)
            {
                entityManager.SetComponentData(entity, new Translation {
                    Value = position
                });
            }
            if (!DoNotChangeScale)
            {
                entityManager.SetComponentData(entity, new Scale {
                    Value = scale
                });                                                                                 //got to scale of physics collider as well
                coreData.Update(entityManager, entity, scale);
                PhysicsCollider pc         = entityManager.GetComponentData <PhysicsCollider>(entity);
                int             groupIndex = 1;
                if (entityManager.HasComponent <GroupIndexInfo>(entity))
                {
                    groupIndex = entityManager.GetComponentData <GroupIndexInfo>(entity).CurrentGroupIndex;
                }
                entityManager.SetComponentData(entity, PokemonDataClass.getPokemonPhysicsCollider(coreData.BaseName, pokemonEntityData.ped, pc.Value.Value.Filter, scale, PokemonDataClass.GetPokemonColliderMaterial(PokemonDataClass.StringToPokedexEntry(coreData.BaseName)), groupIndex));
                entityManager.SetComponentData(entity, new Translation
                {
                    Value = entityManager.GetComponentData <Translation>(entity).Value + ((pokemonEntityData.ped.Height * scale) / 2)
                });
            }
            if (!coreData.DoNotChange)
            {
                coreData.Update(entityManager, entity, scale);
            }

            if (!physicsVelocity.DoNotChange)
            {
                physicsVelocity.ApplyChanges(entityManager, entity);
            }
            if (!physicsDamping.DoNotChange)
            {
                physicsDamping.ApplyChanges(entityManager, entity);
            }
            if (!pokemonEntityData.DoNotChange)
            {
                pokemonEntityData.ApplyChange(entityManager, entity);
            }
            if (!physicsMass.DoNotChange)
            {
                physicsMass.ApplyChange(entityManager, entity, pokemonEntityData.ped.Mass);
            }


            if (!constantChange)
            {
                applyChange = false;
                EditMode    = false;
            }
        }
    }