HasUserDataValue() public method

Checks if a particle has a certain user data slot filled with data
public HasUserDataValue ( int slotID ) : bool
slotID int the slot id obtained by MBEmitter.GetParticleUserDataID
return bool
    public override bool OnLifetime(MBParticle PT)
    {
        if (PT.HasUserDataValue(mGameObjectSlotID)) {
            Transform ptobj = PT.UserData[mGameObjectSlotID] as Transform;
            if (ptobj) {
                if (SyncPosition)
                    ptobj.position = ParticleSystem.Transform.TransformPoint(PT.Position);
                if (SyncSize)
                    ptobj.localScale = PT.Scale;

                switch (SyncRotation) {
                    case MBParticleTransformConnectorRotationMode.None: break;
                    case MBParticleTransformConnectorRotationMode.ByVelocity:
                        if (PT.Velocity != Vector3.zero)
                            ptobj.rotation = Quaternion.LookRotation(PT.Velocity);
                        break;
                    case MBParticleTransformConnectorRotationMode.ByHeading:
                        if (PT.Heading != Vector3.zero)
                            ptobj.rotation = Quaternion.LookRotation(PT.Heading);
                        break;
                }

            }
        }
        return true;
    }
Ejemplo n.º 2
0
 public override bool OnLifetime(MBParticle PT)
 {
     if (PT.HasUserDataValue(mLifeLastTimeID) && PT.HasUserDataValue(mLifeDirID)) {
          float lastTime = (float)PT.UserData[mLifeLastTimeID];
          int dir = (int)PT.UserData[mLifeDirID];
          if (ParticleSystem.GlobalTime - lastTime >= mLifetimeStepTime) {
              PT.ImageFrameIndex = Advance(PT.ImageFrameIndex, ref dir, LifetimeAnimRepeat, LifetimeAnimMode);
              PT.UserData[mLifeLastTimeID] = lastTime + mLifetimeStepTime;
              PT.UserData[mLifeDirID] = dir;
          }
      }
      return true;
 }
Ejemplo n.º 3
0
    public override bool OnLifetime(MBParticle PT)
    {
        if (DelaySync) {
            if (mLastGT==ParentEmitter.ParticleSystem.GlobalTime){
            } else if (mNextGT < ParentEmitter.ParticleSystem.GlobalTime) {
                    mNextGT = PT.ParticleSystem.GlobalTime + Delay + Delay * DelayRandomPercent;
                    mLastGT = ParentEmitter.ParticleSystem.GlobalTime;
            } else
                return true;
        }
        else {
            if (PT.HasUserDataValue(mSlotID) && (float)PT.UserData[mSlotID] < PT.ParticleSystem.GlobalTime) {
                PT.UserData[mSlotID] = PT.ParticleSystem.GlobalTime + Delay + Delay * DelayRandomPercent;
            }
            else
                return true;
        }

        Vector3 v = (Value + Value * RandomPercent);
        if (RandomSign)
            v *= MBUtility.RandomSign();

        switch (Target) {
            case MBParticleMathOperatorTarget.Position:
                DoOp(ref PT.Position, v);
                break;
            case MBParticleMathOperatorTarget.DistanceToCenter:
                Vector3 dir=(PT.Parent.Position-PT.Position);
                float d=dir.magnitude;
                DoOp(ref d, v.x);
                PT.Position = PT.Parent.Position - dir.normalized * d;
                break;
            case MBParticleMathOperatorTarget.Size:
                DoOp(ref PT.Scale, v);
                break;
            case MBParticleMathOperatorTarget.Acceleration:
                DoOp(ref PT.Acceleration, v.x);
                break;
            case MBParticleMathOperatorTarget.Friction:
                DoOp(ref PT.Friction, v.x);
                break;
            case MBParticleMathOperatorTarget.Heading:
                DoOp(ref PT.Heading, v);
                break;
            case MBParticleMathOperatorTarget.Mass:
                DoOp(ref PT.Mass, v.x);
                break;
            case MBParticleMathOperatorTarget.Rotation:
                DoOp(ref PT.Rotation, v);
                break;
        }

        return true;
    }