public override void Load(GameDataReader reader)
 {
     focalShape       = reader.ReadShapeInstance();
     frequency        = reader.ReadFloat();
     cosOffset        = reader.ReadVector3();
     sinOffset        = reader.ReadVector3();
     previousPosition = reader.ReadVector3();
 }
        public void Initialize(Shape shape, Shape focalShape, float radius, float frequency)
        {
            this.focalShape = focalShape;
            this.frequency  = frequency;
            Vector3 orbitAxis = Random.onUnitSphere;

            do
            {
                cosOffset = Vector3.Cross(orbitAxis, Random.onUnitSphere).normalized;
            }while (cosOffset.sqrMagnitude < 0.1f);
            sinOffset  = Vector3.Cross(cosOffset, orbitAxis);
            cosOffset *= radius;
            sinOffset *= radius;

            shape.AddBehavior <RotationShapeBehavior>().AngularVelocity =
                -360f * frequency *
                shape.transform.InverseTransformDirection(orbitAxis);

            GameUpdate(shape);
            previousPosition = shape.transform.localPosition;
        }
 public void Write(ShapeInstance value)
 {
     writer.Write(value.IsValid ? value.Shape.SaveIndex : -1);
 }